diff --git a/CMakeLists.txt b/CMakeLists.txt index 8773d86..e383aef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,12 @@ string(APPEND CMAKE_C_FLAGS set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") +if ("${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} ${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" MATCHES "(^| )-fsanitize=") + message(STATUS "Sanitizer-enabled build detected; not forcing -Wl,--no-undefined") +else() + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") +endif() + set(CMAKE_CXX_VISIBILITY_PRESET hidden) set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)