-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
86 lines (71 loc) · 1.99 KB
/
CMakeLists.txt
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
81
82
83
84
85
cmake_minimum_required(VERSION 3.10)
project(llvmsandbox)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-elide-constructors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,undefined,integer,nullability -fno-sanitize-recover=address,undefined,integer,nullability")
set(LLVM_CONFIG_BIN "/usr/bin/llvm-config-6.0")
execute_process(
COMMAND
${LLVM_CONFIG_BIN} --libs
OUTPUT_VARIABLE
LLVM_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND
${LLVM_CONFIG_BIN} --includedir
OUTPUT_VARIABLE
LLVM_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND
${LLVM_CONFIG_BIN} --libdir
OUTPUT_VARIABLE
LLVM_LIBRARY_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND
${LLVM_CONFIG_BIN} --system-libs
OUTPUT_VARIABLE
LLVM_SYSTEM_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND
${LLVM_CONFIG_BIN} --version
OUTPUT_VARIABLE
LLVM_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND
${LLVM_CONFIG_BIN} --build-mode
OUTPUT_VARIABLE
LLVM_BUILD_TYPE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND
${LLVM_CONFIG_BIN} --has-rtti
OUTPUT_VARIABLE
LLVM_HAS_RTTI
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "LLVM version : ${LLVM_VERSION}")
message(STATUS "LLVM includedir : ${LLVM_INCLUDE_DIRS}")
message(STATUS "LLVM libdir : ${LLVM_LIBRARY_DIRS}")
message(STATUS "LLVM build type : ${LLVM_BUILD_TYPE}")
message(STATUS "LLVM has rtti : ${LLVM_HAS_RTTI}")
set(CMAKE_CXX_STANDARD 11)
file(GLOB SRCS "*.cpp")
foreach(src IN LISTS SRCS)
get_filename_component(fname "${src}" NAME_WE)
add_executable("${fname}" ${src})
link_directories(${LLVM_LIBRARY_DIRS})
target_include_directories(${fname} PRIVATE ${LLVM_INCLUDE_DIRS})
target_link_libraries(${fname}
PRIVATE
${LLVM_LIBS}
${LLVM_SYSTEM_LIBS})
endforeach()