@@ -114,18 +114,28 @@ function(add_ur_target_compile_options name)
114114 elseif (MSVC )
115115 target_compile_options (${name} PRIVATE
116116 $<$<CXX_COMPILER_ID:MSVC >:/MP> # clang-cl.exe does not support /MP
117- /W3
118117 /MD $<$<CONFIG:Debug>:d>
119- /GS
120- /DWIN32_LEAN_AND_MEAN
121- /DNOMINMAX
118+
119+ /W3
120+ /GS # Enable: Buffer security check
121+ /Gy # Enable: Function-level linking
122+
123+ $<$<CONFIG:Release>:/sdl> # Enable: Additional SDL checks
124+ $<$<CXX_COMPILER_ID:MSVC >:/Qspectre> # Enable: Mitigate Spectre variant 1 vulnerabilities
125+
126+ /wd4267 # Disable: 'var' : conversion from 'size_t' to 'type', possible loss of data
127+ /wd6244 # Disable: local declaration of 'variable' hides previous declaration
128+ /wd6246 # Disable: local declaration of 'variable' hides declaration of same name in outer scope
129+ )
130+
131+ target_compile_definitions (${name} PRIVATE
132+ WIN32_LEAN_AND_MEAN NOMINMAX # Cajole Windows.h to define fewer symbols
133+ _CRT_SECURE_NO_WARNINGS # Slience warnings about getenv
122134 )
123135
124136 if (UR_DEVELOPER_MODE)
125- # _CRT_SECURE_NO_WARNINGS used mainly because of getenv
126- # C4267: The compiler detected a conversion from size_t to a smaller type.
127137 target_compile_options (${name} PRIVATE
128- /WX /GS /D_CRT_SECURE_NO_WARNINGS /wd4267
138+ /WX # Enable: Treat all warnings as errors
129139 )
130140 endif ()
131141 endif ()
@@ -149,9 +159,12 @@ function(add_ur_target_link_options name)
149159 endif ()
150160 elseif (MSVC )
151161 target_link_options (${name} PRIVATE
152- LINKER:/DYNAMICBASE
153- LINKER:/HIGHENTROPYVA
154- LINKER:/NXCOMPAT
162+ LINKER:/DYNAMICBASE # Enable: Modify header to indicate ASLR should be use
163+ LINKER:/HIGHENTROPYVA # Enable: High-entropy address space layout randomization (ASLR)
164+ $<$<CONFIG:Release>:
165+ LINKER:/NXCOMPAT # Enable: Data Execution Prevention
166+ LINKER:/LTCG # Enable: Link-time code generation
167+ >
155168 )
156169 endif ()
157170endfunction ()
0 commit comments