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