summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorGereon Kremer <nafur42@gmail.com>2021-11-04 11:43:42 -0700
committerGitHub <noreply@github.com>2021-11-04 18:43:42 +0000
commite1f69a43e9ee7e4a63f3c4a1881001bc650c9df7 (patch)
treef5293f7fdc47f773466185585a8c41d85a258562 /CMakeLists.txt
parent6aef06e6fed867eb014e08859139c8c610c7cce4 (diff)
Refactor cmake to build either static or shared (#7534)
This PR simplifies the cmake setup to only build either shared or statically. It also attempts to fix windows builds, both shared and static.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt30
1 files changed, 25 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ef3b7636e..11e12d89a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -70,6 +70,7 @@ option(ENABLE_GPL "Enable GPL dependencies")
# >> 3-valued: IGNORE ON OFF
# > allows to detect if set by user (default: IGNORE)
# > only necessary for options set for build types
+option(BUILD_SHARED_LIBS "Build shared libraries and binary")
cvc5_option(ENABLE_ASAN "Enable ASAN build")
cvc5_option(ENABLE_UBSAN "Enable UBSan build")
cvc5_option(ENABLE_TSAN "Enable TSan build")
@@ -83,7 +84,6 @@ cvc5_option(ENABLE_STATISTICS "Enable statistics")
cvc5_option(ENABLE_TRACING "Enable tracing")
cvc5_option(ENABLE_UNIT_TESTING "Enable unit testing")
cvc5_option(ENABLE_VALGRIND "Enable valgrind instrumentation")
-cvc5_option(ENABLE_STATIC_BUILD "Enable building static libraries and binary")
cvc5_option(ENABLE_AUTO_DOWNLOAD "Enable automatic download of dependencies")
cvc5_option(ENABLE_IPO "Enable interprocedural optimization")
# >> 2-valued: ON OFF
@@ -263,6 +263,20 @@ enable_testing()
#-----------------------------------------------------------------------------#
# Check options, find packages and configure build.
+if(BUILD_SHARED_LIBS)
+ if (WIN32)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .dll .lib .a)
+ else()
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .so .dylib .a)
+ endif()
+else()
+ if (WIN32)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a .dll)
+ else()
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .a .so .dylib)
+ endif()
+endif()
+
if(USE_PYTHON2)
find_package(PythonInterp 2.7 REQUIRED)
else()
@@ -440,7 +454,9 @@ include(fuzzing-murxla)
#-----------------------------------------------------------------------------#
include(ConfigureCvc5)
-if(ENABLE_STATIC_BUILD)
+if(BUILD_SHARED_LIBS)
+ set(CVC5_STATIC_BUILD OFF)
+else()
set(CVC5_STATIC_BUILD ON)
endif()
@@ -449,6 +465,10 @@ endif()
add_subdirectory(src)
+if(BUILD_BINDINGS_PYTHON AND NOT BUILD_SHARED_LIBS)
+ message(STATUS "Python bindings can only be built in a shared build.")
+ set(BUILD_BINDINGS_PYTHON OFF)
+endif()
if(BUILD_BINDINGS_PYTHON)
set(BUILD_BINDINGS_PYTHON_VERSION ${PYTHON_VERSION_MAJOR})
add_subdirectory(src/api/python)
@@ -481,9 +501,9 @@ include(CMakePackageConfigHelpers)
# (in the assumption that only reasonably experienced users use this and
# also that custom installation prefixes are not used for longer periods of
# time anyway). Also, we print a big warning with further instructions.
-if(NOT ENABLE_STATIC_BUILD)
+if(BUILD_SHARED_LIBS)
# Get the libraries that cvc5 links against
- get_target_property(libs cvc5-shared INTERFACE_LINK_LIBRARIES)
+ get_target_property(libs cvc5 INTERFACE_LINK_LIBRARIES)
set(LIBS_SHARED_FROM_DEPS "")
foreach(lib ${libs})
# Filter out those that are linked dynamically and come from deps/install
@@ -592,7 +612,7 @@ print_config("Profiling (gprof) " ${ENABLE_PROFILING})
print_config("Unit tests " ${ENABLE_UNIT_TESTING})
print_config("Valgrind " ${ENABLE_VALGRIND})
message("")
-print_config("Static build " ${ENABLE_STATIC_BUILD})
+print_config("Shared build " ${BUILD_SHARED_LIBS})
print_config("Python bindings " ${BUILD_BINDINGS_PYTHON})
print_config("Java bindings " ${BUILD_BINDINGS_JAVA})
print_config("Python2 " ${USE_PYTHON2})
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback