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