- # 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
- # prefix on macOS (e.g. when using homebrew in a non-standard directory). If
- # we do not set this option, then the linker will not be able to find the
- # required libraries when trying to run CVC4.
- #
- # Also embed the installation prefix of the installed contrib libraries as an
- # RPATH. This allows to install a dynamically linked binary that depends on
- # dynamically linked libraries. This is dangerous, as the installed binary
- # breaks if the contrib library is removed or changes in other ways, we thus
- # print a big warning and only allow if installing to a custom installation
- # prefix.
- #
- # More information on RPATH in CMake:
- # https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
- set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR};${PROJECT_SOURCE_DIR}/deps/install/lib")
-else()
- # When building statically, we *only* want static archives/libraries
- if (WIN32)
- set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a)
- else()
- set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
- endif()
- set(BUILD_SHARED_LIBS OFF)
- cvc4_set_option(ENABLE_STATIC_BINARY ON)
-
- # Never build unit tests as static binaries, otherwise we'll end up with
- # ~300MB per unit test.
- if(ENABLE_UNIT_TESTING)
- message(WARNING "Disabling unit tests since static build is enabled.")
- set(ENABLE_UNIT_TESTING OFF)
- endif()
-
- if (BUILD_BINDINGS_PYTHON)
- message(FATAL_ERROR "Building Python bindings is not possible "
- "when building statically")
+# Embed the installation prefix as an RPATH in the executable such that the
+# linker can find our libraries (such as libcvc5parser) when executing the
+# cvc5 binary. This is for example useful when installing cvc5 with a custom
+# prefix on macOS (e.g. when using homebrew in a non-standard directory). If
+# we do not set this option, then the linker will not be able to find the
+# required libraries when trying to run cvc5.
+#
+# Also embed the installation prefix of the installed contrib libraries as an
+# RPATH. This allows to install a dynamically linked binary that depends on
+# dynamically linked libraries. This is dangerous, as the installed binary
+# breaks if the contrib library is removed or changes in other ways, we thus
+# print a big warning and only allow if installing to a custom installation
+# prefix.
+#
+# More information on RPATH in CMake:
+# https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
+set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR};${PROJECT_SOURCE_DIR}/deps/install/lib")
+
+# Set visibility to default if unit tests are enabled. If unit tests are
+# enabled, we also check if we can execute white box unit tests (some versions
+# of Clang have issues with the required flag).
+set(ENABLE_WHITEBOX_UNIT_TESTING OFF)
+if(ENABLE_UNIT_TESTING)
+ set(CMAKE_CXX_VISIBILITY_PRESET default)
+ set(CMAKE_VISIBILITY_INLINES_HIDDEN 0)
+
+ # Check if Clang version has the bug that was fixed in
+ # https://reviews.llvm.org/D93104
+ set(ENABLE_WHITEBOX_UNIT_TESTING ON)
+ check_cxx_compiler_flag("-faccess-control" HAVE_CXX_FLAGfaccess_control)
+ if(NOT HAVE_CXX_FLAGfaccess_control)
+ set(ENABLE_WHITEBOX_UNIT_TESTING OFF)
+ message(STATUS "Disabling white box unit tests")