From d6890791897ddebf1212d3e3147bf7aeb2415b27 Mon Sep 17 00:00:00 2001 From: Mathias Preiner Date: Tue, 16 Mar 2021 10:56:01 -0700 Subject: cmake: Generate cvc4_export.h and set visibility to hidden. (#6139) The build system (cmake) will automatically generate an export header cvc4_export.h, which makes sure that the correct export features are defined depending on the compiler and target platform. The macro CVC4_EXPORT replaces CVC4_PUBLIC and its usage is reduced by 2/3. Co-authored-by: Gereon Kremer --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index dc244917d..c06c360ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,8 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) # Generate compile_commands.json, which can be used for various code completion # plugins. @@ -292,6 +294,12 @@ if(ENABLE_SHARED) message(WARNING "Disabling static binary since shared build is enabled.") endif() + # Set visibility to default if unit tests are enabled + if(ENABLE_UNIT_TESTING) + set(CMAKE_CXX_VISIBILITY_PRESET default) + set(CMAKE_VISIBILITY_INLINES_HIDDEN 0) + endif() + # Embed the installation prefix as an RPATH in the executable such that the # linker can find our libraries (such as libcvc4parser) when executing the # cvc4 binary. This is for example useful when installing CVC4 with a custom -- cgit v1.2.3