From fe25bf61e5f9956fed4dd6dd302b79a69d5ba75b Mon Sep 17 00:00:00 2001 From: "Harish S. Kulkarni" Date: Fri, 21 Jun 2019 01:56:57 -0700 Subject: [PATCH 1/4] Fixed build errors resulting from upgrade to VS2019 compilers --- src/Native/CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Native/CMakeLists.txt b/src/Native/CMakeLists.txt index a814277e91..0c8e184517 100644 --- a/src/Native/CMakeLists.txt +++ b/src/Native/CMakeLists.txt @@ -8,6 +8,14 @@ set(RESOURCES) include_directories("${CMAKE_BINARY_DIR}/../../") if(WIN32) + # Clobber and reset the default C and CXX flags because + # CMake uses /ZI (Edit and Continue) for generating pdbs + # which is incompatible with the /guard:cf flag we set below + # for security. So we use the default flags set by CMake + # and reset /ZI with /Zi + set(CMAKE_C_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1 /JMC") + set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1 /JMC") + add_definitions(-DWIN32) add_definitions(-D_WIN32=1) add_definitions(-DUNICODE -D_UNICODE) @@ -22,7 +30,7 @@ if(WIN32) add_compile_options($<$:/MT>) add_compile_options($<$:/MT>) add_compile_options(/guard:cf) - add_compile_options(/d2Zi+) # make optimized builds debugging easier + add_compile_options(/Zo) # make optimized builds debugging easier. /Zo is the newer documented flag. add_compile_options(/nologo) # Suppress Startup Banner add_compile_options(/W3) # set warning level to 3 add_compile_options(/WX) # treat warnings as errors From cb446be57b5debba61f711ed55159e16ce575a1f Mon Sep 17 00:00:00 2001 From: "Harish S. Kulkarni" Date: Fri, 21 Jun 2019 09:44:22 -0700 Subject: [PATCH 2/4] Added additional message describing the previous fix --- src/Native/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Native/CMakeLists.txt b/src/Native/CMakeLists.txt index 0c8e184517..96345141b7 100644 --- a/src/Native/CMakeLists.txt +++ b/src/Native/CMakeLists.txt @@ -13,6 +13,9 @@ if(WIN32) # which is incompatible with the /guard:cf flag we set below # for security. So we use the default flags set by CMake # and reset /ZI with /Zi + message("CMAKE_C_FLAGS_DEBUG is ${CMAKE_C_FLAGS_DEBUG}") + message("CMAKE_CXX_FLAGS_DEBUG is ${CMAKE_CXX_FLAGS_DEBUG}") + 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.") set(CMAKE_C_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1 /JMC") set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1 /JMC") From aae68d2577c76a41739b02a6b640db2dbee82591 Mon Sep 17 00:00:00 2001 From: "Harish S. Kulkarni" Date: Fri, 21 Jun 2019 13:23:33 -0700 Subject: [PATCH 3/4] Checked in a better fix based on code review --- src/Native/CMakeLists.txt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Native/CMakeLists.txt b/src/Native/CMakeLists.txt index 96345141b7..eb5c57b259 100644 --- a/src/Native/CMakeLists.txt +++ b/src/Native/CMakeLists.txt @@ -8,16 +8,12 @@ set(RESOURCES) include_directories("${CMAKE_BINARY_DIR}/../../") if(WIN32) - # Clobber and reset the default C and CXX flags because - # CMake uses /ZI (Edit and Continue) for generating pdbs - # which is incompatible with the /guard:cf flag we set below - # for security. So we use the default flags set by CMake - # and reset /ZI with /Zi + # There seems to be a bug in the latest VS2019 + # which is adding /ZI (which conflicts with /guard:cf) instead of /Zi. message("CMAKE_C_FLAGS_DEBUG is ${CMAKE_C_FLAGS_DEBUG}") - message("CMAKE_CXX_FLAGS_DEBUG is ${CMAKE_CXX_FLAGS_DEBUG}") - 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.") - set(CMAKE_C_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1 /JMC") - set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1 /JMC") + message("In a future version, if the default compiler flags no longer contain the /ZI flag, delete this message block and the line below.") + string(REPLACE "/ZI" "/Zi" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) + string(REPLACE "/ZI" "/Zi" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) add_definitions(-DWIN32) add_definitions(-D_WIN32=1) From fd67c0e455196b6a9ba3dd5d73379bc025044cf1 Mon Sep 17 00:00:00 2001 From: "Harish S. Kulkarni" Date: Fri, 21 Jun 2019 14:53:25 -0700 Subject: [PATCH 4/4] Updated message --- src/Native/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Native/CMakeLists.txt b/src/Native/CMakeLists.txt index eb5c57b259..586a58a704 100644 --- a/src/Native/CMakeLists.txt +++ b/src/Native/CMakeLists.txt @@ -11,7 +11,7 @@ if(WIN32) # There seems to be a bug in the latest VS2019 # which is adding /ZI (which conflicts with /guard:cf) instead of /Zi. message("CMAKE_C_FLAGS_DEBUG is ${CMAKE_C_FLAGS_DEBUG}") - message("In a future version, if the default compiler flags no longer contain the /ZI flag, delete this message block and the line below.") + message("In a future version, if the CMake that ships with VS2019 no longer contains the /ZI flag, delete this message block and the two lines below.") string(REPLACE "/ZI" "/Zi" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) string(REPLACE "/ZI" "/Zi" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})