Skip to content

Commit

Permalink
Fix cmake dynamic analysis on windows (#1373)
Browse files Browse the repository at this point in the history
* Fix sanitizer flag form on windows

* Add search paths to windows code-coverage
  • Loading branch information
byrnHDF authored Jan 24, 2022
1 parent 99d3962 commit 4d45d05
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
15 changes: 11 additions & 4 deletions config/sanitizer/code-coverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,17 @@ option(
OFF)

# Programs
find_program(LLVM_COV_PATH llvm-cov)
find_program(LLVM_PROFDATA_PATH llvm-profdata)
find_program(LCOV_PATH lcov)
find_program(GENHTML_PATH genhtml)
if(WIN32)
find_program(LLVM_COV_PATH llvm-cov PATHS ENV VS2019INSTALLDIR PATH_SUFFIXES "VC/Tools/Llvm/x64/bin")
find_program(LLVM_PROFDATA_PATH llvm-profdata PATHS ENV VS2019INSTALLDIR PATH_SUFFIXES "VC/Tools/Llvm/x64/bin")
find_program(LCOV_PATH lcov PATHS ENV VS2019INSTALLDIR PATH_SUFFIXES "VC/Tools/Llvm/x64/bin")
find_program(GENHTML_PATH genhtml PATHS ENV VS2019INSTALLDIR PATH_SUFFIXES "VC/Tools/Llvm/x64/bin")
else()
find_program(LLVM_COV_PATH llvm-cov)
find_program(LLVM_PROFDATA_PATH llvm-profdata)
find_program(LCOV_PATH lcov)
find_program(GENHTML_PATH genhtml)
endif()

# Variables
set(CMAKE_COVERAGE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/ccov)
Expand Down
11 changes: 10 additions & 1 deletion config/sanitizer/sanitizers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,21 @@ if(USE_SANITIZER)
elseif(MSVC)
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()
else()
message(FATAL_ERROR "USE_SANITIZER is not supported on this platform.")
endif()
elseif(MSVC)
if(USE_SANITIZER MATCHES "([Aa]ddress)")
message(STATUS "Building with Address sanitizer")
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()
else()
message(FATAL_ERROR "USE_SANITIZER is not supported on this platform.")
endif()
endif()

0 comments on commit 4d45d05

Please sign in to comment.