From e4825d16cf43b177b4b062513c1fca5384c5fd0d Mon Sep 17 00:00:00 2001 From: SOULIER Laurent <laurent.soulier@cea.fr> Date: Fri, 5 Jan 2024 17:11:50 +0100 Subject: [PATCH] [BUILD][FIX] fix sanitizer support on msvc --- CMakeLists.txt | 3 +++ unit_tests/CMakeLists.txt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49a68a4d8..a0d70035e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,6 +91,9 @@ $<$<CXX_COMPILER_ID:GNU>:${STRICT_ALIASING_FLAGS}>) target_compile_options(${module_name} PRIVATE $<$<CXX_COMPILER_ID:MSVC>: /W4 /wd4477 /DWIN32 /D_WINDOWS /GR /EHsc /MP /Zc:__cplusplus /Zc:preprocessor /permissive- ${SANITIZE_MSVC_FLAGS}>) +if (DOSANITIZE STREQUAL "ON") + target_compile_options(${module_name} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/MDd>) +endif() # TODO FIXME: I'm not sure it's a good idea to propagate this option but, at this point, it was the only way that worked to silence C4477 target_compile_options(${module_name} PUBLIC $<$<CXX_COMPILER_ID:MSVC>: /wd4477>) diff --git a/unit_tests/CMakeLists.txt b/unit_tests/CMakeLists.txt index f2c446701..806f62d47 100644 --- a/unit_tests/CMakeLists.txt +++ b/unit_tests/CMakeLists.txt @@ -44,6 +44,9 @@ $<$<CXX_COMPILER_ID:GNU>:${STRICT_ALIASING_FLAGS}>) target_compile_options(${module_name} PRIVATE $<$<CXX_COMPILER_ID:MSVC>: /W4 /DWIN32 /D_WINDOWS /GR /EHsc /MP /Zc:__cplusplus /Zc:preprocessor /permissive- ${SANITIZE_MSVC_FLAGS}>) +if (DOSANITIZE STREQUAL "ON") + target_compile_options(${module_name} PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/MDd>) +endif() # TODO FIXME: I'm not sure it's a good idea to propagate this option but, at this point, it was the only way that worked to silence C4477 target_compile_options(${module_name} PUBLIC $<$<CXX_COMPILER_ID:MSVC>: /wd4477>) -- GitLab