forked from vprover/vampire
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
304 lines (253 loc) · 9.34 KB
/
CMakeLists.txt
File metadata and controls
304 lines (253 loc) · 9.34 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
################################################################
# general configuration
################################################################
cmake_minimum_required (VERSION 3.14.0)
project(Vampire)
# version
set(VAMPIRE_VERSION_NUMBER 5.0.1)
include(CheckSymbolExists)
include(CTest)
include(cmake/sources.cmake)
find_package(Git QUIET)
# require the compiler to use C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# compile command database
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# we use threads, make sure we link the thread-support stuff
find_package(Threads REQUIRED)
link_libraries(Threads::Threads)
# set build type if not set
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "build type" FORCE)
endif()
message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} " (options: Release (default), Debug, RelWithDebInfo)")
option(BUILD_SHARED_LIBS "build Vampire with dynamic linking" ON)
if (NOT BUILD_SHARED_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
set(CMAKE_EXE_LINKER_FLAGS -static)
endif()
message(STATUS "BUILD_SHARED_LIBS: " ${BUILD_SHARED_LIBS})
# enable CCache if available
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
message(STATUS "found ccache, enabling for this build")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
message(STATUS "CCACHE_PROGRAM: " ${CCACHE_PROGRAM})
endif()
################################################################
# compiler configuration
################################################################
# add top level directory to the search path of compiler
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_compile_definitions(ABSOLUTE_SOURCE_DIR="${CMAKE_SOURCE_DIR}")
if(CMAKE_BUILD_TYPE STREQUAL Debug)
add_compile_definitions(VDEBUG=1)
else()
add_compile_definitions(VDEBUG=0)
endif()
option(CHECK_LEAKS "try to free more memory" OFF)
if(CHECK_LEAKS)
message(STATUS "CHECK_LEAKS = 1")
add_compile_definitions(CHECK_LEAKS=1)
else()
add_compile_definitions(CHECK_LEAKS=0)
endif()
option(TIME_PROFILING "enable internal profiler" OFF)
if(TIME_PROFILING)
message(STATUS "VTIME_PROFILING = 1")
add_compile_definitions(VTIME_PROFILING=1)
else()
add_compile_definitions(VTIME_PROFILING=0)
endif()
# Cygwin-specific
if(CYGWIN)
add_compile_definitions(_BSD_SOURCE)
# somehow Cygwin fails to link, saying that we have multiple definitions of some (inline) functions
add_link_options(LINKER:--allow-multiple-definition)
# link libstdc++ and libgcc statically
add_link_options(-static-libgcc -static-libstdc++)
# apparently Cygwin's libc cannot be statically linked, so we have to ship cygwin.dll
endif()
# below here configure flags for specific compilers
if(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang$)
set(GCC_OR_CLANG ON)
endif()
if(GCC_OR_CLANG)
add_compile_options(-Wall)
# we don't use multithreaded statics in Vampire
add_compile_options(-fno-threadsafe-statics)
# ...or RTTI
add_compile_options(-fno-rtti)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
add_compile_options(-fsanitize=undefined)
add_link_options(-fsanitize=undefined)
endif()
endif()
################################################################
# CODE COVERAGE
################################################################
option(COVERAGE "generate code coverage reports" OFF)
if(COVERAGE)
message(STATUS "Coverage is enabled")
include(${CMAKE_SOURCE_DIR}/cmake/CodeCoverage.cmake)
message(STATUS "Removing previous coverage data")
file(GLOB_RECURSE GCDA_FILES ${CMAKE_BINARY_DIR}/*.gcda)
file(REMOVE ${GCDA_FILES})
append_coverage_compiler_flags()
setup_target_for_coverage_gcovr_html(
NAME vcoverage
EXECUTABLE ctest
EXECUTABLE_ARGS "-j${CMAKE_BUILD_PARALLEL_LEVEL}"
EXCLUDE "${PROJECT_SOURCE_DIR}/CASC"
"${PROJECT_SOURCE_DIR}/Debug"
"${PROJECT_SOURCE_DIR}/UnitTests"
"${PROJECT_SOURCE_DIR}/Test"
"${PROJECT_SOURCE_DIR}/cadical"
"${PROJECT_SOURCE_DIR}/viras"
"${PROJECT_SOURCE_DIR}/z3")
endif()
################################################################
# VIRAS
################################################################
# attempt to automatically checkout VIRAS
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git" AND NOT EXISTS "${PROJECT_SOURCE_DIR}/viras/.git")
message(STATUS "VIRAS not checked out, running git submodule update")
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init viras
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
# check for VIRAS
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/viras/README.md")
message(FATAL_ERROR "VIRAS not found")
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/viras/src)
################################################################
# GMP
################################################################
# TODO git submodule?
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/mini-gmp-6.3.0)
################################################################
# CaDiCaL
################################################################
# attempt to automatically checkout CaDiCaL
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git" AND NOT EXISTS "${PROJECT_SOURCE_DIR}/cadical/README.md")
message(STATUS "CaDiCaL not checked out, running git submodule update")
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init cadical
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endif()
# check for CaDiCaL
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/cadical/README.md")
message(FATAL_ERROR "CaDiCaL not found")
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/cadical/src)
add_compile_definitions(NBUILD=1)
# Check if closefrom() exists in unistd.h
check_symbol_exists(closefrom "unistd.h" HAVE_CLOSEFROM)
# If closefrom() is missing, define NCLOSEFROM=1
if(NOT HAVE_CLOSEFROM)
add_compile_definitions(NCLOSEFROM=1)
endif()
################################################################
# Z3
################################################################
# find Z3 automatically
# normally this is just in /z3/build/, but this can be overridden using -DZ3_DIR
find_package(
Z3
CONFIG
NO_CMAKE_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_PACKAGE_REGISTRY
NO_CMAKE_SYSTEM_PATH
NO_CMAKE_SYSTEM_PACKAGE_REGISTRY
PATHS
${Z3_DIR}
${CMAKE_SOURCE_DIR}/z3/build/
)
if (Z3_FOUND)
message(STATUS "found Z3 " ${Z3_VERSION_STRING})
include_directories(${Z3_CXX_INCLUDE_DIRS})
link_directories(${Z3_DIR})
link_libraries(z3)
add_compile_definitions(VZ3=1)
set(UNIT_TESTS ${UNIT_TESTS} ${UNIT_TESTS_Z3})
else ()
message(STATUS "no Z3 found -- compiling without SMT support")
add_compile_definitions(VZ3=0)
endif()
################################################################
# Vampire
################################################################
# wrap up common object files so not built multiple times for each target
add_library(common OBJECT ${SOURCES})
# the actual Vampire executable
add_executable(vampire vampire.cpp $<TARGET_OBJECTS:common>)
install(TARGETS vampire)
################################################################
# UNIT TESTING
################################################################
if(CMAKE_BUILD_TYPE STREQUAL Debug)
foreach(test_file ${UNIT_TESTS})
get_filename_component(test_name ${test_file} NAME_WE)
string(REGEX REPLACE "^t" "" test_name ${test_name})
# set UNIT_ID for the unit test
set_property(SOURCE ${test_file} APPEND PROPERTY COMPILE_DEFINITIONS
UNIT_ID_STR=\"${test_name}\"
UNIT_ID=${test_name}
)
# register it with CTest
add_test(${test_name} ${CMAKE_BINARY_DIR}/vtest run ${test_name})
if(COVERAGE)
# coverage is a lot slower, so increase the timeout
set_tests_properties(${test_name} PROPERTIES TIMEOUT 180)
else()
set_tests_properties(${test_name} PROPERTIES TIMEOUT 60)
endif()
endforeach()
# build test executable
add_executable(
vtest
EXCLUDE_FROM_ALL # only build when explicitly requested
${TESTING_SOURCES}
${UNIT_TESTS}
$<TARGET_OBJECTS:common>
)
endif()
#################################################################
# automated generation of Vampire revision information from git #
#################################################################
execute_process(
COMMAND git rev-parse --is-inside-work-tree
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_IS_REPOSITORY
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (GIT_IS_REPOSITORY STREQUAL true)
# VAMPIRE_VERSION_NUMBER and CMAKE_BUILD_TYPE used by version.cpp.in through
# ConfigureGitVersionCpp.cmake
add_custom_target(update_git_version ALL
COMMAND ${CMAKE_COMMAND} -DVAMPIRE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
-DVAMPIRE_VERSION_NUMBER=${VAMPIRE_VERSION_NUMBER}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-P ${CMAKE_SOURCE_DIR}/cmake/ConfigureGitVersionCpp.cmake
BYPRODUCTS version.cpp
VERBATIM
)
else()
configure_file(version.cpp.in version.cpp)
endif()
################################################################
# subsat
################################################################
# standalone version of the SAT solver used for subsumption (resolution)
add_executable(subsat
EXCLUDE_FROM_ALL # only build when explicitly requested
SATSubsumption/subsat/subsat_main.cpp
$<TARGET_OBJECTS:common>
)