forked from qingkaishi/canary
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
86 lines (70 loc) · 2.32 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
86
cmake_minimum_required(VERSION 3.10.0)
project(canary C CXX)
# Set C++ standard to 14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Check for LLVM build path
if (NOT LLVM_BUILD_PATH)
message(FATAL_ERROR "Please specify the build folder of LLVM using -DLLVM_BUILD_PATH=")
else()
message(STATUS "LLVM_BUILD_PATH set to: ${LLVM_BUILD_PATH}")
endif()
# Find LLVM package
find_package(LLVM REQUIRED CONFIG PATHS ${LLVM_BUILD_PATH})
if(NOT LLVM_FOUND)
message(FATAL_ERROR "Cannot find LLVMConfig.cmake under path: ${LLVM_BUILD_PATH}")
endif()
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
message(STATUS "LLVM header files located in: ${LLVM_INCLUDE_DIRS}")
# Check LLVM version
if (LLVM_PACKAGE_VERSION VERSION_EQUAL "12.0.0")
message(STATUS "Using LLVM version 12")
add_definitions(-DLLVM12)
elseif (LLVM_PACKAGE_VERSION VERSION_EQUAL "14.0.0")
message(STATUS "Using LLVM version 14")
add_definitions(-DLLVM14)
else()
message(FATAL_ERROR "Unsupported or unknown LLVM version: ${LLVM_PACKAGE_VERSION}")
endif()
# Set compiler flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fexceptions")
# Set output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
option(BUILD_TESTS "build all unit tests" OFF)
# Include LLVM directories
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
link_directories(${LLVM_LIBRARY_DIRS})
include_directories(AFTER ${CMAKE_CURRENT_SOURCE_DIR}/include)
# Find Z3
find_library(
Z3_LIBRARIES
NAMES z3
HINTS ${Z3_DIR} ENV Z3_DIR
PATH_SUFFIXES bin lib
)
find_path(
Z3_INCLUDES
NAMES z3++.h
HINTS ${Z3_DIR} ENV Z3_DIR
PATH_SUFFIXES include z3
)
if(NOT Z3_LIBRARIES OR NOT Z3_INCLUDES)
message(FATAL_ERROR "Z3 not found!")
endif()
message(STATUS "Found Z3: ${Z3_LIBRARIES}")
message(STATUS "Z3 include dir: ${Z3_INCLUDES}")
include_directories(${Z3_INCLUDES})
# Add subdirectories
add_subdirectory(lib)
add_subdirectory(tools)
add_subdirectory(benchmarks)
if (BUILD_TESTS)
add_subdirectory(test)
endif()
enable_testing()
add_test(AliasTest ${PROJECT_BINARY_DIR}/test/AliasTest)