-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
380 lines (315 loc) · 13.2 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
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
include (GenerateExportHeader)
include (GNUInstallDirs)
message(STATUS "LIB directory is '${CMAKE_INSTALL_LIBDIR}'")
message(STATUS "BIN directory is '${CMAKE_INSTALL_BINDIR}'")
if(POLICY CMP0048)
#policy for VERSION in cmake 3.0
cmake_policy(SET CMP0048 NEW)
endif()
if(POLICY CMP0022)
cmake_policy(SET CMP0022 NEW)
endif()
if(POLICY CMP0046)
cmake_policy(SET CMP0046 NEW)
endif()
if(POLICY CMP0026)
cmake_policy(SET CMP0026 NEW)
endif()
# -----------------------------------------------------------------------------
# Provide scripts dir for included cmakes to use
# -----------------------------------------------------------------------------
set(CRYPTOMS_SCRIPTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scripts)
# -----------------------------------------------------------------------------
# Make RelWithDebInfo the default build type if otherwise not set
# -----------------------------------------------------------------------------
set(build_types Debug Release RelWithDebInfo MinSizeRel)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "You can choose the type of build, options are:${build_types}")
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
"Options are ${build_types}"
FORCE
)
# Provide drop down menu options in cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${build_types})
endif()
message(STATUS "Doing a ${CMAKE_BUILD_TYPE} build")
# -----------------------------------------------------------------------------
# Option to enable/disable assertions
# -----------------------------------------------------------------------------
# Filter out definition of NDEBUG from the default build configuration flags.
# We will add this ourselves if we want to disable assertions
foreach (build_config ${build_types})
string(TOUPPER ${build_config} upper_case_build_config)
foreach (language CXX C)
set(VAR_TO_MODIFY "CMAKE_${language}_FLAGS_${upper_case_build_config}")
string(REGEX REPLACE "(^| )[/-]D *NDEBUG($| )"
" "
replacement
"${${VAR_TO_MODIFY}}")
#message("Original (${VAR_TO_MODIFY}) is ${${VAR_TO_MODIFY}} replacement is ${replacement}")
set(${VAR_TO_MODIFY} "${replacement}" CACHE STRING "Default flags for ${build_config} configuration" FORCE)
endforeach()
endforeach()
PROJECT(KCBox)
# contains some library search cmake scripts
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
option(ENABLE_ASSERTIONS "Build with assertions enabled" ON)
message(STATUS "build type is ${CMAKE_BUILD_TYPE}")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(ENABLE_ASSERTIONS OFF)
endif()
# static compilation
option(BUILD_SHARED_LIBS "Build the shared library" ON)
option(STATICCOMPILE "Compile to static executable" OFF)
option(ENABLE_FLTO "Enable the flag -flto" OFF)
if (STATICCOMPILE)
set(BUILD_SHARED_LIBS OFF)
endif()
if (ENABLE_ASSERTIONS)
# NDEBUG was already removed.
else()
# Note this definition doesn't appear in the cache variables.
add_definitions(-DNDEBUG)
add_definitions(-D_FORTIFY_SOURCE=0)
endif()
# Note: O3 gives slight speed increase, 1 more solved from SAT Comp'14 @ 3600s
if (NOT MSVC)
add_compile_options( -g)
add_compile_options( -pthread )
#NOTE: out-satrace19-8373595 has confirmed that O3+flto only hurts compared to O2
# on gcc version 7.3.0
add_compile_options("$<$<CONFIG:RELWITHDEBINFO>:-O2>")
add_compile_options("$<$<CONFIG:RELEASE>:-O2>")
add_compile_options("$<$<CONFIG:RELEASE>:-g0>")
add_compile_options("$<$<CONFIG:DEBUG>:-O0>")
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -O2")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2")
endif()
else()
# see https://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx for details
# /ZI = include debug info
# /Wall = all warnings
add_compile_options("$<$<CONFIG:RELWITHDEBINFO>:/O2>")
add_compile_options("$<$<CONFIG:RELWITHDEBINFO>:/ZI>")
add_compile_options("$<$<CONFIG:RELEASE>:/O2>")
add_compile_options("$<$<CONFIG:RELEASE>:/D>")
add_compile_options("$<$<CONFIG:RELEASE>:/NDEBUG>")
add_compile_options("$<$<CONFIG:DEBUG>:/Od>")
if (NOT BUILD_SHARED_LIBS)
# We statically link to reduce dependencies
foreach(flag_var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
# /MD -- Causes the application to use the multithread-specific
# and DLL-specific version of the run-time library.
# Defines _MT and _DLL and causes the compiler to place
# the library name MSVCRT.lib into the .obj file.
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MD")
# /MDd -- Defines _DEBUG, _MT, and _DLL and causes the application to use the debug multithread-specific and DLL-specific version of the run-time library.
# It also causes the compiler to place the library name MSVCRTD.lib into the .obj file.
if(${flag_var} MATCHES "/MDd")
string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
endif(${flag_var} MATCHES "/MDd")
endforeach(flag_var)
# Creates a multithreaded executable (static) file using LIBCMT.lib.
add_compile_options(/MT)
endif()
# buffers security check
add_compile_options(/GS)
# Proper warning level
add_compile_options(/W1)
# Disable STL used in DLL-boundary warning
add_compile_options(/wd4251)
add_compile_options(/D_CRT_SECURE_NO_WARNINGS)
# Wall is MSVC's Weverything, so annoying unless used from the start
# and with judiciously used warning disables
# add_compile_options(/Wall)
# /Za = only ansi C98 & C++11
# /Za is not recommended for use, not tested, etc.
# see: http://stackoverflow.com/questions/5489326/za-compiler-directive-does-not-compile-system-headers-in-vs2010
# add_compile_options(/Za)
add_compile_options(/fp:precise)
# exception handling. s = The exception-handling model that catches C++ exceptions only and tells the compiler to assume that functions declared as extern "C" may throw an exception.
# exception handling. c = If used with s (/EHsc), catches C++ exceptions only and tells the compiler to assume that functions declared as extern "C" never throw a C++ exception.
add_compile_options(/EHsc)
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /INCREMENTAL:NO")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /PDBCOMPRESS")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1572864")
#what does this do?
set(DEF_INSTALL_CMAKE_DIR CMake)
endif()
include(CheckCXXCompilerFlag)
macro(add_cxx_flag_if_supported flagname)
check_cxx_compiler_flag("${flagname}" HAVE_FLAG_${flagname})
if(HAVE_FLAG_${flagname})
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flagname}" )
endif()
endmacro()
include(CheckCCompilerFlag)
macro(add_c_flag_if_supported flagname)
check_c_compiler_flag("${flagname}" HAVE_FLAG_${flagname})
if(HAVE_FLAG_${flagname})
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flagname}" )
endif()
endmacro()
# contains some library search cmake scripts
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# generate JSON file of compile commands -- useful for code extension
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
# static compilation
option(BUILD_SHARED_LIBS "Build the shared library" OFF)
option(STATICCOMPILE "Compile to static executable" ON)
if (STATICCOMPILE)
set(BUILD_SHARED_LIBS OFF)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(CMAKE_EXE_LINKER_FLAGS "-static")
endif()
SET(TOOLNAME "KCBox" CACHE STRING "please input PreLite, Panini, ExactMC, or PartialKC if you do not want KCBox")
if (NOT WIN32)
if(NOT ENABLE_TESTING AND ${CMAKE_SYSTEM_NAME} MATCHES "Linux" AND NOT COVERAGE)
#add_cxx_flag_if_supported("-fvisibility=hidden")
endif()
add_compile_options("-fPIC")
#add_cxx_flag_if_supported("-mtune=native")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
#NOTE: out-satrace19-8373595 has confirmed that O3+flto only hurts compared to O2
# on gcc version 7.3.0
if (ENABLE_FLTO)
add_cxx_flag_if_supported("-flto")
endif()
else()
add_cxx_flag_if_supported("-Wall")
add_cxx_flag_if_supported("-Wextra")
add_cxx_flag_if_supported("-Wunused")
add_cxx_flag_if_supported("-Wsign-compare")
if (NOT CMAKE_BUILD_TYPE STREQUAL "Release")
add_cxx_flag_if_supported("-fno-omit-frame-pointer")
endif()
add_cxx_flag_if_supported("-Wtype-limits")
add_cxx_flag_if_supported("-Wuninitialized")
add_cxx_flag_if_supported("-Wno-deprecated")
add_cxx_flag_if_supported("-Wstrict-aliasing")
add_cxx_flag_if_supported("-Wpointer-arith")
add_cxx_flag_if_supported("-Wheader-guard")
add_cxx_flag_if_supported("-Wpointer-arith")
add_cxx_flag_if_supported("-Wformat-nonliteral")
add_cxx_flag_if_supported("-Winit-self")
add_cxx_flag_if_supported("-Wparentheses")
add_cxx_flag_if_supported("-Wunreachable-code")
add_cxx_flag_if_supported("-ggdb3")
# Apparently needed before OS X Maverics (2013)
#add_c_flag_if_supported("-stdlib=libc++")
endif()
endif()
if (NOT WIN32)
add_cxx_flag_if_supported("-Wno-bitfield-constant-conversion")
#add_cxx_flag_if_supported("-Wduplicated-cond")
#add_cxx_flag_if_supported("-Wduplicated-branches")
add_cxx_flag_if_supported("-Wlogical-op")
add_cxx_flag_if_supported("-Wrestrict")
add_cxx_flag_if_supported("-Wnull-dereference")
add_cxx_flag_if_supported("-Wjump-misses-init")
add_cxx_flag_if_supported("-Wdouble-promotion")
add_cxx_flag_if_supported("-Wshadow")
add_cxx_flag_if_supported("-Wformat=2")
add_cxx_flag_if_supported("-Wextra-semi")
add_cxx_flag_if_supported("-pedantic")
add_cxx_flag_if_supported("-Wno-class-memaccess")
#add_cxx_flag_if_supported("-Wdeprecated")
endif()
if (NOT WIN32)
MESSAGE(STATUS "${CMAKE_C_FLAGS}")
add_c_flag_if_supported("-fPIC")
add_c_flag_if_supported("-std=c99")
add_c_flag_if_supported("-Wall")
add_c_flag_if_supported("-msse4.1")
add_c_flag_if_supported("-mpclmul")
endif()
find_library(GMP_LIB gmp)
find_library(GMPXX_LIB gmpxx)
find_package(ZLIB)
include_directories(${ZLIB_INCLUDE_DIR})
include_directories(${minisat_SOURCE_DIR})
include_directories(${PreLite_SOURCE_DIR})
#--------------------------------------------------------------------------------------------------
# Compile flags:
add_definitions(-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS)
option(NODEID_64BITS "Use 64 bits of NodeID" OFF)
if (NODEID_64BITS)
add_definitions(-DNODEID_64BITS)
endif()
option(CACHEENTRYID_64BITS "Use 64 bits of CacheEntryID" OFF)
if (CACHEENTRYID_64BITS)
add_definitions(-DCACHEENTRYID_64BITS)
endif()
option(ACTIVATE_CLHASH "Activate clhash" OFF)
if (ACTIVATE_CLHASH)
add_definitions(-DACTIVATE_CLHASH)
endif()
#--------------------------------------------------------------------------------------------------
# Build Targets:
set(MINISAT_LIB_SOURCES
minisat/utils/Options.cc
minisat/utils/System.cc
minisat/core/Solver.cc
minisat/simp/SimpSolver.cc)
add_library(minisat-lib-static STATIC ${MINISAT_LIB_SOURCES})
target_link_libraries(minisat-lib-static ${ZLIB_LIBRARY})
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/minisat/)
include_directories(
${PROJECT_SOURCE_DIR}/src
)
include_directories(${PROJECT_SOURCE_DIR}/cadical/src/)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(${TOOLNAME}
src/Compilers/BDDC_Compiler.cpp
src/Compilers/CDD_Compiler.cpp
src/Compilers/CCDD_Compiler.cpp
src/Compilers/RCDD_Compiler.cpp
src/Compilers/R2D2_Compiler.cpp
src/Compilers/DNNF_Compiler.cpp
src/Compilers/Partial_Compiler.cpp
src/Component_Types/Component.cpp
src/Component_Types/Cacheable_Clause.cpp
src/Counters/KCounter.cpp
src/Counters/WCounter.cpp
src/KC_Languages/DAG.cpp
src/KC_Languages/OBDD.cpp
src/KC_Languages/OBDD[AND].cpp
src/KC_Languages/smooth-OBDD[AND].cpp
src/KC_Languages/CCDD.cpp
src/KC_Languages/CDD.cpp
src/KC_Languages/DecDNNF.cpp
src/KC_Languages/RCDD.cpp
src/KC_Languages/RRCDD.cpp
src/Weighted_Languages/Partial_CCDD.cpp
src/Primitive_Types/Assignment.cpp
src/Primitive_Types/CNF_Formula.cpp
src/Primitive_Types/Lit_Equivalency.cpp
src/Template_Library/Basic_Functions.cpp
src/Template_Library/BigNum.cpp
src/Template_Library/Graph_Structures.cpp
src/Template_Library/Mersenne.cpp
src/clhash/clhash.c
src/CustomizedSolver.cpp
src/Extensive_Inprocessor.cpp
src/Inprocessor.cpp
src/Main.cpp
src/minisatInterface.cpp
src/Preprocessor.cpp
src/CadiBack.cpp
src/Solver.cpp
src/Solver_Krom.cpp
)
target_link_libraries(${TOOLNAME}
${GMPXX_LIB}
${GMP_LIB}
minisat-lib-static
${PROJECT_SOURCE_DIR}/cadical/build/libcadical.a
)