CMake: Use -fvisibility=hidden everywhere supported

This commit is contained in:
Sam Edwards 2019-01-11 07:50:27 -07:00
parent 9ee4f1f4e2
commit 768a8d62e9

View File

@ -111,6 +111,16 @@ add_compile_options(
"$<${cxx_exceptions_property}:${cxx_exceptions_on}>"
"$<$<NOT:${cxx_exceptions_property}>:${cxx_exceptions_off}>")
# We should use -fvisibility=hidden everywhere, as it makes sure we think
# about what symbols really should be exposed externally. For more info, see:
# https://gcc.gnu.org/wiki/Visibility
if(NOT MSVC)
check_cxx_compiler_flag("-fvisibility=hidden" COMPILER_SUPPORTS_FVISIBILITY_HIDDEN)
if(COMPILER_SUPPORTS_FVISIBILITY_HIDDEN)
add_compile_options("-fvisibility=hidden")
endif()
endif()
# Include global modules needed for configure scripts
include(PackageConfig) # Defines package_option