diff --git a/CMakeLists.txt b/CMakeLists.txt index 60d3d80a6..4127d0714 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -299,15 +299,17 @@ set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD ${CMAKE_CXX_STANDA # Hide symbols by default # Except where it causes problems, and the situation is weird enough that it's not worth investigating further. -string(FIND "${CMAKE_CXX_FLAGS}" "-D_GLIBCXX_USE_CXX11_ABI=0" found_ancient_abi_flag) +# +# We've seen people set _GLIBCXX_USE_CXX11_ABI=0 which forces GCC to use it's pre-C++11 string implementation, +# which leads to crashes on shared-lib builds. Search every variant of CXX_FLAGS to see if it's set. +string(FIND "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${CMAKE_CXX_FLAGS_MINSIZEREL}" + "-D_GLIBCXX_USE_CXX11_ABI=0" found_ancient_abi_flag) if(found_ancient_abi_flag GREATER -1) - # We've seen people set _GLIBCXX_USE_CXX11_ABI=0 which forces GCC to use it's pre-C++11 string implementation. - # This leads to crashes on shared-lib builds. - message(STATUS "Cannot deal with hidden symbols when _GLIBCXX_USE_CXX11_ABI=0 is set, making everything visible") + message(WARNING "_GLIBCXX_USE_CXX11_ABI=0 is set. Making all symbols visible to prevent weird crashes") elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") # Ancient GCC leads to crashes in shared-lib builds # see: https://github.com/awslabs/aws-crt-cpp/pull/675 - message(STATUS "Your compiler is too old to deal with hidden symbols, making everything visible") + message(WARNING "Ancient compiler (${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}). Making all symbols visible to prevent weird crashes") else() set_target_properties(${PROJECT_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON) endif()