Skip to content

Commit 15878ee

Browse files
committed
Windows, compiling : Remove _DEBUG preprocessor constant, to fix
debug build with older cmake. The constant is implicitely defined by VS when chosen C runtime is Debug (/MTd, MDd). CMake does not define it since https://public.kitware.com/Bug/view.php?id=15777 was fixed. We remove it from compile flags, to be able to build Debug with /MT runtime using older cmakes.
1 parent fb0b364 commit 15878ee

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

cmake/os/Windows.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ IF(MSVC)
9797
# information for use with the debugger. The symbolic debugging
9898
# information includes the names and types of variables, as well as
9999
# functions and line numbers. No .pdb file is produced by the compiler.
100+
#
101+
# - Remove preprocessor flag _DEBUG that older cmakes use with Config=Debug,
102+
# it is as defined by Debug runtimes itself (/MTd /MDd)
103+
100104
FOREACH(lang C CXX)
101105
SET(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE} /Z7")
102106
ENDFOREACH()
@@ -106,6 +110,7 @@ IF(MSVC)
106110
CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO
107111
CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT)
108112
STRING(REGEX REPLACE "/M[TD][d]?" "${MSVC_CRT_TYPE}" "${flag}" "${${flag}}" )
113+
STRING(REGEX REPLACE "/D[ ]?_DEBUG" "" "${flag}" "${${flag}}")
109114
STRING(REPLACE "/Zi" "/Z7" "${flag}" "${${flag}}")
110115
ENDFOREACH()
111116

0 commit comments

Comments
 (0)