@@ -47,11 +47,11 @@ set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWIT
4747set (CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO} /LTCG" )
4848set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /LTCG /OPT:REF /OPT:ICF ${NO_INCREMENTAL_LINKER_FLAGS} " )
4949
50- # Force uCRT to be dynamically linked for Release build
51- set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib" )
52- set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib" )
53- set (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib" )
54- set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib" )
50+ # Force uCRT to be dynamically linked for Release build
51+ set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib" )
52+ set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib" )
53+ set (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib" )
54+ set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib" )
5555
5656#------------------------------------
5757# Definitions (for platform)
@@ -133,16 +133,18 @@ if (BUILD_ARCH_AMD64)
133133endif (BUILD_ARCH_AMD64)
134134
135135# enable control-flow-guard support for native components for non-Arm64 builds
136- add_compile_options (/guard:cf)
137-
138- # Statically linked CRT (libcmt[d].lib, libvcruntime[d].lib and libucrt[d].lib) by default. This is done to avoid
139- # linking in VCRUNTIME140.DLL for a simplified xcopy experience by reducing the dependency on VC REDIST.
140- #
141- # For Release builds, we shall dynamically link into uCRT [ucrtbase.dll] (which is pushed down as a Windows Update on downlevel OS) but
142- # wont do the same for debug/checked builds since ucrtbased.dll is not redistributable and Debug/Checked builds are not
143- # production-time scenarios.
144- add_compile_options ($<$<OR :$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/MT>)
145- add_compile_options ($<$<OR :$<CONFIG:Debug>,$<CONFIG:Checked>>:/MTd>)
136+ add_compile_options (/guard:cf)
137+
138+ # Statically linked CRT (libcmt[d].lib, libvcruntime[d].lib and libucrt[d].lib) by default. This is done to avoid
139+ # linking in VCRUNTIME140.DLL for a simplified xcopy experience by reducing the dependency on VC REDIST.
140+ #
141+ # For Release builds, we shall dynamically link into uCRT [ucrtbase.dll] (which is pushed down as a Windows Update on downlevel OS) but
142+ # wont do the same for debug/checked builds since ucrtbased.dll is not redistributable and Debug/Checked builds are not
143+ # production-time scenarios.
144+ add_compile_options ($<$<OR :$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/MT>)
145+ add_compile_options ($<$<OR :$<CONFIG:Debug>,$<CONFIG:Checked>>:/MTd>)
146+
147+ add_compile_options (/Qspectre) # add Spectre mitigation compiler option. (https://docs.microsoft.com/en-us/cpp/build/reference/qspectre?view=vs-2017)
146148
147149#set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /ZH:SHA_256")
148150
0 commit comments