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