diff --git a/cmake/Modules/MacroQbtCommonConfig.cmake b/cmake/Modules/MacroQbtCommonConfig.cmake index 0e0068977..72e6f5702 100644 --- a/cmake/Modules/MacroQbtCommonConfig.cmake +++ b/cmake/Modules/MacroQbtCommonConfig.cmake @@ -95,4 +95,13 @@ macro(qbt_common_config) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() + if (MSVC) + target_compile_options(qbt_common_cfg INTERFACE /guard:cf) + target_link_options(qbt_common_cfg INTERFACE /guard:cf + $<$>:/OPT:REF /OPT:ICF> + # suppress linking warning due to /INCREMENTAL and /OPT:ICF being both ON + $<$:/INCREMENTAL:NO> + ) + endif() + endmacro(qbt_common_config)