From 6d1ee1f6b26c77d77510e39c09c063537810f457 Mon Sep 17 00:00:00 2001 From: Mathias Preiner Date: Wed, 29 Aug 2018 10:26:10 -0700 Subject: [PATCH] cmake: Add support for building static binaries/libraries. --- CMakeLists.txt | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69f56f0bf..aa91a631f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -201,18 +201,6 @@ set(CVC4_BUILD_PROFILE_COMPETITION 0) # Whether CVC4 is built with the (optional) GPLed library dependences. set(CVC4_GPL_DEPS 0) -#-----------------------------------------------------------------------------# - -find_package(PythonInterp REQUIRED) - -set(ANTLR_HOME ${ANTLR_DIR}) -find_package(ANTLR REQUIRED) - -set(GMP_HOME ${GMP_DIR}) -find_package(GMP REQUIRED) -cvc4_link_library(${GMP_LIBRARIES}) -include_directories(${GMP_INCLUDE_DIR}) - #-----------------------------------------------------------------------------# # Compiler flags @@ -258,6 +246,27 @@ cvc4_set_option(ENABLE_PORTFOLIO OFF) cvc4_set_option(ENABLE_SHARED ON) cvc4_set_option(ENABLE_VALGRIND OFF) +#-----------------------------------------------------------------------------# + +# This needs to be set before any find_package(...) command since we want to +# search for static libraries with suffix .a. +if(NOT ENABLE_SHARED) + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + set(CMAKE_EXE_LINKER_FLAGS "-static") + set(BUILD_SHARED_LIBS OFF) +endif() + +find_package(PythonInterp REQUIRED) + +set(ANTLR_HOME ${ANTLR_DIR}) +find_package(ANTLR REQUIRED) + +set(GMP_HOME ${GMP_DIR}) +find_package(GMP REQUIRED) +cvc4_link_library(${GMP_LIBRARIES}) +include_directories(${GMP_INCLUDE_DIR}) + + #-----------------------------------------------------------------------------# # Enable the ctest testing framework -- 2.30.2