From 223431aaa5a95d48a6aff20134ed4e2481de3cf3 Mon Sep 17 00:00:00 2001 From: Mathias Preiner Date: Thu, 8 Nov 2018 11:10:16 -0800 Subject: cmake: Add option to explicitely enable/disable static binaries. (#2698) --- CMakeLists.txt | 14 +++++++++++++- configure.sh | 9 ++++++++- src/main/CMakeLists.txt | 4 ++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33824d186..099fc00fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,8 @@ cvc4_option(ENABLE_TRACING "Enable tracing") cvc4_option(ENABLE_UNIT_TESTING "Enable unit testing") cvc4_option(ENABLE_VALGRIND "Enable valgrind instrumentation") cvc4_option(ENABLE_SHARED "Build as shared library") +cvc4_option(ENABLE_STATIC_BINARY + "Build static binaries with statically linked system libraries") # >> 2-valued: ON OFF # > for options where we don't need to detect if set by user (default: OFF) option(ENABLE_BEST "Enable dependencies known to give best performance") @@ -184,7 +186,11 @@ add_check_cxx_flag("-Wno-class-memaccess") # These options are only set if their value is IGNORE. Otherwise, the user # already set the option, which we don't want to overwrite. -cvc4_set_option(ENABLE_SHARED ON) +if(ENABLE_STATIC_BINARY) + cvc4_set_option(ENABLE_SHARED OFF) +else() + cvc4_set_option(ENABLE_SHARED ON) +endif() #-----------------------------------------------------------------------------# # Set options for best configuration @@ -221,11 +227,16 @@ endif() if(ENABLE_SHARED) set(BUILD_SHARED_LIBS ON) + if(ENABLE_STATIC_BINARY) + set(ENABLE_STATIC_BINARY OFF) + message(WARNING "Disabling static binary since shared build is enabled.") + endif() else() set(CMAKE_FIND_LIBRARY_SUFFIXES ".a ${CMAKE_FIND_LIBRARY_SUFFIXES}") set(BUILD_SHARED_LIBS OFF) # This is required to force find_package(Boost) to use static libraries. set(Boost_USE_STATIC_LIBS ON) + cvc4_set_option(ENABLE_STATIC_BINARY ON) endif() #-----------------------------------------------------------------------------# @@ -501,6 +512,7 @@ print_config("Unit tests :" ENABLE_UNIT_TESTING) print_config("Valgrind :" ENABLE_VALGRIND) message("") print_config("Shared libs :" ENABLE_SHARED) +print_config("Static binary :" ENABLE_STATIC_BINARY) print_config("Java bindings :" BUILD_BINDINGS_JAVA) print_config("Python bindings :" BUILD_BINDINGS_PYTHON) print_config("Python2 :" USE_PYTHON2) diff --git a/configure.sh b/configure.sh index d5f466ec6..7fa842f70 100755 --- a/configure.sh +++ b/configure.sh @@ -25,6 +25,7 @@ General options; Features: The following flags enable optional features (disable with --no-