-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
80 lines (62 loc) · 2.93 KB
/
CMakeLists.txt
File metadata and controls
80 lines (62 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
cmake_minimum_required(VERSION 3.24)
project(SakuraE)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
message(STATUS "LLVM_INCLUDE_DIRS: ${LLVM_INCLUDE_DIRS}")
string(REPLACE "." ";" LLVM_PACKAGE_VERSION_LIST "${LLVM_PACKAGE_VERSION}")
list(GET LLVM_PACKAGE_VERSION_LIST 0 LLVM_MAJOR_VERSION)
find_program(LLVM_CONFIG_EXECUTABLE
NAMES llvm-config llvm-config-${LLVM_MAJOR_VERSION}
DOC "Path to the llvm-config executable"
REQUIRED
)
message(STATUS "Using llvm-config executable: ${LLVM_CONFIG_EXECUTABLE}")
execute_process(COMMAND ${LLVM_CONFIG_EXECUTABLE} --libs all
OUTPUT_VARIABLE llvm_components
OUTPUT_STRIP_TRAILING_WHITESPACE
RESULT_VARIABLE LLVM_LIBS_RESULT
)
string(REPLACE " " ";" llvm_components_list "${llvm_components}")
execute_process(COMMAND ${LLVM_CONFIG_EXECUTABLE} --libdir
OUTPUT_VARIABLE llvm_libdir
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# print LLVM components
message(STATUS "LLVM libdir: ${llvm_libdir}")
message(STATUS "LLVM components: ${llvm_components}")
# -Wfloat-equal
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g -Wall -pedantic -Wimplicit-fallthrough -Wsequence-point -Wstringop-truncation -Wbool-compare -Wtautological-compare -Wshadow=global -Wpointer-arith -Wpointer-compare -Wcast-align -Wcast-qual -Wwrite-strings -Wdangling-else -Wlogical-op -Werror")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
file(GLOB SRC_FILES "includes/magic_enum.hpp"
"main.cpp"
"Compiler/Frontend/lexer.*"
"Compiler/Frontend/parser_base.hpp"
"Compiler/Frontend/parser.hpp"
"Compiler/Frontend/parser.cpp"
"Compiler/Error/error.hpp"
"Compiler/Utils/logger.hpp"
"Compiler/Frontend/AST.h"
"Compiler/IR/*.hpp"
"Compiler/IR/*.cpp"
"Compiler/IR/value/*.hpp"
"Compiler/IR/value/*.cpp"
"Compiler/IR/struct/*.hpp"
"Compiler/IR/type/*.hpp"
"Compiler/IR/type/*.cpp"
"Compiler/LLVMCodegen/*.cpp"
"Compiler/LLVMCodegen/*.hpp"
"atrI/*.hpp"
"atrI/config.*hpp")
file(GLOB RUNTIME_FILES "Runtime/*.cpp"
"Runtime/*.h")
add_executable(${CMAKE_PROJECT_NAME} ${SRC_FILES} ${RUNTIME_FILES})
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR})
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE ${llvm_components_list})