-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
215 lines (181 loc) · 4.25 KB
/
CMakeLists.txt
File metadata and controls
215 lines (181 loc) · 4.25 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# This ships with Ubuntu 20.04 and supports C++20
cmake_minimum_required(VERSION 3.16)
list(
APPEND
CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/cmake
)
include(Policies)
set_policies()
# Require out-of-source builds (taken from
# https://hsf-training.github.io/hsf-training-cmake-webpage/07-commonproblems/index.html)
file(
TO_CMAKE_PATH
"${PROJECT_BINARY_DIR}/CMakeLists.txt"
LOC_PATH
)
if(EXISTS "${LOC_PATH}")
message(
FATAL_ERROR
"You cannot build in a source directory (or any directory with "
"CMakeLists.txt file). Please make a build subdirectory. Feel free to "
"remove CMakeCache.txt and CMakeFiles."
)
endif()
# End of require out-of-source builds
# Project information
set(METACG_VERSION 1.0.0)
project(
MetaCG
VERSION ${METACG_VERSION}
DESCRIPTION "An annotatable whole-program call-graph toolset"
)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(METACG_Directory ${CMAKE_CURRENT_SOURCE_DIR})
# Whether the GoogleTest-based unit tests should be built and GoogleTest is downloaded as dependency This needs to be
# here, so ToolchainOptions already "sees" the option's value
option(
METACG_BUILD_UNIT_TESTS
"On or Off"
ON
)
if(METACG_BUILD_UNIT_TESTS)
enable_testing()
include(GoogleTest)
endif()
include(ToolchainOptions)
# Making packaging easier
include(CMakePackageConfigHelpers)
# Making printing / debugging easier
include(CMakePrintHelpers)
# Obtain ghe git revision of this MetaCG repository
include(GetGitRevisionDescription)
# Stream the verison info in the project's config.h
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
if(NOT
DEFINED
GIT_SHA1
)
set(GIT_SHA1 "NO_GIT_ROOT")
endif()
# Configure the file that holds version information
configure_file(Config.h.in include/metacg/config.h)
# Component options MetaCG graph library will always be built. The actual graph implementation
add_subdirectory(graph)
option(
METACG_BUILD_GRAPH_TOOLS
"Build new graphlib-based tools (cgcollector2, cgmerge2)"
OFF
)
if(METACG_BUILD_GRAPH_TOOLS)
# New MetaCG tools based on the graphlib
include(ClangLLVM)
# Determine if we can build CaGe
if(${LLVM_PACKAGE_VERSION}
GREATER
15
)
set(BUILD_CAGE ON)
option(
CAGE_USE_METAVIRT
ON
"Rely on metavirt for virtual call handling"
)
if(${CAGE_USE_METAVIRT})
include(metavirt)
endif()
else()
set(BUILD_CAGE OFF)
message(STATUS "Skipping CaGe: requires LLVM version 16 or higher")
endif()
add_subdirectory(tools)
endif()
# Build the collector toolchain: CGCollector, CGMerge, and CGValidate
option(
METACG_BUILD_CGCOLLECTOR
"On or off"
OFF
)
if(METACG_BUILD_CGCOLLECTOR)
include(ClangLLVM)
include(CubeLib)
add_subdirectory(cgcollector)
endif()
# Build CGPatch: cgpatch-pass, cgpatch-runtime, wrappers, tests
option(
METACG_BUILD_CGPATCH
"On or off"
OFF
)
if(METACG_BUILD_CGPATCH)
if(NOT METACG_BUILD_GRAPH_TOOLS)
message(FATAL_ERROR "CGPatch requires to build with METACG_BUILD_GRAPH_TOOLS=ON")
endif()
if(${LLVM_PACKAGE_VERSION}
GREATER
14
)
add_subdirectory(tools/cgpatch/)
else()
message(STATUS "Skipping CGPatch: requires LLVM version 15 or higher")
endif()
endif()
# PIRA analyzer Should PGIS be built
option(
METACG_BUILD_PGIS
"On or off"
OFF
)
if(METACG_BUILD_PGIS)
include(ExtraP)
include(CubeLib)
add_subdirectory(pgis)
endif()
# If set to on, CMake looks for installed nlohmann::json
option(
METACG_USE_EXTERNAL_JSON
"On or off"
OFF
)
# If set to on, CMake looks for installed cxxopts
option(
METACG_USE_EXTERNAL_CXXOPTS
"On or Off"
OFF
)
# Enable MPI for CGPatch
option(
CGPATCH_USE_MPI
"On or Off"
ON
)
if(METACG_BUILD_CGPATCH AND CGPATCH_USE_MPI)
find_package(MPI REQUIRED)
message(STATUS "MPI VERSION: ${MPI_C_VERSION}")
endif()
# Build MetaCG's Python interface
option(
METACG_BUILD_PYMETACG
"On or off"
OFF
)
# If set to on, CMake looks for installed nanobind
option(
METACG_USE_EXTERNAL_NANOBIND
"On or Off"
OFF
)
# Build tests for pymetacg
option(
METACG_BUILD_PYMETACG_TESTS
"On or Off"
OFF
)
if(METACG_BUILD_PYMETACG)
add_subdirectory(pymetacg)
endif()
add_subdirectory(utils)