diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-02-21 21:40:55 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-02-21 21:41:05 (GMT) |
commit | a6706e3a7850aa3095e8c3530417cfdcf7236e96 (patch) | |
tree | 3e9decb56f0c0f7b936dc2e411d1245bafbaf8df /config/sanitizer/sanitizers.cmake | |
parent | 7daf7d4a0bf63fa811a16306b88ccd1b21b9dc16 (diff) | |
download | hdf5-a6706e3a7850aa3095e8c3530417cfdcf7236e96.zip hdf5-a6706e3a7850aa3095e8c3530417cfdcf7236e96.tar.gz hdf5-a6706e3a7850aa3095e8c3530417cfdcf7236e96.tar.bz2 |
Merge changes from develop for CMake and Java
Diffstat (limited to 'config/sanitizer/sanitizers.cmake')
-rw-r--r-- | config/sanitizer/sanitizers.cmake | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/config/sanitizer/sanitizers.cmake b/config/sanitizer/sanitizers.cmake index 2625ec3..ecee2de 100644 --- a/config/sanitizer/sanitizers.cmake +++ b/config/sanitizer/sanitizers.cmake @@ -28,52 +28,53 @@ function(append value) endforeach(variable) endfunction() -if(USE_SANITIZER AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") +message(STATUS "USE_SANITIZER=${USE_SANITIZER}, CMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}") +if(USE_SANITIZER AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - append("-fno-omit-frame-pointer" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-fno-omit-frame-pointer" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS) + message(STATUS "Building with sanitize, base flags=${CMAKE_C_SANITIZER_FLAGS}") if(UNIX) if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") - append("-O1" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-O1" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS) endif() if(USE_SANITIZER MATCHES "([Aa]ddress);([Uu]ndefined)" OR USE_SANITIZER MATCHES "([Uu]ndefined);([Aa]ddress)") message(STATUS "Building with Address, Undefined sanitizers") - append("-fsanitize=address,undefined" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-fsanitize=address,undefined" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS) set(MEMCHECK_TYPE AddressSanitizer) elseif(USE_SANITIZER MATCHES "([Aa]ddress)") # Optional: -fno-optimize-sibling-calls -fsanitize-address-use-after-scope message(STATUS "Building with Address sanitizer") - append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-fsanitize=address" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS) set(MEMCHECK_TYPE AddressSanitizer) elseif(USE_SANITIZER MATCHES "([Mm]emory([Ww]ith[Oo]rigins)?)") # Optional: -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2 - append("-fsanitize=memory" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-fsanitize=memory" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS) if(USE_SANITIZER MATCHES "([Mm]emory[Ww]ith[Oo]rigins)") message(STATUS "Building with MemoryWithOrigins sanitizer") - append("-fsanitize-memory-track-origins" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-fsanitize-memory-track-origins" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS) else() message(STATUS "Building with Memory sanitizer") endif() set(MEMCHECK_TYPE MemorySanitizer) elseif(USE_SANITIZER MATCHES "([Uu]ndefined)") message(STATUS "Building with Undefined sanitizer") - append("-fsanitize=undefined" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-fsanitize=undefined" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS) if(EXISTS "${BLACKLIST_FILE}") - append("-fsanitize-blacklist=${BLACKLIST_FILE}" CMAKE_C_FLAGS - CMAKE_CXX_FLAGS) + append("-fsanitize-blacklist=${BLACKLIST_FILE}" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS) endif() set(MEMCHECK_TYPE UndefinedBehaviorSanitizer) elseif(USE_SANITIZER MATCHES "([Tt]hread)") message(STATUS "Building with Thread sanitizer") - append("-fsanitize=thread" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-fsanitize=thread" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS) set(MEMCHECK_TYPE ThreadSanitizer) elseif(USE_SANITIZER MATCHES "([Ll]eak)") message(STATUS "Building with Leak sanitizer") - append("-fsanitize=leak" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-fsanitize=leak" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS) set(MEMCHECK_TYPE LeakSanitizer) else() message( @@ -82,7 +83,7 @@ if(USE_SANITIZER AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") elseif(MSVC) if(USE_SANITIZER MATCHES "([Aa]ddress)") message(STATUS "Building with Address sanitizer") - append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS) + append("-fsanitize=address" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS) else() message( FATAL_ERROR |