1 cmake_minimum_required(VERSION 3.1)
4 cmake_policy(SET CMP0075 NEW)
7 #-----------------------------------------------------------------------------#
8 # Project configuration
12 set(CVC4_MAJOR 1) # Major component of the version of CVC4.
13 set(CVC4_MINOR 7) # Minor component of the version of CVC4.
14 set(CVC4_RELEASE 0) # Release component of the version of CVC4.
16 # Extraversion component of the version of CVC4.
17 set(CVC4_EXTRAVERSION "-prerelease")
19 # Shared library versioning. Increment SOVERSION for every new CVC4 release.
22 # Full release string for CVC4.
24 set(CVC4_RELEASE_STRING
25 "${CVC4_MAJOR}.${CVC4_MINOR}.${CVC4_RELEASE}${CVC4_EXTRAVERSION}")
27 set(CVC4_RELEASE_STRING "${CVC4_MAJOR}.${CVC4_MINOR}${CVC4_EXTRAVERSION}")
30 set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
31 set(CMAKE_C_STANDARD 99)
32 set(CMAKE_CXX_STANDARD 11)
34 #-----------------------------------------------------------------------------#
38 #-----------------------------------------------------------------------------#
42 option(ENABLE_GPL "Enable GPL dependencies")
44 # General build options
46 # >> 3-valued: INGORE ON OFF
47 # > allows to detect if set by user (default: IGNORE)
48 # > only necessary for options set for build types
49 cvc4_option(ENABLE_ASAN "Enable ASAN build")
50 cvc4_option(ENABLE_ASSERTIONS "Enable assertions")
51 cvc4_option(ENABLE_DEBUG_SYMBOLS "Enable debug symbols")
52 cvc4_option(ENABLE_DUMPING "Enable dumping")
53 cvc4_option(ENABLE_MUZZLE "Suppress ALL non-result output")
54 cvc4_option(ENABLE_OPTIMIZED "Enable optimization")
55 cvc4_option(ENABLE_PORTFOLIO "Enable portfolio support")
56 cvc4_option(ENABLE_PROOFS "Enable proof support")
57 cvc4_option(ENABLE_REPLAY "Enable the replay feature")
58 cvc4_option(ENABLE_STATISTICS "Enable statistics")
59 cvc4_option(ENABLE_TRACING "Enable tracing")
60 cvc4_option(ENABLE_UNIT_TESTING "Enable unit testing")
61 cvc4_option(ENABLE_VALGRIND "Enable valgrind instrumentation")
62 cvc4_option(ENABLE_SHARED "Build as shared library")
64 # > for options where we don't need to detect if set by user (default: OFF)
65 option(ENABLE_BEST "Enable dependencies known to give best performance")
66 option(ENABLE_COVERAGE "Enable support for gcov coverage testing")
67 option(ENABLE_DEBUG_CONTEXT_MM "Enable the debug context memory manager")
68 option(ENABLE_PROFILING "Enable support for gprof profiling")
70 # Optional dependencies
72 # >> 3-valued: INGORE ON OFF
73 # > allows to detect if set by user (default: IGNORE)
74 # > only necessary for options set for ENABLE_BEST
75 cvc4_option(USE_ABC "Use ABC for AIG bit-blasting")
76 cvc4_option(USE_CLN "Use CLN instead of GMP")
77 cvc4_option(USE_GLPK "Use GLPK simplex solver")
78 cvc4_option(USE_READLINE "Use readline for better interactive support")
80 # > for options where we don't need to detect if set by user (default: OFF)
81 option(USE_CADICAL "Use CaDiCaL SAT solver")
82 option(USE_CRYPTOMINISAT "Use CryptoMiniSat SAT solver")
83 option(USE_LFSC "Use LFSC proof checker")
84 option(USE_SYMFPU "Use SymFPU for floating point support")
85 option(USE_PYTHON2 "Prefer using Python 2 (for Python bindings)")
87 # Custom install directories for dependencies
88 # If no directory is provided by the user, we first check if the dependency was
89 # installed via the corresponding contrib/get-* script and if not found, we
90 # check the intalled system version. If the user provides a directory we
91 # immediately fail if the dependency was not found at the specified location.
92 set(ABC_DIR "" CACHE STRING "Set ABC install directory")
93 set(ANTLR_DIR "" CACHE STRING "Set ANTLR3 install directory")
94 set(CADICAL_DIR "" CACHE STRING "Set CaDiCaL install directory")
95 set(CRYPTOMINISAT_DIR "" CACHE STRING "Set CryptoMiniSat install directory")
96 set(GLPK_DIR "" CACHE STRING "Set GLPK install directory")
97 set(GMP_DIR "" CACHE STRING "Set GMP install directory")
98 set(LFSC_DIR "" CACHE STRING "Set LFSC install directory")
99 set(SYMFPU_DIR "" CACHE STRING "Set SymFPU install directory")
101 # Supported language bindings
102 option(BUILD_BINDINGS_JAVA "Build Java bindings")
103 option(BUILD_BINDINGS_PYTHON "Build Python bindings")
105 #-----------------------------------------------------------------------------#
106 # Internal cmake variables
108 set(OPTIMIZATION_LEVEL 3)
111 #-----------------------------------------------------------------------------#
114 # Note: Module CodeCoverage requires the name of the debug build to conform
115 # to cmake standards (first letter uppercase).
116 set(BUILD_TYPES Production Debug Testing Competition)
119 set(CMAKE_BUILD_TYPE Debug)
122 # Set the default build type to Production
123 if(NOT CMAKE_BUILD_TYPE)
125 Production CACHE STRING "Options are: ${BUILD_TYPES}" FORCE)
126 # Provide drop down menu options in cmake-gui
127 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${BUILD_TYPES})
130 # Check if specified build type is valid.
131 list(FIND BUILD_TYPES ${CMAKE_BUILD_TYPE} FOUND_BUILD_TYPE)
132 if(${FOUND_BUILD_TYPE} EQUAL -1)
134 "'${CMAKE_BUILD_TYPE}' is not a valid build type. "
135 "Available builds are: ${BUILD_TYPES}")
138 message(STATUS "Building ${CMAKE_BUILD_TYPE} build")
139 include(Config${CMAKE_BUILD_TYPE})
141 #-----------------------------------------------------------------------------#
144 add_check_c_cxx_flag("-O${OPTIMIZATION_LEVEL}")
145 add_check_c_flag("-fexceptions")
146 add_check_c_cxx_flag("-Wno-deprecated")
147 add_check_cxx_flag("-Wsuggest-override")
148 add_check_cxx_flag("-Wnon-virtual-dtor")
150 #-----------------------------------------------------------------------------#
151 # Option defaults (three-valued options (cvc4_option(...)))
153 # These options are only set if their value is IGNORE. Otherwise, the user
154 # already set the option, which we don't want to overwrite.
156 cvc4_set_option(ENABLE_SHARED ON)
158 #-----------------------------------------------------------------------------#
159 # Set options for best configuration
162 cvc4_set_option(USE_ABC ON)
163 cvc4_set_option(USE_CLN ON)
164 cvc4_set_option(USE_GLPK ON)
165 cvc4_set_option(USE_READLINE ON)
168 #-----------------------------------------------------------------------------#
171 # This needs to be set before any find_package(...) command since we want to
172 # search for static libraries with suffix .a.
173 if(NOT ENABLE_SHARED)
174 set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
175 set(CMAKE_EXE_LINKER_FLAGS "-static")
176 set(BUILD_SHARED_LIBS OFF)
179 #-----------------------------------------------------------------------------#
180 # Enable the ctest testing framework
182 # This needs to be enabled here rather than in subdirectory test in order to
183 # allow calling ctest from the root build directory.
186 #-----------------------------------------------------------------------------#
187 # Check options, find packages and configure build.
190 find_package(PythonInterp 2.7 REQUIRED)
192 find_package(PythonInterp 3)
193 find_package(PythonInterp REQUIRED)
196 set(GMP_HOME ${GMP_DIR})
197 find_package(GMP REQUIRED)
198 libcvc4_link_libraries(${GMP_LIBRARIES})
199 libcvc4_include_directories(${GMP_INCLUDE_DIR})
202 set(CMAKE_REQUIRED_LIBRARIES -fsanitize=address)
203 add_required_c_cxx_flag("-fsanitize=address")
204 unset(CMAKE_REQUIRED_LIBRARIES)
205 add_required_c_cxx_flag("-fno-omit-frame-pointer")
206 add_check_c_cxx_flag("-fsanitize-recover=address")
209 if(ENABLE_ASSERTIONS)
210 add_definitions(-DCVC4_ASSERTIONS)
212 add_definitions(-DNDEBUG)
213 # Only enable unit testing if assertions are enabled. Otherwise, unit tests
214 # that expect AssertionException to be thrown will fail.
215 set(ENABLE_UNIT_TESTING OFF)
219 include(CodeCoverage)
220 APPEND_COVERAGE_COMPILER_FLAGS()
221 add_definitions(-DCVC4_COVERAGE)
222 setup_target_for_coverage_lcov(
224 EXECUTABLE ctest $(ARGS)
225 DEPENDENCIES cvc4-bin)
228 if(ENABLE_DEBUG_CONTEXT_MM)
229 add_definitions(-DCVC4_DEBUG_CONTEXT_MEMORY_MANAGER)
232 if(ENABLE_DEBUG_SYMBOLS)
233 add_check_c_cxx_flag("-ggdb3")
237 add_definitions(-DCVC4_MUZZLE)
240 # This check needs to come before the USE_CLN check.
242 find_package(Boost 1.50.0 REQUIRED COMPONENTS thread)
244 message(FATAL_ERROR "Dumping not supported with a portfolio build.")
246 # Disable CLN for portfolio builds since it is not thread safe (uses an
247 # unlocked hash table internally).
249 message(WARNING "Disabling CLN support since portfolio is enabled.")
252 set(THREADS_PREFER_PTHREAD_FLAG ON)
253 find_package(Threads REQUIRED)
254 if(THREADS_HAVE_PTHREAD_ARG)
255 add_c_cxx_flag(-pthread)
257 add_definitions(-DCVC4_PORTFOLIO)
258 set(BOOST_HAS_THREAD_ATTR 1)
261 # This has to be processed after ENABLE_PORTFOLIO (disables dumping support).
263 add_definitions(-DCVC4_DUMPING)
267 add_definitions(-DCVC4_PROFILING)
268 add_check_c_cxx_flag("-pg")
272 set(RUN_REGRESSION_ARGS ${RUN_REGRESSION_ARGS} --enable-proof)
273 add_definitions(-DCVC4_PROOF)
277 add_definitions(-DCVC4_REPLAY)
281 add_definitions(-DCVC4_TRACING)
284 if(ENABLE_UNIT_TESTING)
285 find_package(CxxTest REQUIRED)
286 # Force shared libs for unit tests, static libs with unit tests are not
288 set(ENABLE_SHARED ON)
292 set(BUILD_SHARED_LIBS ON)
295 if(ENABLE_STATISTICS)
296 add_definitions(-DCVC4_STATISTICS_ON)
300 find_package(Valgrind REQUIRED)
301 libcvc4_include_directories(${Valgrind_INCLUDE_DIR})
302 add_definitions(-DCVC4_VALGRIND)
306 set(ABC_HOME "${ABC_DIR}")
307 find_package(ABC REQUIRED)
308 libcvc4_link_libraries(${ABC_LIBRARIES})
309 libcvc4_include_directories(${ABC_INCLUDE_DIR})
310 add_definitions(-DCVC4_USE_ABC ${ABC_ARCH_FLAGS})
314 set(CaDiCaL_HOME ${CADICAL_DIR})
315 find_package(CaDiCaL REQUIRED)
316 libcvc4_link_libraries(${CaDiCaL_LIBRARIES})
317 libcvc4_include_directories(${CaDiCaL_INCLUDE_DIR})
318 add_definitions(-DCVC4_USE_CADICAL)
322 set(GPL_LIBS "${GPL_LIBS} cln")
323 find_package(CLN 1.2.2 REQUIRED)
324 libcvc4_link_libraries(${CLN_LIBRARIES})
325 libcvc4_include_directories(${CLN_INCLUDE_DIR})
326 set(CVC4_USE_CLN_IMP 1)
327 set(CVC4_USE_GMP_IMP 0)
329 set(CVC4_USE_CLN_IMP 0)
330 set(CVC4_USE_GMP_IMP 1)
333 if(USE_CRYPTOMINISAT)
334 # CryptoMiniSat requires pthreads support
335 set(THREADS_PREFER_PTHREAD_FLAG ON)
336 find_package(Threads REQUIRED)
337 if(THREADS_HAVE_PTHREAD_ARG)
338 add_c_cxx_flag(-pthread)
340 set(CryptoMiniSat_HOME ${CRYPTOMINISAT_DIR})
341 find_package(CryptoMiniSat REQUIRED)
342 libcvc4_link_libraries(${CryptoMiniSat_LIBRARIES})
343 libcvc4_include_directories(${CryptoMiniSat_INCLUDE_DIR})
344 add_definitions(-DCVC4_USE_CRYPTOMINISAT)
348 set(GPL_LIBS "${GPL_LIBS} glpk")
349 set(GLPK_HOME ${GLPK_DIR})
350 find_package(GLPK REQUIRED)
351 libcvc4_link_libraries(${GLPK_LIBRARIES})
352 libcvc4_include_directories(${GLPK_INCLUDE_DIR})
353 add_definitions(-DCVC4_USE_GLPK)
357 set(RUN_REGRESSION_ARGS ${RUN_REGRESSION_ARGS} --with-lfsc)
358 set(LFSC_HOME ${LFSC_DIR})
359 find_package(LFSC REQUIRED)
360 libcvc4_link_libraries(${LFSC_LIBRARIES})
361 libcvc4_include_directories(${LFSC_INCLUDE_DIR})
362 add_definitions(-DCVC4_USE_LFSC)
366 find_package(Readline REQUIRED)
367 set(HAVE_LIBREADLINE 1)
368 if(Readline_COMPENTRY_FUNC_RETURNS_CHARPTR)
369 set(READLINE_COMPENTRY_FUNC_RETURNS_CHARP 1)
374 set(SymFPU_HOME ${SYMFPU_DIR})
375 find_package(SymFPU REQUIRED)
376 libcvc4_include_directories(${SymFPU_INCLUDE_DIR})
377 add_definitions(-DCVC4_USE_SYMFPU)
378 set(CVC4_USE_SYMFPU 1)
380 set(CVC4_USE_SYMFPU 0)
386 "Bad configuration detected: BSD-licensed code only, but also requested "
387 "GPLed libraries: ${GPL_LIBS}")
392 #-----------------------------------------------------------------------------#
393 # Generate CVC4's cvc4autoconfig.h header
395 include(ConfigureCVC4)
396 configure_file(cvc4autoconfig.new.h.in cvc4autoconfig.h)
397 include_directories(${CMAKE_CURRENT_BINARY_DIR})
399 #-----------------------------------------------------------------------------#
402 # signatures needs to come before src since it adds source files to libcvc4.
404 add_subdirectory(proofs/signatures)
407 add_subdirectory(doc)
408 add_subdirectory(examples EXCLUDE_FROM_ALL) # excluded from all target
409 add_subdirectory(src)
410 add_subdirectory(test)
412 if(BUILD_BINDINGS_JAVA OR BUILD_BINDINGS_PYTHON)
413 add_subdirectory(src/bindings)
416 #-----------------------------------------------------------------------------#
417 # Print build configuration
419 # Convert build type to lower case.
420 string(TOLOWER ${CMAKE_BUILD_TYPE} CVC4_BUILD_PROFILE_STRING)
422 # Get all definitions added via add_definitions.
423 get_directory_property(CVC4_DEFINITIONS COMPILE_DEFINITIONS)
424 string(REPLACE ";" " " CVC4_DEFINITIONS "${CVC4_DEFINITIONS}")
426 message("CVC4 ${CVC4_RELEASE_STRING}")
428 message("Build profile : ${CVC4_BUILD_PROFILE_STRING}")
430 print_config("GPL :" ENABLE_GPL)
431 print_config("Best configuration :" ENABLE_BEST)
432 print_config("Optimized :" ENABLE_OPTIMIZED)
433 print_config("Optimization level :" OPTIMIZATION_LEVEL)
435 print_config("Assertions :" ENABLE_ASSERTIONS)
436 print_config("Debug symbols :" ENABLE_DEBUG_SYMBOLS)
437 print_config("Debug context mem mgr:" ENABLE_DEBUG_CONTEXT_MM)
439 print_config("Dumping :" ENABLE_DUMPING)
440 print_config("Muzzle :" ENABLE_MUZZLE)
441 print_config("Proofs :" ENABLE_PROOFS)
442 print_config("Replay :" ENABLE_REPLAY)
443 print_config("Statistics :" ENABLE_STATISTICS)
444 print_config("Tracing :" ENABLE_TRACING)
446 print_config("Asan :" ENABLE_ASAN)
447 print_config("Coverage (gcov) :" ENABLE_COVERAGE)
448 print_config("Profiling (gprof) :" ENABLE_PROFILING)
449 print_config("Unit tests :" ENABLE_UNIT_TESTING)
450 print_config("Valgrind :" ENABLE_VALGRIND)
452 print_config("Shared libs :" ENABLE_SHARED)
453 print_config("Java bindings :" BUILD_BINDINGS_JAVA)
454 print_config("Python bindings :" BUILD_BINDINGS_PYTHON)
455 print_config("Python2 :" USE_PYTHON2)
457 print_config("Portfolio :" ENABLE_PORTFOLIO)
459 print_config("ABC :" USE_ABC)
460 print_config("CaDiCaL :" USE_CADICAL)
461 print_config("CryptoMiniSat :" USE_CRYPTOMINISAT)
462 print_config("GLPK :" USE_GLPK)
463 print_config("LFSC :" USE_LFSC)
466 message("MP library : cln")
468 message("MP library : gmp")
470 print_config("Readline :" ${USE_READLINE})
471 print_config("SymFPU :" ${USE_SYMFPU})
474 message("ABC dir : ${ABC_DIR}")
477 message("ANTLR dir : ${ANTLR_DIR}")
480 message("CADICAL dir : ${CADICAL_DIR}")
482 if(CRYPTOMINISAT_DIR)
483 message("CRYPTOMINISAT dir : ${CRYPTOMINISAT_DIR}")
486 message("GLPK dir : ${GLPK_DIR}")
489 message("GMP dir : ${GMP_DIR}")
492 message("LFSC dir : ${LFSC_DIR}")
495 message("SYMFPU dir : ${SYMFPU_DIR}")
498 message("CPPLAGS (-D...) : ${CVC4_DEFINITIONS}")
499 message("CXXFLAGS : ${CMAKE_CXX_FLAGS}")
500 message("CFLAGS : ${CMAKE_C_FLAGS}")
502 message("Install prefix : ${CMAKE_INSTALL_PREFIX}")
507 "CVC4 license : GPLv3 (due to optional libraries; see below)"
510 "Please note that CVC4 will be built against the following GPLed libraries:"
514 "As these libraries are covered under the GPLv3, so is this build of CVC4."
516 "CVC4 is also available to you under the terms of the (modified) BSD license."
518 "If you prefer to license CVC4 under those terms, please configure CVC4 to"
520 "disable all optional GPLed library dependences (-DENABLE_BSD_ONLY=ON)."
524 "CVC4 license : modified BSD"
527 "Note that this configuration is NOT built against any GPL'ed libraries, so"
529 "it is covered by the (modified) BSD license. This is, however, not the best"
531 "performing configuration of CVC4. To build against GPL'ed libraries which"
533 "improve CVC4's performance, re-configure with '-DENABLE_GPL -DENABLE_BEST'."
538 message("Now just type make, followed by make check or make install.")