-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
73 lines (63 loc) · 2.25 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
# the CMakeLists.txt for default llvm build, recommended with the bundled alive2
cmake_minimum_required(VERSION 3.13)
project(TranslationValidator C CXX)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti -fexceptions")
if(APPLE)
# suppress the ld warning about duplicate libraries
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-w")
endif()
# find the llvm version
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
# include llvm headers
include_directories(${LLVM_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})
# find z3
find_package(Z3 REQUIRED)
include_directories(${Z3_INCLUDE_DIRS})
add_definitions(${Z3_DEFINITIONS})
# set the path to alive2
# make sure you have built alive2 first either through `make alive2`
# or the automatic build when running `make full_build`.
set(ALIVE2_DIR "${CMAKE_CURRENT_SOURCE_DIR}/alive2_snapshot")
# include alive2 headers
include_directories(${ALIVE2_DIR})
# add source files
add_executable(standalone src/standalone.cpp)
add_executable(validator_server src/ValidatorServer.cpp)
llvm_map_components_to_libnames(llvm_libs
Core
Support
IRReader
BitReader
MC
Option
Analysis
Target
TargetParser
)
target_link_libraries(standalone PRIVATE
${ALIVE2_DIR}/build/libllvm_util.a # for `llvm_util::initializer`
${ALIVE2_DIR}/build/libtools.a
${ALIVE2_DIR}/build/libir.a
${ALIVE2_DIR}/build/libsmt.a
${ALIVE2_DIR}/build/libutil.a
${Z3_LIBRARIES}
${llvm_libs} # will trigger ld warning(s) regarding duplicate libraries but that's fine
)
# link against llvm, z3, and alive2
target_link_libraries(validator_server PRIVATE
${ALIVE2_DIR}/build/libllvm_util.a # for `llvm_util::initializer`
${ALIVE2_DIR}/build/libtools.a
${ALIVE2_DIR}/build/libir.a
${ALIVE2_DIR}/build/libsmt.a
${ALIVE2_DIR}/build/libutil.a
${Z3_LIBRARIES}
${llvm_libs} # will trigger ld warning(s) regarding duplicate libraries but that's fine
)