-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
75 lines (61 loc) · 2.37 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
cmake_minimum_required(VERSION 3.4.3)
project(aser_pta)
if (EXISTS /llvm-project/build/lib/cmake/llvm/)
# We are probably in the dev container
if(CMAKE_BUILD_TYPE MATCHES "Debug")
# here link to shared llvm
set(LLVM_DIR /llvm-project/build-shared/lib/cmake/llvm/)
else()
set(LLVM_DIR /llvm-project/build/lib/cmake/llvm/)
endif()
endif()
if(NOT ENABLE_TEST)
set(ENABLE_TEST Off) # default disable testing
endif()
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSPDLOG_ACTIVE_LEVEL=2 -DRACE_DETECT_DEBUG") # log level = debug
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSPDLOG_ACTIVE_LEVEL=2") # log level = warn
endif()
set(COMMON_CXX_FLAG "-fno-rtti -Wno-c++14-extensions -Wno-c++17-extensions -DNO_ADDR_OF_FOR_OFFSET")
# To support both in- and out-of-source builds,
# we check for the presence of the add_llvm_loadable_module command.
# - if this command is not present, we are building out-of-source
if(NOT COMMAND add_llvm_loadable_module)
if (DEFINED LLVM_DIR)
# We need to match the build environment for LLVM:
# In particular, we need C++11 and the -fno-rtti flag
set(CMAKE_CXX_STANDARD 11)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O0 ${COMMON_CXX_FLAG}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -O3 ${COMMON_CXX_FLAG}")
endif()
find_package(LLVM 9.0.0 REQUIRED CONFIG NO_DEFAULT_PATH)
message("FIND LLVM IN ${LLVM_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(AddLLVM)
add_definitions(${LLVM_DEFINITIONS})
include_directories(${LLVM_INCLUDE_DIRS})
else()
message(FATAL_ERROR "\
WARNING: The LLVM_DIR var was not set (required for an out-of-source build)!\n\
Please set this to environment variable to point to the LLVM build directory\
(e.g. on linux: export LLVM_DIR=/path/to/llvm/build/dir)")
endif()
else()
set(IN_SOURCE_BUILD 1)
endif()
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
utils/jsoncons/include
utils)
add_subdirectory(lib)
add_subdirectory(tools)
# unit tests
#if (${ENABLE_TEST})
enable_testing()
add_subdirectory(utils/googletest)
add_subdirectory(unittests/PointerAnalysis)
#endif()