-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
98 lines (92 loc) · 3.65 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
87
88
89
90
91
92
93
94
95
96
97
98
cmake_minimum_required(VERSION 3.22)
project(Unias)
# TODO: Avoid hardcoding paths. Use environment variables instead.
set(ENV{LLVM_DIR} /mnt/sdc/lhy_tmp/spa/env/llvm-project-14.0.6.src/build/lib/cmake)
set(ENV{SVF_DIR} /mnt/sdc/lhy_tmp/spa/Unias-repro/SVF-SVF-2.8)
set(ENV{Z3_DIR} /mnt/sdc/lhy_tmp/spa/Unias-repro/SVF-SVF-2.8/z3.obj)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# cd build; cmake .. -DCMAKE_BUILD_TYPE=Release
# make -j8
# set LLVM_DIR
if (DEFINED ENV{LLVM_DIR})
# We need to match the build environment for LLVM:
# In particular, we need C++11 and the -fno-rtti flag
# MESSAGE(STATUS "FOOBAR env seen: --[$ENV{LLVM_DIR}]--")
set(CMAKE_CXX_STANDARD 14)
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++14 -O0 -fno-rtti -Wno-deprecated")
else()
set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++14 -O3 -fno-rtti -Wno-deprecated")
endif()
set(CMAKE_C_FLAGS "-fPIC")
find_package(LLVM REQUIRED CONFIG)
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()
# set SVF_DIR
if (EXISTS "${SVF_DIR}")
# MESSAGE(STATUS "FOOBAR env seen: --[${SVF_DIR}]--")
else()
# MESSAGE(STATUS "FOOBAR env seen: --[$ENV{SVF_DIR}]--")
set(SVF_DIR $ENV{SVF_DIR})
if(EXISTS "${SVF_DIR}")
else()
message(FATAL_ERROR "\
WARNING: The SVF_DIR var was not set (required for an out-of-source build)!\n\
Please set this to environment variable to point to the SVF_DIR directory or set this variable to cmake configuration\n
(e.g. on linux: export SVF_DIR=/path/to/SVF/dir) \n or \n \n(make the project via: cmake -DSVF_DIR=your_path_to_SVF) ")
endif()
endif()
if(CMAKE_BUILD_TYPE MATCHES "Debug")
MESSAGE (STATUS "building SVF in debug mode")
set(SVF_LIB "${SVF_DIR}/Debug-build/svf-llvm/libSvfLLVM.a" "${SVF_DIR}/Debug-build/svf/libSvfCore.a")
# set(LLVMCudd "${SVF_DIR}/Debug-build/lib/CUDD/libCudd.a")
else()
MESSAGE (STATUS "building SVF in release mode")
set(SVF_LIB "${SVF_DIR}/Release-build/svf-llvm/libSvfLLVM.a" "${SVF_DIR}/Release-build/svf/libSvfCore.a")
# set(LLVMCudd "${SVF_DIR}/Release-build/lib/CUDD/libCudd.a")
endif()
set(SVF_HEADER "${SVF_DIR}/svf-llvm/include" "${SVF_DIR}/svf/include" "${SVF_DIR}/Release-build/include")
include_directories(${SVF_HEADER})
#set z3 env
if (DEFINED Z3_DIR)
set(ENV{Z3_DIR} "${Z3_DIR}")
endif()
if(CMAKE_BUILD_TYPE MATCHES "Debug")
if(EXISTS "${Z3_DIR}/src")
find_package(Z3 REQUIRED CONFIG)
include_directories(${Z3_CXX_INCLUDE_DIRS})
else()
find_library(Z3_LIBRARIES NAMES libz3.a libz3.so
HINTS $ENV{Z3_DIR}
PATH_SUFFIXES bin)
find_path(Z3_INCLUDES NAMES z3++.h
HINTS $ENV{Z3_DIR}
PATH_SUFFIXES include z3)
if(NOT Z3_LIBRARIES OR NOT Z3_INCLUDES)
message(FATAL_ERROR "Z3 not found!")
endif()
include_directories(${Z3_INCLUDES})
LINK_DIRECTORIES(${Z3_DIR}/bin)
endif()
else()
find_library(Z3_LIBRARIES NAMES libz3.a libz3.so
HINTS $ENV{Z3_DIR}
PATH_SUFFIXES bin)
find_path(Z3_INCLUDES NAMES z3++.h
HINTS $ENV{Z3_DIR}
PATH_SUFFIXES include z3)
if(NOT Z3_LIBRARIES OR NOT Z3_INCLUDES)
message(FATAL_ERROR "Z3 not found!")
endif()
include_directories(${Z3_INCLUDES})
LINK_DIRECTORIES(${Z3_DIR}/bin)
endif()
add_subdirectory(src)