1 cmake_minimum_required (VERSION 3.0.1)
3 #-----------------------------------------------------------------------------#
7 # Major component of the version of CVC4.
9 # Minor component of the version of CVC4.
11 # Release component of the version of CVC4.
13 # Extraversion component of the version of CVC4.
14 set(CVC4_EXTRAVERSION "-prerelease")
16 # Full release string for CVC4.
18 set(CVC4_RELEASE_STRING "${CVC4_MAJOR}.${CVC4_MINOR}.${CVC4_RELEASE}${CVC4_EXTRAVERSION}")
20 set(CVC4_RELEASE_STRING "${CVC4_MAJOR}.${CVC4_MINOR}${CVC4_EXTRAVERSION}")
23 # Define to the full name of this package.
24 set(PACKAGE_NAME "${PROJECT_NAME}")
26 #### These defines are only use in autotools make files, will likely be
27 #### replaced with corresponding CPack stuff
28 ## Define to the full name and version of this package.
29 #set(PACKAGE_STRING "${PROJECT_NAME} ${CVC4_RELEASE_STRING}")
30 ## Define to the one symbol short name of this package.
31 #set(PACKAGE_TARNAME "${PROJECT_NAME}")
32 ## Define to the home page for this package.
34 ## Define to the version of this package.
35 #set(PACKAGE_VERSION "${CVC4_RELEASE_STRING}")
36 ## Define to the address where bug reports for this package should be sent.
37 #set(PACKAGE_BUGREPORT "cvc4-bugs@cs.stanford.edu")
39 #-----------------------------------------------------------------------------#
41 set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
42 set(CMAKE_C_STANDARD 99)
43 set(CMAKE_CXX_STANDARD 11)
45 #-----------------------------------------------------------------------------#
48 include(CheckCCompilerFlag)
49 include(CheckCXXCompilerFlag)
51 macro(add_c_flag flag)
52 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag}")
53 message(STATUS "Configuring with C flag '${flag}'")
56 macro(add_cxx_flag flag)
57 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}")
58 message(STATUS "Configuring with CXX flag '${flag}'")
61 macro(add_c_cxx_flag flag)
66 macro(add_check_c_flag flag)
67 string(REGEX REPLACE "[-=]" "_" flagname ${flag})
68 check_c_compiler_flag("${flag}" HAVE_FLAG${flagname})
69 if(HAVE_FLAG${flagname})
74 macro(add_check_cxx_flag flag)
75 string(REGEX REPLACE "[-=]" "_" flagname ${flag})
76 check_cxx_compiler_flag("${flag}" HAVE_FLAG${flagname})
77 if(HAVE_FLAG${flagname})
82 macro(add_check_c_cxx_flag flag)
83 add_check_c_flag(${flag})
84 add_check_cxx_flag(${flag})
87 macro(add_required_cxx_flag flag)
88 string(REGEX REPLACE "[-=]" "_" flagnamename ${flag})
89 check_cxx_compiler_flag("${flag}" HAVE_FLAG${flagname})
90 if (NOT HAVE_FLAG${flagname})
91 message(FATAL_ERROR "Required compiler flag ${flag} not supported")
96 macro(add_required_c_flag flag)
97 string(REGEX REPLACE "[-=]" "_" flagname ${flag})
98 check_c_compiler_flag("${flag}" HAVE_FLAG${flagname})
99 if (NOT HAVE_FLAG${flagname})
100 message(FATAL_ERROR "Required compiler flag ${flag} not supported")
105 macro(add_required_c_cxx_flag flag)
106 add_required_c_flag(${flag})
107 add_required_cxx_flag(${flag})
110 macro(cvc4_link_library library)
111 set(CVC4_LIBRARIES ${CVC4_LIBRARIES} ${library})
114 macro(cvc4_option var description)
115 set(${var} IGNORE CACHE STRING "${description}")
116 # Provide drop down menu options in cmake-gui
117 set_property(CACHE ${var} PROPERTY STRINGS IGNORE ON OFF)
120 macro(cvc4_set_option var value)
121 if(${var} STREQUAL "IGNORE")
126 #-----------------------------------------------------------------------------#
130 option(ENABLE_GPL "Enable GPL dependencies" OFF)
132 # General build options
133 # >> 3-valued: INGORE ON OFF, allows to detect if set by user
134 # this is only necessary for options set for build types!
135 cvc4_option(ENABLE_ASSERTIONS "Enable assertions")
136 cvc4_option(ENABLE_DEBUG_SYMBOLS "Enable debug symbols")
137 cvc4_option(ENABLE_DUMPING "Enable dumpin")
138 cvc4_option(ENABLE_MUZZLE "Enable silencing CVC4; supress ALL non-result output")
139 cvc4_option(ENABLE_OPTIMIZED "Enable optimization")
140 cvc4_option(ENABLE_PROOFS "Enable proof support")
141 cvc4_option(ENABLE_REPLAY "Enable the replay feature")
142 cvc4_option(ENABLE_STATISTICS "Enable statistics")
143 cvc4_option(ENABLE_TRACING "Enable tracing")
144 cvc4_option(ENABLE_UNIT_TESTING "Enable unit testing")
145 cvc4_option(ENABLE_VALGRIND "Enable valgrind instrumentation")
146 cvc4_option(ENABLE_SHARED "Build as shared library")
147 # >> 2-valued: ON OFF, for options where we don't need to detect if set by user
148 option(ENABLE_COVERAGE "Enable support for gcov coverage testing" OFF)
149 option(ENABLE_PROFILING "Enable support for gprof profiling" OFF)
151 # Optional dependencies
152 option(USE_CADICAL "Use CaDiCaL SAT solver")
153 option(USE_CLN "Use CLN instead of GMP")
154 option(USE_CRYPTOMINISAT "Use CryptoMiniSat SAT solver")
155 option(USE_LFSC "Use LFSC proof checker")
156 option(USE_READLINE "Use readline for better interactive support" OFF)
157 option(USE_SYMFPU "Use SymFPU for floating point support")
160 #-----------------------------------------------------------------------------#
161 # Internal cmake variables
166 set(BUILD_TYPES Production Debug Testing Competition)
168 #-----------------------------------------------------------------------------#
169 # CVC4 build variables
172 set(CVC4_BUILD_PROFILE_PRODUCTION 0)
173 set(CVC4_BUILD_PROFILE_DEBUG 0)
174 set(CVC4_BUILD_PROFILE_TESTING 0)
175 set(CVC4_BUILD_PROFILE_COMPETITION 0)
176 # Whether CVC4 is built with the (optional) GPLed library dependences.
179 #-----------------------------------------------------------------------------#
181 find_package(PythonInterp REQUIRED)
182 find_package(ANTLR REQUIRED)
184 find_package(GMP REQUIRED)
185 cvc4_link_library(${GMP_LIBRARIES})
186 include_directories(${GMP_INCLUDE_DIR})
188 #-----------------------------------------------------------------------------#
191 add_check_c_cxx_flag("-O${OPT_LEVEL}")
192 add_check_c_flag("-fexceptions")
193 add_check_c_cxx_flag("-Wno-deprecated")
194 add_check_c_cxx_flag("-Wsuggest-override")
195 add_check_cxx_flag("-Wnon-virtual-dtor")
197 #-----------------------------------------------------------------------------#
200 if(NOT CMAKE_BUILD_TYPE)
201 set(CMAKE_BUILD_TYPE Production CACHE STRING "Options are: ${BUILD_TYPES}" FORCE)
202 # Provide drop down menu options in cmake-gui
203 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${BUILD_TYPES})
205 message(STATUS "Building ${CMAKE_BUILD_TYPE} build")
207 if(CMAKE_BUILD_TYPE STREQUAL "Debug")
209 elseif(CMAKE_BUILD_TYPE STREQUAL "Production")
210 include(ConfigProduction)
211 elseif(CMAKE_BUILD_TYPE STREQUAL "Testing")
212 include(ConfigTesting)
213 elseif(CMAKE_BUILD_TYPE STREQUAL "Competition")
214 include(ConfigCompetition)
217 # enable_static_binary=yes
221 #-----------------------------------------------------------------------------#
223 if(ENABLE_ASSERTIONS)
224 add_definitions(-DCVC4_ASSERTIONS)
228 include(CodeCoverage)
229 APPEND_COVERAGE_COMPILER_FLAGS()
230 add_definitions(-DCVC4_COVERAGE)
231 # TODO set_up_target_for_coverage + regression tests
235 add_definitions(-DCVC4_DUMPING)
237 add_definitions(-DNDEBUG)
240 if(ENABLE_DEBUG_SYMBOLS)
241 add_check_c_cxx_flag("-ggdb3")
245 add_definitions(-DCVC4_MUZZLE)
249 add_definitions(-DCVC4_PROFILING)
250 add_check_c_cxx_flag("-pg")
254 #TODO RUN_REGRESSION_ARGS="${RUN_REGRESSION_ARGS:+$RUN_REGRESSION_ARGS }--enable-proof"
255 add_definitions(-DCVC4_PROOF)
260 add_definitions(-DCVC4_REPLAY)
264 add_definitions(-DCVC4_TRACING)
268 if(ENABLE_UNIT_TESTING)
269 find_package(CxxTest REQUIRED)
274 set(BUILD_SHARED_LIBS ON)
277 if(ENABLE_STATISTICS)
278 add_definitions(-DCVC4_STATISTICS_ON)
282 #TODO check if valgrind available
283 add_definitions(-DCVC4_VALGRIND)
287 find_package(CaDiCaL REQUIRED)
288 cvc4_link_library(${CaDiCaL_LIBRARIES})
289 include_directories(${CaDiCaL_INCLUDE_DIR})
290 add_definitions(-DCVC4_USE_CADICAL)
294 set(GPL_LIBS "${GPL_LIBS} cln")
297 "Bad configuration detected: BSD-licensed code only, but also requested "
298 "GPLed libraries: ${GPL_LIBS}")
300 find_package(CLN 1.2.2 REQUIRED)
301 cvc4_link_library(${CLN_LIBRARIES})
302 include_directories(${CLN_INCLUDE_DIR})
303 set(CVC4_USE_CLN_IMP 1)
304 set(CVC4_USE_GMP_IMP 0)
306 set(CVC4_USE_CLN_IMP 0)
307 set(CVC4_USE_GMP_IMP 1)
310 if(USE_CRYPTOMINISAT)
311 # CryptoMiniSat requires pthreads support
312 set(THREADS_PREFER_PTHREAD_FLAG ON)
313 find_package(Threads REQUIRED)
314 if(THREADS_HAVE_PTHREAD_ARG)
315 add_c_cxx_flag(-pthread)
317 find_package(CryptoMiniSat REQUIRED)
318 cvc4_link_library(${CryptoMiniSat_LIBRARIES})
319 include_directories(${CryptoMiniSat_INCLUDE_DIR})
320 add_definitions(-DCVC4_USE_CRYPTOMINISAT)
324 find_package(LFSC REQUIRED)
325 include_directories(${LFSC_INCLUDE_DIR})
326 add_definitions(-DCVC4_USE_LFSC)
333 find_package(Readline REQUIRED)
334 set(HAVE_LIBREADLINE 1)
335 if(Readline_COMPENTRY_FUNC_RETURNS_CHARPTR)
336 set(READLINE_COMPENTRY_FUNC_RETURNS_CHARP 1)
338 set(READLINE_COMPENTRY_FUNC_RETURNS_CHARP 0)
341 set(HAVE_LIBREADLINE 0)
345 find_package(SymFPU REQUIRED)
346 include_directories(${SymFPU_INCLUDE_DIR})
347 add_definitions(-DCVC4_USE_SYMFPU)
348 set(CVC4_USE_SYMFPU 1)
350 set(CVC4_USE_SYMFPU 0)
356 "Bad configuration detected: BSD-licensed code only, but also requested "
357 "GPLed libraries: ${GPL_LIBS}")
362 #-----------------------------------------------------------------------------#
364 set(VERSION "1.6.0-prerelease")
365 string(TIMESTAMP MAN_DATE "%Y-%m-%d")
367 #-----------------------------------------------------------------------------#
369 include(GetGitRevisionDescription)
370 get_git_head_revision(GIT_REFSPEC GIT_SHA1)
371 git_local_changes(GIT_IS_DIRTY)
372 if(${GIT_IS_DIRTY} STREQUAL "DIRTY")
373 set(GIT_IS_DIRTY "true")
375 set(GIT_IS_DIRTY "false")
379 COMMAND "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD
380 OUTPUT_VARIABLE GIT_BRANCH
381 OUTPUT_STRIP_TRAILING_WHITESPACE
384 #-----------------------------------------------------------------------------#
386 include(ConfigureCVC4)
388 # Define to 1 if Boost threading library has support for thread attributes
389 set(BOOST_HAS_THREAD_ATTR 0)
390 # Defined if using the CLN multi-precision arithmetic library.
391 set(CVC4_CLN_IMP ${CVC4_USE_CLN_IMP})
392 # Defined if using the GMP multi-precision arithmetic library.
393 set(CVC4_GMP_IMP ${CVC4_USE_GMP_IMP})
394 ## Defined if the requested minimum BOOST version is satisfied
396 ## Define to 1 if you have <boost/system/error_code.hpp>
397 #set(HAVE_BOOST_SYSTEM_ERROR_CODE_HPP 1)
398 ## Define to 1 if you have <boost/thread.hpp>
399 #set(HAVE_BOOST_THREAD_HPP 1)
400 # Defined to 1 if clock_gettime() is supported by the platform.
401 set(HAVE_CLOCK_GETTIME 1)
402 # define if the compiler supports basic C++11 syntax
404 # Define to 1 if you have the declaration of `optreset', and to 0 if you don't.
405 set(HAVE_DECL_OPTRESET 0)
406 ## Define to 1 if you have the declaration of `strerror_r', and to 0 if you
408 #set(HAVE_DECL_STRERROR_R 1)
409 ## Define to 1 if you have the <dlfcn.h> header file.
411 # Define to 1 if you have the <ext/stdio_filebuf.h> header file.
412 set(HAVE_EXT_STDIO_FILEBUF_H 1)
413 # Defined to 1 if ffs() is supported by the platform.
415 # Define to 1 if you have the <getopt.h> header file.
417 ## Define to 1 if you have the <inttypes.h> header file.
418 #set(HAVE_INTTYPES_H 1)
419 ## Define to 1 if you have the `gmp' library (-lgmp).
421 ## Define to 1 if you have the `profiler' library (-lprofiler).
422 #set(HAVE_LIBPROFILER 0)
423 # Define to 1 to use libreadline
424 #set(HAVE_LIBREADLINE 0)
425 ## Define to 1 if you have the `tcmalloc' library (-ltcmalloc).
426 #set(HAVE_LIBTCMALLOC 0)
427 ## Define to 1 if you have the <memory.h> header file.
428 #set(HAVE_MEMORY_H 1)
429 # Defined to 1 if sigaltstack() is supported by the platform.
430 set(HAVE_SIGALTSTACK 1)
431 ## Define to 1 if you have the <stdint.h> header file.
432 #set(HAVE_STDINT_H 1)
433 ## Define to 1 if you have the <stdlib.h> header file.
434 #set(HAVE_STDLIB_H 1)
435 # Define to 1 if you have the `strerror_r' function.
436 set(HAVE_STRERROR_R 1)
437 ## Define to 1 if you have the <strings.h> header file.
438 #set(HAVE_STRINGS_H 1)
439 ## Define to 1 if you have the <string.h> header file.
440 #set(HAVE_STRING_H 1)
441 # Defined to 1 if strtok_r() is supported by the platform.
443 ## Define to 1 if you have the <sys/stat.h> header file.
444 #set(HAVE_SYS_STAT_H 1)
445 ## Define to 1 if you have the <sys/types.h> header file.
446 #set(HAVE_SYS_TYPES_H 1)
447 # Define to 1 if you have the <unistd.h> header file.
449 ## Define to the sub-directory where libtool stores uninstalled libraries.
450 #set(LT_OBJDIR ".libs/")
451 ## Define to 1 if you have the ANSI C header files.
453 # Define to 1 if strerror_r returns char *.
454 set(STRERROR_R_CHAR_P 1)
456 configure_file(cvc4autoconfig.new.h.in cvc4autoconfig.h)
457 include_directories(${CMAKE_CURRENT_BINARY_DIR})
459 #-----------------------------------------------------------------------------#
461 add_subdirectory(doc)
462 add_subdirectory(src)
463 add_subdirectory(test/java)
464 add_subdirectory(test/regress)
465 add_subdirectory(test/system)
466 if(ENABLE_UNIT_TESTING)
467 add_subdirectory(test/unit)
471 add_subdirectory(proofs/signatures)
472 cvc4_link_library(signatures)
475 #-----------------------------------------------------------------------------#
477 if(CVC4_BUILD_PROFILE_PRODUCTION)
478 set(CVC4_BUILD_PROFILE_STRING "production")
479 elseif(CVC4_BUILD_PROFILE_DEBUG)
480 set(CVC4_BUILD_PROFILE_STRING "debug")
481 elseif(CVC4_BUILD_PROFILE_TESTING)
482 set(CVC4_BUILD_PROFILE_STRING "testing")
483 elseif(CVC4_BUILD_PROFILE_COMPETITION)
484 set(CVC4_BUILD_PROFILE_STRING "competition")
487 message("CVC4 ${CVC4_RELEASE_STRING}")
489 message("Build profile : ${CVC4_BUILD_PROFILE_STRING}")
490 message("Optimized : ${ENABLE_OPTIMIZED}")
491 message("Optimization level: ${OPTIMIZATION_LEVEL}")
492 message("Debug symbols : ${ENABLE_DEBUG_SYMBOLS}")
493 message("Proofs : ${ENABLE_PROOFS}")
494 message("Statistics : ${ENABLE_STATISTICS}")
495 message("Replay : ${ENABLE_REPLAY}")
496 message("Assertions : ${ENABLE_ASSERTIONS}")
497 message("Tracing : ${ENABLE_TRACING}")
498 message("Dumping : ${ENABLE_DUMPING}")
499 message("Muzzle : ${ENABLE_MUZZLE}")
501 message("Unit tests : ${ENABLE_UNIT_TESTING}")
502 message("Coverage (gcov) : ${ENABLE_COVERAGE}")
503 message("Profiling (gprof) : ${ENABLE_PROFILING}")
505 #message("Static libs : ${enable_static}")
506 if(BUILD_SHARED_LIBS)
507 message("Shared libs : ON")
509 message("Shared libs : OFF")
511 #message("Static binary: ${enable_static_binary}")
512 #message("Compat lib : ${CVC4_BUILD_LIBCOMPAT}")
513 #message("Bindings : ${bindings_to_be_built}")
515 #message("Multithreaded: ${support_multithreaded}")
516 #message("Portfolio : ${with_portfolio}")
518 #message("ABC : ${{with_abc}")
519 message("CaDiCaL : ${USE_CADICAL}")
520 message("Cryptominisat : ${USE_CRYPTOMINISAT}")
521 #message("GLPK : ${USE_GLPK}")
522 message("LFSC : ${USE_LFSC}")
523 #message("MP library : ${mplibrary}")
524 message("Readline : ${USE_READLINE}")
525 message("SymFPU : ${USE_SYMFPU}")
527 #message("CPPFLAGS : ${CPPFLAGS}")
528 message("CXXFLAGS : ${CMAKE_CXX_FLAGS}")
529 message("CFLAGS : ${CMAKE_C_FLAGS}")
530 #message("LIBS : ${LIBS}")
531 #message("LDFLAGS : ${LDFLAGS}")
533 #message("libcvc4 version : ${{CVC4_LIBRARY_VERSION}")
534 #message("libcvc4parser version : ${CVC4_PARSER_LIBRARY_VERSION}")
535 #message("libcvc4compat version : ${CVC4_COMPAT_LIBRARY_VERSION_or_nobuild}")
536 #message("libcvc4bindings version: ${CVC4_BINDINGS_LIBRARY_VERSION_or_nobuild}")
538 #message("Install into : ${prefix}")
543 "CVC4 license : GPLv3 (due to optional libraries; see below)"
546 "Please note that CVC4 will be built against the following GPLed libraries:"
550 "As these libraries are covered under the GPLv3, so is this build of CVC4."
552 "CVC4 is also available to you under the terms of the (modified) BSD license."
554 "If you prefer to license CVC4 under those terms, please configure CVC4 to"
556 "disable all optional GPLed library dependences (-DENABLE_BSD_ONLY=ON)."
560 "CVC4 license : modified BSD"
563 "Note that this configuration is NOT built against any GPL'ed libraries, so"
565 "it is covered by the (modified) BSD license. This is, however, not the best"
567 "performing configuration of CVC4. To build against GPL'ed libraries which"
569 "improve CVC4's performance, re-configure with '-DENABLE_GPL -DENABLE_BEST'."
574 message("Now just type make, followed by make check or make install.")