-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
129 lines (102 loc) · 3.98 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
cmake_minimum_required (VERSION 3.6)
project(Automated-Neck-Identification)
set(CMAKE_PROJECT_NAME "Automated-Neck-Identification")
set(CMAKE_EXPORT_COMPILE_COMMANDS YES)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set_property(GLOBAL PROPERTY TARGET_MESSAGES OFF)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "DebugSan" CACHE STRING "Build mode ('DebugSan', 'Debug' or 'Release', default is 'DebugSan')" FORCE)
endif ()
if(CMAKE_BUILD_TYPE STREQUAL "DebugSan")
# Debug build with address and undefined behavior sanitizers enabled
message(STATUS "Select Debug Build with Sanitizers")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP -fstack-protector-strong -g -fno-omit-frame-pointer -fsanitize=address,undefined")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address,undefined")
# Required to communicate enabled sanitizers to PhASAR
set(LLVM_USE_SANITIZER "Address,Undefined")
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
# Standard debug build
message(STATUS "Select Debug Build")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP -fstack-protector-strong -g")
else()
# Release build
message(STATUS "Select Release Build")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -MP -fstack-protector-strong -march=native")
endif()
# Enable testing
enable_testing()
set(NECKID_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${NECKID_SRC_DIR}/cmake")
include("neckid_macros")
option(NECKID_RUN_CLANGTIDY_IN_BUILD "Run clang-tidy during the build (may be expensive on small machines, default is OFF)" OFF)
option(NECKID_BUILD_UNITTESTS "Build all tests (default is ON)" ON)
option(NECKID_BUILD_IR "Build IR test code (default is ON)" ON)
option(BUILD_SHARED_LIBS "Build shared libraries (default is ON)" ON)
option(NECKID_ENABLE_WARNINGS "Enable warnings" ON)
if (NECKID_ENABLE_WARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-variable -Wno-unused-parameter -Wno-return-type-c-linkage ")
endif (NECKID_ENABLE_WARNINGS)
option(NECKID_ENABLE_PIC "Build Position-Independed Code" ON)
if (NECKID_ENABLE_PIC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif (NECKID_ENABLE_PIC)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(
${NECKID_SRC_DIR}/include/
)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
if (LLVM_ENABLE_LIBCXX)
set(NECKID_STD_FILESYSTEM c++fs)
else()
set(NECKID_STD_FILESYSTEM stdc++fs)
endif()
### Adding external libraries
# Threads
find_package(Threads)
# Boost
find_package(Boost 1.65.1 COMPONENTS filesystem graph system program_options log ${BOOST_THREAD} REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
# Disable clang-tidy for the external projects
set(CMAKE_CXX_CLANG_TIDY "")
# PhASAR
add_subdirectory(external/phasar)
# find_package(phasar COMPONENTS db REQUIRED)
include_directories(external/phasar/include/)
# include_directories(${PHASAR_INCLUDE_DIR})
link_directories(${PHASAR_LIBRARY_DIR})
# Googletest
# Set up Googletest only if it is not already available through PhASAR
if (NOT TARGET gtest OR NOT TARGET gmock)
add_subdirectory(external/googletest)
endif()
include_directories(external/googletest/googletest/include)
include_directories(external/googletest/googlemock/include)
# LLVM
find_package(LLVM 12 REQUIRED CONFIG)
set(USE_LLVM_FAT_LIB ON)
# the remaining LLVM related setup is performed by PhASAR
# Set up clang-tidy to be applied during compilation to indicate code smells
if (NECKID_RUN_CLANGTIDY_IN_BUILD)
set(CMAKE_CXX_CLANG_TIDY
clang-tidy;
-header-filter=NeckID.*;
# -warnings-as-errors=*;
)
endif()
# Add the Neck-ID subdirectories
add_subdirectory(config)
add_subdirectory(include)
add_subdirectory(lib)
add_subdirectory(tools)
if (NECKID_BUILD_UNITTESTS)
message("NeckID Unittests")
add_subdirectory(unittests)
set(NECKID_BUILD_IR ON)
endif()
if (NECKID_BUILD_IR)
message("Building IR Test Code")
add_subdirectory(test)
endif()