Remove example theory (#4922)
[cvc5.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.4)
2
3 #-----------------------------------------------------------------------------#
4 # Project configuration
5
6 project(cvc4)
7
8 set(CVC4_MAJOR 1) # Major component of the version of CVC4.
9 set(CVC4_MINOR 9) # Minor component of the version of CVC4.
10 set(CVC4_RELEASE 0) # Release component of the version of CVC4.
11
12 # Extraversion component of the version of CVC4.
13 set(CVC4_EXTRAVERSION "-prerelease")
14
15 # Shared library versioning. Increment SOVERSION for every new CVC4 release.
16 set(CVC4_SOVERSION 7)
17
18 # Full release string for CVC4.
19 if(CVC4_RELEASE)
20 set(CVC4_RELEASE_STRING
21 "${CVC4_MAJOR}.${CVC4_MINOR}.${CVC4_RELEASE}${CVC4_EXTRAVERSION}")
22 else()
23 set(CVC4_RELEASE_STRING "${CVC4_MAJOR}.${CVC4_MINOR}${CVC4_EXTRAVERSION}")
24 endif()
25
26 set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
27 set(CMAKE_C_STANDARD 99)
28 set(CMAKE_CXX_STANDARD 11)
29 set(CMAKE_CXX_EXTENSIONS OFF)
30
31 # Generate compile_commands.json, which can be used for various code completion
32 # plugins.
33 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
34
35 #-----------------------------------------------------------------------------#
36 # Policies
37
38 # Required for FindGLPK since it sets CMAKE_REQUIRED_LIBRARIES
39 if(POLICY CMP0075)
40 cmake_policy(SET CMP0075 NEW)
41 endif()
42
43 #-----------------------------------------------------------------------------#
44 # Tell CMake where to find our dependencies
45
46 if(ABC_DIR)
47 list(APPEND CMAKE_PREFIX_PATH "${ABC_DIR}")
48 endif()
49 if(ANTLR_DIR)
50 list(APPEND CMAKE_PREFIX_PATH "${ANTLR_DIR}")
51 endif()
52 if(CADICAL_DIR)
53 list(APPEND CMAKE_PREFIX_PATH "${CADICAL_DIR}")
54 endif()
55 if(CRYPTOMINISAT_DIR)
56 list(APPEND CMAKE_PREFIX_PATH "${CRYPTOMINISAT_DIR}")
57 endif()
58 if(CXXTEST_DIR)
59 list(APPEND CMAKE_PREFIX_PATH "${CXXTEST_DIR}")
60 endif()
61 if(DRAT2ER_DIR)
62 list(APPEND CMAKE_PREFIX_PATH "${DRAT2ER_DIR}")
63 endif()
64 if(GLPK_DIR)
65 list(APPEND CMAKE_PREFIX_PATH "${GLPK_DIR}")
66 endif()
67 if(GMP_DIR)
68 list(APPEND CMAKE_PREFIX_PATH "${GMP_DIR}")
69 endif()
70 if(KISSAT_DIR)
71 list(APPEND CMAKE_PREFIX_PATH "${KISSAT_DIR}")
72 endif()
73 if(LFSC_DIR)
74 list(APPEND CMAKE_PREFIX_PATH "${LFSC_DIR}")
75 endif()
76 if(POLY_DIR)
77 list(APPEND CMAKE_PREFIX_PATH "${POLY_DIR}")
78 endif()
79 if(SYMFPU_DIR)
80 list(APPEND CMAKE_PREFIX_PATH "${SYMFPU_DIR}")
81 endif()
82
83 # By default the contrib/get-* scripts install dependencies to deps/install.
84 list(APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/deps/install")
85
86 #-----------------------------------------------------------------------------#
87
88 set(INCLUDE_INSTALL_DIR include)
89 set(LIBRARY_INSTALL_DIR lib)
90 set(RUNTIME_INSTALL_DIR bin)
91
92 #-----------------------------------------------------------------------------#
93
94 include(Helpers)
95
96 #-----------------------------------------------------------------------------#
97 # User options
98
99 # License
100 option(ENABLE_GPL "Enable GPL dependencies")
101
102 # General build options
103 #
104 # >> 3-valued: IGNORE ON OFF
105 # > allows to detect if set by user (default: IGNORE)
106 # > only necessary for options set for build types
107 cvc4_option(ENABLE_ASAN "Enable ASAN build")
108 cvc4_option(ENABLE_UBSAN "Enable UBSan build")
109 cvc4_option(ENABLE_TSAN "Enable TSan build")
110 cvc4_option(ENABLE_ASSERTIONS "Enable assertions")
111 cvc4_option(ENABLE_COMP_INC_TRACK
112 "Enable optimizations for incremental SMT-COMP tracks")
113 cvc4_option(ENABLE_DEBUG_SYMBOLS "Enable debug symbols")
114 cvc4_option(ENABLE_DUMPING "Enable dumping")
115 cvc4_option(ENABLE_MUZZLE "Suppress ALL non-result output")
116 cvc4_option(ENABLE_PROOFS "Enable proof support")
117 cvc4_option(ENABLE_STATISTICS "Enable statistics")
118 cvc4_option(ENABLE_TRACING "Enable tracing")
119 cvc4_option(ENABLE_UNIT_TESTING "Enable unit testing")
120 cvc4_option(ENABLE_VALGRIND "Enable valgrind instrumentation")
121 cvc4_option(ENABLE_SHARED "Build as shared library")
122 cvc4_option(ENABLE_STATIC_BINARY
123 "Build static binaries with statically linked system libraries")
124 # >> 2-valued: ON OFF
125 # > for options where we don't need to detect if set by user (default: OFF)
126 option(ENABLE_BEST "Enable dependencies known to give best performance")
127 option(ENABLE_COVERAGE "Enable support for gcov coverage testing")
128 option(ENABLE_DEBUG_CONTEXT_MM "Enable the debug context memory manager")
129 option(ENABLE_PROFILING "Enable support for gprof profiling")
130
131 # Optional dependencies
132 #
133 # >> 3-valued: IGNORE ON OFF
134 # > allows to detect if set by user (default: IGNORE)
135 # > only necessary for options set for ENABLE_BEST
136 cvc4_option(USE_ABC "Use ABC for AIG bit-blasting")
137 cvc4_option(USE_CADICAL "Use CaDiCaL SAT solver")
138 cvc4_option(USE_CLN "Use CLN instead of GMP")
139 cvc4_option(USE_CRYPTOMINISAT "Use CryptoMiniSat SAT solver")
140 cvc4_option(USE_GLPK "Use GLPK simplex solver")
141 cvc4_option(USE_KISSAT "Use Kissat SAT solver")
142 cvc4_option(USE_EDITLINE "Use Editline for better interactive support")
143 # >> 2-valued: ON OFF
144 # > for options where we don't need to detect if set by user (default: OFF)
145 option(USE_DRAT2ER "Include drat2er for making eager BV proofs")
146 option(USE_LFSC "Use LFSC proof checker")
147 option(USE_POLY "Use LibPoly for polynomial arithmetic")
148 option(USE_SYMFPU "Use SymFPU for floating point support")
149 option(USE_PYTHON2 "Prefer using Python 2 (for Python bindings)")
150 option(USE_PYTHON3 "Prefer using Python 3 (for Python bindings)")
151
152 # Custom install directories for dependencies
153 # If no directory is provided by the user, we first check if the dependency was
154 # installed via the corresponding contrib/get-* script and if not found, we
155 # check the intalled system version. If the user provides a directory we
156 # immediately fail if the dependency was not found at the specified location.
157 set(ABC_DIR "" CACHE STRING "Set ABC install directory")
158 set(ANTLR_DIR "" CACHE STRING "Set ANTLR3 install directory")
159 set(CADICAL_DIR "" CACHE STRING "Set CaDiCaL install directory")
160 set(CRYPTOMINISAT_DIR "" CACHE STRING "Set CryptoMiniSat install directory")
161 set(CXXTEST_DIR "" CACHE STRING "Set CxxTest install directory")
162 set(DRAT2ER_DIR "" CACHE STRING "Set drat2er install directory")
163 set(GLPK_DIR "" CACHE STRING "Set GLPK install directory")
164 set(GMP_DIR "" CACHE STRING "Set GMP install directory")
165 set(KISSAT_DIR "" CACHE STRING "Set Kissat install directory")
166 set(LFSC_DIR "" CACHE STRING "Set LFSC install directory")
167 set(POLY_DIR "" CACHE STRING "Set LibPoly install directory")
168 set(SYMFPU_DIR "" CACHE STRING "Set SymFPU install directory")
169
170 # Prepend binaries with prefix on make install
171 set(PROGRAM_PREFIX "" CACHE STRING "Program prefix on make install")
172
173 # Supprted language bindings based on new C++ API
174 option(BUILD_BINDINGS_PYTHON "Build Python bindings based on new C++ API ")
175 option(BUILD_BINDINGS_JAVA "Build Java bindings based on new C++ API ")
176
177 # Build limitations
178 option(BUILD_LIB_ONLY "Only build the library")
179
180 #-----------------------------------------------------------------------------#
181 # Internal cmake variables
182
183 set(OPTIMIZATION_LEVEL 3)
184 set(GPL_LIBS "")
185
186 #-----------------------------------------------------------------------------#
187 # Determine number of threads available, used to configure (default) parallel
188 # execution of custom test targets (can be overriden with ARGS=-jN).
189
190 include(ProcessorCount)
191 ProcessorCount(CTEST_NTHREADS)
192 if(CTEST_NTHREADS EQUAL 0)
193 set(CTEST_NTHREADS 1)
194 endif()
195
196 #-----------------------------------------------------------------------------#
197 # Build types
198
199 # Note: Module CodeCoverage requires the name of the debug build to conform
200 # to cmake standards (first letter uppercase).
201 set(BUILD_TYPES Production Debug Testing Competition)
202
203 if(ENABLE_ASAN OR ENABLE_UBSAN OR ENABLE_TSAN)
204 set(CMAKE_BUILD_TYPE Debug)
205 endif()
206
207 # Set the default build type to Production
208 if(NOT CMAKE_BUILD_TYPE)
209 set(CMAKE_BUILD_TYPE
210 Production CACHE STRING "Options are: ${BUILD_TYPES}" FORCE)
211 # Provide drop down menu options in cmake-gui
212 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${BUILD_TYPES})
213 endif()
214
215 # Check if specified build type is valid.
216 list(FIND BUILD_TYPES ${CMAKE_BUILD_TYPE} FOUND_BUILD_TYPE)
217 if(${FOUND_BUILD_TYPE} EQUAL -1)
218 message(FATAL_ERROR
219 "'${CMAKE_BUILD_TYPE}' is not a valid build type. "
220 "Available builds are: ${BUILD_TYPES}")
221 endif()
222
223 message(STATUS "Building ${CMAKE_BUILD_TYPE} build")
224 include(Config${CMAKE_BUILD_TYPE})
225
226 #-----------------------------------------------------------------------------#
227 # Compiler flags
228
229 add_check_c_cxx_flag("-O${OPTIMIZATION_LEVEL}")
230 add_check_c_cxx_flag("-Wall")
231 add_check_c_flag("-fexceptions")
232 add_check_c_cxx_flag("-Wno-deprecated")
233 add_check_cxx_flag("-Wsuggest-override")
234 add_check_cxx_flag("-Wnon-virtual-dtor")
235 add_check_c_cxx_flag("-Wimplicit-fallthrough")
236 add_check_c_cxx_flag("-Wshadow")
237
238 # Temporarily disable -Wclass-memaccess to suppress 'no trivial copy-assignment'
239 # cdlist.h warnings. Remove when fixed.
240 add_check_cxx_flag("-Wno-class-memaccess")
241
242 if (WIN32)
243 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,100000000")
244 endif ()
245
246 #-----------------------------------------------------------------------------#
247 # Use ld.gold if available
248
249 execute_process(COMMAND ${CMAKE_C_COMPILER}
250 -fuse-ld=gold
251 -Wl,--version ERROR_QUIET OUTPUT_VARIABLE LD_VERSION)
252 if ("${LD_VERSION}" MATCHES "GNU gold")
253 string(APPEND CMAKE_EXE_LINKER_FLAGS " -fuse-ld=gold")
254 string(APPEND CMAKE_SHARED_LINKER_FLAGS " -fuse-ld=gold")
255 string(APPEND CMAKE_MODULE_LINKER_FLAGS " -fuse-ld=gold")
256 message(STATUS "Using GNU gold linker.")
257 endif ()
258
259 #-----------------------------------------------------------------------------#
260 # Option defaults (three-valued options (cvc4_option(...)))
261 #
262 # These options are only set if their value is IGNORE. Otherwise, the user
263 # already set the option, which we don't want to overwrite.
264
265 if(ENABLE_STATIC_BINARY)
266 cvc4_set_option(ENABLE_SHARED OFF)
267 else()
268 cvc4_set_option(ENABLE_SHARED ON)
269 endif()
270
271 #-----------------------------------------------------------------------------#
272 # Set options for best configuration
273
274 if(ENABLE_BEST)
275 cvc4_set_option(USE_ABC ON)
276 cvc4_set_option(USE_CADICAL ON)
277 cvc4_set_option(USE_CLN ON)
278 cvc4_set_option(USE_CRYPTOMINISAT ON)
279 cvc4_set_option(USE_GLPK ON)
280 cvc4_set_option(USE_EDITLINE ON)
281 endif()
282
283 # Only enable unit testing if assertions are enabled. Otherwise, unit tests
284 # that expect AssertionException to be thrown will fail.
285 if(NOT ENABLE_ASSERTIONS)
286 set(ENABLE_UNIT_TESTING OFF)
287 endif()
288
289 #-----------------------------------------------------------------------------#
290 # Shared/static libraries
291 #
292 # This needs to be set before any find_package(...) command since we want to
293 # search for static libraries with suffix .a.
294
295 if(ENABLE_SHARED)
296 set(BUILD_SHARED_LIBS ON)
297 if(ENABLE_STATIC_BINARY)
298 set(ENABLE_STATIC_BINARY OFF)
299 message(WARNING "Disabling static binary since shared build is enabled.")
300 endif()
301
302 # Embed the installation prefix as an RPATH in the executable such that the
303 # linker can find our libraries (such as libcvc4parser) when executing the
304 # cvc4 binary. This is for example useful when installing CVC4 with a custom
305 # prefix on macOS (e.g. when using homebrew in a non-standard directory). If
306 # we do not set this option, then the linker will not be able to find the
307 # required libraries when trying to run CVC4.
308 #
309 # Also embed the installation prefix of the installed contrib libraries as an
310 # RPATH. This allows to install a dynamically linked binary that depends on
311 # dynamically linked libraries. This is dangerous, as the installed binary
312 # breaks if the contrib library is removed or changes in other ways, we thus
313 # print a big warning and only allow if installing to a custom installation
314 # prefix.
315 #
316 # More information on RPATH in CMake:
317 # https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
318 set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIR};${PROJECT_SOURCE_DIR}/deps/install/lib")
319 else()
320 # When building statically, we *only* want static archives/libraries
321 if (WIN32)
322 set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a)
323 else()
324 set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
325 endif()
326 set(BUILD_SHARED_LIBS OFF)
327 cvc4_set_option(ENABLE_STATIC_BINARY ON)
328
329 # Never build unit tests as static binaries, otherwise we'll end up with
330 # ~300MB per unit test.
331 if(ENABLE_UNIT_TESTING)
332 message(WARNING "Disabling unit tests since static build is enabled.")
333 set(ENABLE_UNIT_TESTING OFF)
334 endif()
335 endif()
336
337 #-----------------------------------------------------------------------------#
338 # Enable the ctest testing framework
339
340 # This needs to be enabled here rather than in subdirectory test in order to
341 # allow calling ctest from the root build directory.
342 enable_testing()
343
344 #-----------------------------------------------------------------------------#
345 # Check GCC version.
346 #
347 # GCC version 4.5.1 builds MiniSat incorrectly with -O2, which results in
348 # incorrect answers.
349
350 if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
351 execute_process(
352 COMMAND ${CMAKE_CXX_COMPILER} -dumpversion
353 OUTPUT_VARIABLE GCC_VERSION
354 OUTPUT_STRIP_TRAILING_WHITESPACE)
355 if(GCC_VERSION VERSION_EQUAL "4.5.1")
356 message(FATAL_ERROR
357 "GCC 4.5.1's optimizer is known to build MiniSat incorrectly "
358 "(and by extension CVC4).")
359 endif()
360 endif()
361
362 #-----------------------------------------------------------------------------#
363 # Check options, find packages and configure build.
364
365 if(USE_PYTHON2)
366 find_package(PythonInterp 2.7 REQUIRED)
367 elseif(USE_PYTHON3)
368 find_package(PythonInterp 3 REQUIRED)
369 else()
370 find_package(PythonInterp REQUIRED)
371 endif()
372
373 find_package(GMP REQUIRED)
374
375 if(ENABLE_ASAN)
376 # -fsanitize=address requires CMAKE_REQUIRED_FLAGS to be explicitely set,
377 # otherwise the -fsanitize=address check will fail while linking.
378 set(CMAKE_REQUIRED_FLAGS -fsanitize=address)
379 add_required_c_cxx_flag("-fsanitize=address")
380 unset(CMAKE_REQUIRED_FLAGS)
381 add_required_c_cxx_flag("-fno-omit-frame-pointer")
382 add_check_c_cxx_flag("-fsanitize-recover=address")
383 endif()
384
385 if(ENABLE_UBSAN)
386 add_required_c_cxx_flag("-fsanitize=undefined")
387 add_definitions(-DCVC4_USE_UBSAN)
388 endif()
389
390 if(ENABLE_TSAN)
391 # -fsanitize=thread requires CMAKE_REQUIRED_FLAGS to be explicitely set,
392 # otherwise the -fsanitize=thread check will fail while linking.
393 set(CMAKE_REQUIRED_FLAGS -fsanitize=thread)
394 add_required_c_cxx_flag("-fsanitize=thread")
395 unset(CMAKE_REQUIRED_FLAGS)
396 endif()
397
398 if(ENABLE_ASSERTIONS)
399 add_definitions(-DCVC4_ASSERTIONS)
400 else()
401 add_definitions(-DNDEBUG)
402 endif()
403
404 if(ENABLE_COVERAGE)
405 include(CodeCoverage)
406 APPEND_COVERAGE_COMPILER_FLAGS()
407 add_definitions(-DCVC4_COVERAGE)
408 # Note: The ctest command returns a non-zero exit code if tests fail or run
409 # into a timeout. As a consequence, the coverage report is not generated. To
410 # prevent this we always return with exit code 0 after the ctest command has
411 # finished.
412 setup_target_for_coverage_gcovr_html(
413 NAME coverage
414 EXECUTABLE
415 ctest -j${CTEST_NTHREADS} -LE "example"
416 --output-on-failure $$ARGS || exit 0
417 DEPENDS
418 build-tests)
419 endif()
420
421 if(ENABLE_DEBUG_CONTEXT_MM)
422 add_definitions(-DCVC4_DEBUG_CONTEXT_MEMORY_MANAGER)
423 endif()
424
425 if(ENABLE_DEBUG_SYMBOLS)
426 add_check_c_cxx_flag("-ggdb3")
427 endif()
428
429 if(ENABLE_COMP_INC_TRACK)
430 add_definitions(-DCVC4_SMTCOMP_APPLICATION_TRACK)
431 endif()
432
433 if(ENABLE_MUZZLE)
434 add_definitions(-DCVC4_MUZZLE)
435 endif()
436
437 if(ENABLE_DUMPING)
438 add_definitions(-DCVC4_DUMPING)
439 endif()
440
441 if(ENABLE_PROFILING)
442 add_definitions(-DCVC4_PROFILING)
443 add_check_c_cxx_flag("-pg")
444 endif()
445
446 if(ENABLE_PROOFS)
447 set(RUN_REGRESSION_ARGS ${RUN_REGRESSION_ARGS} --enable-proof)
448 add_definitions(-DCVC4_PROOF)
449 endif()
450
451 if(ENABLE_TRACING)
452 add_definitions(-DCVC4_TRACING)
453 endif()
454
455 if(ENABLE_STATISTICS)
456 add_definitions(-DCVC4_STATISTICS_ON)
457 endif()
458
459 if(ENABLE_VALGRIND)
460 find_package(Valgrind REQUIRED)
461 add_definitions(-DCVC4_VALGRIND)
462 endif()
463
464 if(USE_ABC)
465 find_package(ABC REQUIRED)
466 add_definitions(-DCVC4_USE_ABC ${ABC_ARCH_FLAGS})
467 endif()
468
469 if(USE_CADICAL)
470 find_package(CaDiCaL REQUIRED)
471 add_definitions(-DCVC4_USE_CADICAL)
472 endif()
473
474 if(USE_CLN)
475 set(GPL_LIBS "${GPL_LIBS} cln")
476 find_package(CLN 1.2.2 REQUIRED)
477 set(CVC4_USE_CLN_IMP 1)
478 set(CVC4_USE_GMP_IMP 0)
479 else()
480 set(CVC4_USE_CLN_IMP 0)
481 set(CVC4_USE_GMP_IMP 1)
482 endif()
483
484 if(USE_CRYPTOMINISAT)
485 # CryptoMiniSat requires pthreads support
486 set(THREADS_PREFER_PTHREAD_FLAG ON)
487 find_package(Threads REQUIRED)
488 if(THREADS_HAVE_PTHREAD_ARG)
489 add_c_cxx_flag(-pthread)
490 endif()
491 find_package(CryptoMiniSat REQUIRED)
492 add_definitions(-DCVC4_USE_CRYPTOMINISAT)
493 endif()
494
495 if(USE_DRAT2ER)
496 find_package(Drat2Er REQUIRED)
497 add_definitions(-DCVC4_USE_DRAT2ER)
498 endif()
499
500 if(USE_GLPK)
501 set(GPL_LIBS "${GPL_LIBS} glpk")
502 find_package(GLPK REQUIRED)
503 add_definitions(-DCVC4_USE_GLPK)
504 endif()
505
506 if(USE_KISSAT)
507 find_package(Kissat REQUIRED)
508 add_definitions(-DCVC4_USE_KISSAT)
509 endif()
510
511 if(USE_LFSC)
512 set(RUN_REGRESSION_ARGS ${RUN_REGRESSION_ARGS} --with-lfsc)
513 find_package(LFSC REQUIRED)
514 add_definitions(-DCVC4_USE_LFSC)
515 endif()
516
517 if(USE_POLY)
518 find_package(Poly REQUIRED)
519 add_definitions(-DCVC4_USE_POLY)
520 set(CVC4_USE_POLY_IMP 1)
521 else()
522 set(CVC4_USE_POLY_IMP 0)
523 endif()
524
525 if(USE_EDITLINE)
526 find_package(Editline REQUIRED)
527 set(HAVE_LIBEDITLINE 1)
528 if(Editline_COMPENTRY_FUNC_RETURNS_CHARPTR)
529 set(EDITLINE_COMPENTRY_FUNC_RETURNS_CHARP 1)
530 endif()
531 endif()
532
533 if(USE_SYMFPU)
534 find_package(SymFPU REQUIRED)
535 add_definitions(-DCVC4_USE_SYMFPU)
536 set(CVC4_USE_SYMFPU 1)
537 else()
538 set(CVC4_USE_SYMFPU 0)
539 endif()
540
541 if(GPL_LIBS)
542 if(NOT ENABLE_GPL)
543 message(FATAL_ERROR
544 "Bad configuration detected: BSD-licensed code only, but also requested "
545 "GPLed libraries: ${GPL_LIBS}")
546 endif()
547 set(CVC4_GPL_DEPS 1)
548 endif()
549
550 #-----------------------------------------------------------------------------#
551 # Generate CVC4's cvc4autoconfig.h header
552
553 include(ConfigureCVC4)
554 if(NOT ENABLE_SHARED)
555 set(CVC4_STATIC_BUILD ON)
556 endif()
557 configure_file(cvc4autoconfig.h.in cvc4autoconfig.h)
558 unset(CVC4_STATIC_BUILD)
559 include_directories(${CMAKE_CURRENT_BINARY_DIR})
560
561 #-----------------------------------------------------------------------------#
562 # Add subdirectories
563
564 # signatures needs to come before src since it adds source files to libcvc4.
565 if(ENABLE_PROOFS)
566 add_subdirectory(proofs/signatures)
567 endif()
568
569 add_subdirectory(doc)
570 add_subdirectory(src)
571 add_subdirectory(test)
572
573 if(BUILD_BINDINGS_PYTHON)
574 add_subdirectory(src/api/python)
575 endif()
576
577 if(BUILD_BINDINGS_JAVA)
578 message(FATAL_ERROR
579 "Java bindings for the new API are not implemented yet.")
580 endif()
581
582 #-----------------------------------------------------------------------------#
583 # Package configuration
584 #
585 # Export CVC4 targets to support find_package(CVC4) in other cmake projects.
586
587 include(CMakePackageConfigHelpers)
588
589 # If we install a dynamically linked binary that also uses dynamically used
590 # libraries from deps/install/lib, we need to be cautious. Changing these
591 # shared libraries from deps/install/lib most probably breaks the binary.
592 # We only allow such an installation for custom installation prefixes
593 # (in the assumption that only reasonably experienced users use this and
594 # also that custom installation prefixes are not used for longer periods of
595 # time anyway). Also, we print a big warning with further instructions.
596 if(NOT ENABLE_STATIC_BINARY)
597 # Get the libraries that cvc4 links against
598 get_target_property(libs cvc4 INTERFACE_LINK_LIBRARIES)
599 set(LIBS_SHARED_FROM_DEPS "")
600 foreach(lib ${libs})
601 # Filter out those that are linked dynamically and come from deps/install
602 if(lib MATCHES ".*/deps/install/lib/.*\.so")
603 list(APPEND LIBS_SHARED_FROM_DEPS ${lib})
604 endif()
605 endforeach()
606 list(LENGTH LIBS_SHARED_FROM_DEPS list_len)
607 # Check if we actually use such "dangerous" libraries
608 if(list_len GREATER 0)
609 # Print a generic warning
610 install(CODE "message(WARNING \"You are installing a dynamically linked \
611 binary of CVC4 which may be a problem if you are using any dynamically \
612 linked third-party library that you obtained through one of the \
613 contrib/get-xxx scripts. The binary uses the rpath mechanism to find these \
614 locally, hence executing such a contrib script removing the \
615 \\\"deps/install\\\" folder most probably breaks the installed binary! \
616 Consider installing the dynamically linked dependencies on your system \
617 manually or link cvc4 statically.\")")
618 # Print the libraries in question
619 foreach(lib ${LIBS_SHARED_FROM_DEPS})
620 install(CODE "message(WARNING \"The following library is used by the cvc4 binary: ${lib}\")")
621 endforeach()
622 # Check if we use a custom installation prefix
623 if(CMAKE_INSTALL_PREFIX STREQUAL "/usr/local")
624 install(CODE "message(FATAL_ERROR \"To avoid installing a \
625 soon-to-be-broken binary, system-wide installation is disabled if the \
626 binary depends on locally-built shared libraries.\")")
627 else()
628 install(CODE "message(WARNING \"You have selected a custom install \
629 directory ${CMAKE_INSTALL_PREFIX}, so we expect you understood the \
630 previous warning and know what you are doing.\")")
631 endif()
632 endif()
633 endif()
634
635 install(EXPORT cvc4-targets
636 FILE CVC4Targets.cmake
637 NAMESPACE CVC4::
638 DESTINATION ${LIBRARY_INSTALL_DIR}/cmake/CVC4)
639
640 configure_package_config_file(
641 ${CMAKE_SOURCE_DIR}/cmake/CVC4Config.cmake.in
642 ${CMAKE_BINARY_DIR}/cmake/CVC4Config.cmake
643 INSTALL_DESTINATION ${LIBRARY_INSTALL_DIR}/cmake/CVC4
644 PATH_VARS LIBRARY_INSTALL_DIR
645 )
646
647 write_basic_package_version_file(
648 ${CMAKE_CURRENT_BINARY_DIR}/CVC4ConfigVersion.cmake
649 VERSION ${CVC4_RELEASE_STRING}
650 COMPATIBILITY ExactVersion
651 )
652
653 install(FILES
654 ${CMAKE_BINARY_DIR}/cmake/CVC4Config.cmake
655 ${CMAKE_BINARY_DIR}/CVC4ConfigVersion.cmake
656 DESTINATION ${LIBRARY_INSTALL_DIR}/cmake/CVC4
657 )
658
659
660 #-----------------------------------------------------------------------------#
661 # Print build configuration
662
663 # Convert build type to lower case.
664 string(TOLOWER ${CMAKE_BUILD_TYPE} CVC4_BUILD_PROFILE_STRING)
665
666 # Get all definitions added via add_definitions.
667 get_directory_property(CVC4_DEFINITIONS COMPILE_DEFINITIONS)
668 string(REPLACE ";" " " CVC4_DEFINITIONS "${CVC4_DEFINITIONS}")
669
670 message("CVC4 ${CVC4_RELEASE_STRING}")
671 message("")
672 if(ENABLE_COMP_INC_TRACK)
673 message("Build profile : ${CVC4_BUILD_PROFILE_STRING} (incremental)")
674 else()
675 message("Build profile : ${CVC4_BUILD_PROFILE_STRING}")
676 endif()
677 message("")
678 print_config("GPL :" ENABLE_GPL)
679 print_config("Best configuration :" ENABLE_BEST)
680 print_config("Optimization level :" OPTIMIZATION_LEVEL)
681 message("")
682 print_config("Assertions :" ENABLE_ASSERTIONS)
683 print_config("Debug symbols :" ENABLE_DEBUG_SYMBOLS)
684 print_config("Debug context mem mgr :" ENABLE_DEBUG_CONTEXT_MM)
685 message("")
686 print_config("Dumping :" ENABLE_DUMPING)
687 print_config("Muzzle :" ENABLE_MUZZLE)
688 print_config("Proofs :" ENABLE_PROOFS)
689 print_config("Statistics :" ENABLE_STATISTICS)
690 print_config("Tracing :" ENABLE_TRACING)
691 message("")
692 print_config("ASan :" ENABLE_ASAN)
693 print_config("UBSan :" ENABLE_UBSAN)
694 print_config("TSan :" ENABLE_TSAN)
695 print_config("Coverage (gcov) :" ENABLE_COVERAGE)
696 print_config("Profiling (gprof) :" ENABLE_PROFILING)
697 print_config("Unit tests :" ENABLE_UNIT_TESTING)
698 print_config("Valgrind :" ENABLE_VALGRIND)
699 message("")
700 print_config("Shared libs :" ENABLE_SHARED)
701 print_config("Static binary :" ENABLE_STATIC_BINARY)
702 print_config("Python bindings :" BUILD_BINDINGS_PYTHON)
703 print_config("Java bindings :" BUILD_BINDINGS_JAVA)
704 print_config("Python2 :" USE_PYTHON2)
705 print_config("Python3 :" USE_PYTHON3)
706 message("")
707 print_config("ABC :" USE_ABC)
708 print_config("CaDiCaL :" USE_CADICAL)
709 print_config("CryptoMiniSat :" USE_CRYPTOMINISAT)
710 print_config("drat2er :" USE_DRAT2ER)
711 print_config("GLPK :" USE_GLPK)
712 print_config("Kissat :" USE_KISSAT)
713 print_config("LFSC :" USE_LFSC)
714 print_config("LibPoly :" USE_POLY)
715 message("")
716 print_config("BUILD_LIB_ONLY :" BUILD_LIB_ONLY)
717
718 if(CVC4_USE_CLN_IMP)
719 message("MP library : cln")
720 else()
721 message("MP library : gmp")
722 endif()
723 print_config("Editline :" ${USE_EDITLINE})
724 print_config("SymFPU :" ${USE_SYMFPU})
725 message("")
726 if(ABC_DIR)
727 message("ABC dir : ${ABC_DIR}")
728 endif()
729 if(ANTLR_DIR)
730 message("ANTLR dir : ${ANTLR_DIR}")
731 endif()
732 if(CADICAL_DIR)
733 message("CADICAL dir : ${CADICAL_DIR}")
734 endif()
735 if(CRYPTOMINISAT_DIR)
736 message("CRYPTOMINISAT dir : ${CRYPTOMINISAT_DIR}")
737 endif()
738 if(DRAT2ER_DIR)
739 message("DRAT2ER dir : ${DRAT2ER_DIR}")
740 endif()
741 if(GLPK_DIR)
742 message("GLPK dir : ${GLPK_DIR}")
743 endif()
744 if(GMP_DIR)
745 message("GMP dir : ${GMP_DIR}")
746 endif()
747 if(KISSAT_DIR)
748 message("KISSAT dir : ${KISSAT_DIR}")
749 endif()
750 if(LFSC_DIR)
751 message("LFSC dir : ${LFSC_DIR}")
752 endif()
753 if(POLY_DIR)
754 message("LibPoly dir : ${POLY_DIR}")
755 endif()
756 if(SYMFPU_DIR)
757 message("SYMFPU dir : ${SYMFPU_DIR}")
758 endif()
759 message("")
760 message("CPPLAGS (-D...) : ${CVC4_DEFINITIONS}")
761 message("CXXFLAGS : ${CMAKE_CXX_FLAGS}")
762 message("CFLAGS : ${CMAKE_C_FLAGS}")
763 message("Linker flags : ${CMAKE_EXE_LINKER_FLAGS}")
764 message("")
765 message("Install prefix : ${CMAKE_INSTALL_PREFIX}")
766 message("")
767
768 if(GPL_LIBS)
769 message(
770 "CVC4 license : GPLv3 (due to optional libraries; see below)"
771 "\n"
772 "\n"
773 "Please note that CVC4 will be built against the following GPLed libraries:"
774 "\n"
775 "${GPL_LIBS}"
776 "\n"
777 "As these libraries are covered under the GPLv3, so is this build of CVC4."
778 "\n"
779 "CVC4 is also available to you under the terms of the (modified) BSD license."
780 "\n"
781 "If you prefer to license CVC4 under those terms, please configure CVC4 to"
782 "\n"
783 "disable all optional GPLed library dependencies (-DENABLE_BSD_ONLY=ON)."
784 )
785 else()
786 message(
787 "CVC4 license : modified BSD"
788 "\n"
789 "\n"
790 "Note that this configuration is NOT built against any GPL'ed libraries, so"
791 "\n"
792 "it is covered by the (modified) BSD license. This is, however, not the best"
793 "\n"
794 "performing configuration of CVC4. To build against GPL'ed libraries which"
795 "\n"
796 "improve CVC4's performance, re-configure with '-DENABLE_GPL -DENABLE_BEST'."
797 )
798 endif()
799
800 if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
801 set(BUILD_COMMAND_NAME "ninja")
802 else()
803 set(BUILD_COMMAND_NAME "make")
804 endif()
805
806 message("")
807 message("Now just type '${BUILD_COMMAND_NAME}', "
808 "followed by '${BUILD_COMMAND_NAME} check' "
809 "or '${BUILD_COMMAND_NAME} install'.")
810 message("")