-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
71 lines (64 loc) · 1.9 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
cmake_minimum_required(VERSION 3.10)
project(seexperiment)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
if(DEFINED LLVM_PREFIX)
set(LLVM_CONFIG ${LLVM_PREFIX}/bin/llvm-config)
# specify LLVM include dir
set(LLVM_INCLUDE ${LLVM_PREFIX}/include)
# specify LLVM lib dir
set(LLVM_LIB ${LLVM_PREFIX}/lib)
elseif(DEFINED LLVM_BUILD)
set(LLVM_CONFIG ${LLVM_BUILD}/bin/llvm-config)
# run `llvm-config --src-root` to get llvm source root path, and output it to variable LLVM_SRC
execute_process(
COMMAND ${LLVM_CONFIG} --src-root
OUTPUT_VARIABLE LLVM_SRC
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# specify LLVM include dir
set(LLVM_INCLUDE
${LLVM_SRC}/include ${LLVM_SRC}/tools/clang/include
${LLVM_BUILD}/include ${LLVM_BUILD}/tools/clang/include
)
# specify LLVM lib dir
set(LLVM_LIB ${LLVM_BUILD}/lib)
else()
message(FATAL_ERROR "You must define one of the two variables: LLVM_PREFIX, LLVM_BUILD")
endif()
# run `llvm-config --libs` to get llvm libs list, and output it to variable LLVM_LIBS
execute_process(
COMMAND ${LLVM_CONFIG} --libs
OUTPUT_VARIABLE LLVM_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# define CLANG_LIBS: some clang libs to be used in link time
# !!! DO NOT change the order of the libs !!!
# libs will be linked in this order, and changing the order could lead to link errors
set(CLANG_LIBS
clangTooling
clangFrontendTool
clangFrontend
clangDriver
clangSerialization
clangCodeGen
clangParse
clangSema
clangStaticAnalyzerFrontend
clangStaticAnalyzerCheckers
clangStaticAnalyzerCore
clangAnalysis
clangARCMigrate
clangRewriteFrontend
clangEdit
clangAST
clangASTMatchers
clangLex
clangBasic
)
# define OTHER_LIBS: other libs to be used in link time
set(OTHER_LIBS pthread z dl curses)
include_directories(include ${LLVM_INCLUDE})
link_directories(${LLVM_LIB})
add_subdirectory(lib)
add_subdirectory(tools)