mirror of
https://github.com/HDFGroup/hdf5.git
synced 2024-11-21 01:04:10 +08:00
Fix clang/sanitizer for windows (#883)
* Fix clang/sanitizer for windows * Restrict MSVC version for sanitize
This commit is contained in:
parent
c0f1db4b96
commit
6968906418
@ -33,10 +33,10 @@ if(USE_SANITIZER)
|
||||
if(INTEL_CLANG OR "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
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)
|
||||
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(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
||||
append("-O1" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
|
||||
endif()
|
||||
@ -80,10 +80,10 @@ if(USE_SANITIZER)
|
||||
message(
|
||||
FATAL_ERROR "Unsupported value of USE_SANITIZER: ${USE_SANITIZER}")
|
||||
endif()
|
||||
elseif(MSVC)
|
||||
elseif(MSVC AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 19.29)
|
||||
if(USE_SANITIZER MATCHES "([Aa]ddress)")
|
||||
message(STATUS "Building with Address sanitizer")
|
||||
append("-fsanitize=address" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
|
||||
append("/fsanitize=address" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
|
||||
else()
|
||||
message(FATAL_ERROR "This sanitizer not yet supported in the MSVC environment: ${USE_SANITIZER}")
|
||||
endif()
|
||||
|
@ -3,8 +3,13 @@
|
||||
|
||||
set(CMAKE_COMPILER_VENDOR "clang")
|
||||
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
set(CMAKE_CXX_COMPILER clang++)
|
||||
if(WIN32)
|
||||
set(CMAKE_C_COMPILER clang-cl)
|
||||
set(CMAKE_CXX_COMPILER clang-cl)
|
||||
else()
|
||||
set(CMAKE_C_COMPILER clang)
|
||||
set(CMAKE_CXX_COMPILER clang++)
|
||||
endif()
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# the following is used if cross-compiling
|
||||
|
Loading…
Reference in New Issue
Block a user