Hide symbols by default also with a system Abseil The default hidden symbol visibility was only applied when building against the bundled Abseil, so shared libraries built against a system Abseil exported all internal symbols. Set the visibility presets regardless of how Abseil is provided. Change-Id: I23e1bb1e7eea0d5822806b227ccaa6089587786c
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6911897..05fea16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -249,12 +249,6 @@ unset(CMAKE_CXX_STANDARD) unset(CMAKE_CXX_VISIBILITY_PRESET) - # Set the default symbol visibility to hidden to unify the behavior among - # the various compilers and to get smaller binaries - set(CMAKE_C_VISIBILITY_PRESET hidden) - set(CMAKE_CXX_VISIBILITY_PRESET hidden) - set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) - set(CERES_USE_SYSTEM_ABSL NO) else() if (NOT absl_VERSION) @@ -267,6 +261,12 @@ endif() set(CERES_USE_SYSTEM_ABSL YES) endif() + +# Set the default symbol visibility to hidden to unify the behavior among +# the various compilers and to get smaller binaries +set(CMAKE_C_VISIBILITY_PRESET hidden) +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) if (NOT absl_VERSION) install (CODE [=[message (FATAL_ERROR "Cannot generate CeresConfig.cmake due to missing Abseil version. Using resulting package configuration will likely result in integration errors. Set absl_VERSION manually to disable this error message.")]=]) endif()