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