Skip to content

Commit e66e19e

Browse files
authored
Fixed build errors resulting from upgrading to VS2019 compilers (dotnet#3894)
* Fixed build errors resulting from upgrade to VS2019 compilers * Added additional message describing the previous fix
1 parent de250ba commit e66e19e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Native/CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ set(RESOURCES)
88
include_directories("${CMAKE_BINARY_DIR}/../../")
99

1010
if(WIN32)
11+
# Clobber and reset the default C and CXX flags because
12+
# CMake uses /ZI (Edit and Continue) for generating pdbs
13+
# which is incompatible with the /guard:cf flag we set below
14+
# for security. So we use the default flags set by CMake
15+
# and reset /ZI with /Zi
16+
message("CMAKE_C_FLAGS_DEBUG is ${CMAKE_C_FLAGS_DEBUG}")
17+
message("CMAKE_CXX_FLAGS_DEBUG is ${CMAKE_CXX_FLAGS_DEBUG}")
18+
message("In a future version, If the default compiler flags no longer contain the /ZI flag, delete this message block and the two lines below.")
19+
set(CMAKE_C_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1 /JMC")
20+
set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1 /JMC")
21+
1122
add_definitions(-DWIN32)
1223
add_definitions(-D_WIN32=1)
1324
add_definitions(-DUNICODE -D_UNICODE)
@@ -22,7 +33,7 @@ if(WIN32)
2233
add_compile_options($<$<CONFIG:Release>:/MT>)
2334
add_compile_options($<$<CONFIG:RelWithDebInfo>:/MT>)
2435
add_compile_options(/guard:cf)
25-
add_compile_options(/d2Zi+) # make optimized builds debugging easier
36+
add_compile_options(/Zo) # make optimized builds debugging easier. /Zo is the newer documented flag.
2637
add_compile_options(/nologo) # Suppress Startup Banner
2738
add_compile_options(/W3) # set warning level to 3
2839
add_compile_options(/WX) # treat warnings as errors

0 commit comments

Comments
 (0)