Revert to using add_<compile|link>_options again
This commit is contained in:
@@ -653,6 +653,31 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||
ENDIF(WIN32)
|
||||
ENDIF()
|
||||
|
||||
#
|
||||
# add enabled sanitizers
|
||||
# todo: use target_link_options(lmmsobjs INTERFACE -fsanitize=<check>) instead
|
||||
# once support is added to link object libraries to other targets (CMake 3.12)
|
||||
#
|
||||
function(add_sanitizer sanitizer supported_compilers want_flag status_flag)
|
||||
if(${want_flag})
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES ${supported_compilers})
|
||||
set(${status_flag} "Enabled" PARENT_SCOPE)
|
||||
add_compile_options(-fsanitize=${sanitizer})
|
||||
add_link_options(-fsanitize=${sanitizer})
|
||||
else()
|
||||
set(${status_flag} "Wanted but disabled due to unsupported compiler" PARENT_SCOPE)
|
||||
endif()
|
||||
else()
|
||||
set(${status_flag} "Disabled" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
add_sanitizer(address "GNU|Clang|MSVC" WANT_DEBUG_ASAN STATUS_DEBUG_ASAN)
|
||||
add_sanitizer(thread "GNU|Clang" WANT_DEBUG_TSAN STATUS_DEBUG_TSAN)
|
||||
add_sanitizer(memory "Clang" WANT_DEBUG_MSAN STATUS_DEBUG_MSAN)
|
||||
add_sanitizer(undefined "GNU|Clang" WANT_DEBUG_UBSAN STATUS_DEBUG_UBSAN)
|
||||
|
||||
|
||||
# use ccache
|
||||
include(CompileCache)
|
||||
|
||||
@@ -721,32 +746,6 @@ ADD_CUSTOM_TARGET(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}" -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/uninstall.cmake"
|
||||
)
|
||||
|
||||
#
|
||||
# add enabled sanitizers
|
||||
# todo: use target_link_options(lmmsobjs INTERFACE -fsanitize=<check>) instead
|
||||
# once support is added to link object libraries to other targets (CMake 3.12)
|
||||
#
|
||||
|
||||
function(add_sanitizer sanitizer supported_compilers want_flag status_flag)
|
||||
if(${want_flag})
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES ${supported_compilers})
|
||||
set(${status_flag} "Enabled" PARENT_SCOPE)
|
||||
target_compile_options(lmmsobjs PUBLIC -fsanitize=${sanitizer})
|
||||
target_link_options(lmms PRIVATE -fsanitize=${sanitizer})
|
||||
target_link_options(tests PRIVATE -fsanitize=${sanitizer})
|
||||
else()
|
||||
set(${status_flag} "Wanted but disabled due to unsupported compiler" PARENT_SCOPE)
|
||||
endif()
|
||||
else()
|
||||
set(${status_flag} "Disabled" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
add_sanitizer(address "GNU|Clang|MSVC" WANT_DEBUG_ASAN STATUS_DEBUG_ASAN)
|
||||
add_sanitizer(thread "GNU|Clang" WANT_DEBUG_TSAN STATUS_DEBUG_TSAN)
|
||||
add_sanitizer(memory "Clang" WANT_DEBUG_MSAN STATUS_DEBUG_MSAN)
|
||||
add_sanitizer(undefined "GNU|Clang" WANT_DEBUG_UBSAN STATUS_DEBUG_UBSAN)
|
||||
|
||||
#
|
||||
# display configuration information
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user