[MSVC] Add NOMINMAX flag to scons and cmake.

Ensures user inclusion of windows.h do not define "min" and "max"
macros.
pull/819/head
Fabio Alessandrelli 2022-09-11 13:12:44 +02:00
parent e272d92827
commit 081d425277
3 changed files with 3 additions and 5 deletions

View File

@ -95,8 +95,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# Disable conversion warning, truncation, unreferenced var, signed mismatch, different type
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /wd4244 /wd4305 /wd4101 /wd4018 /wd4267 /wd4099")
# Todo: Check if needed.
add_definitions(-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DNOMINMAX)
# Unkomment for warning level 4
#if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")

View File

@ -50,8 +50,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# Disable conversion warning, truncation, unreferenced var, signed mismatch
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /wd4244 /wd4305 /wd4101 /wd4018 /wd4267")
# Todo: Check if needed.
add_definitions(-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DNOMINMAX)
# Unkomment for warning level 4
#if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")

View File

@ -24,7 +24,7 @@ def generate(env):
env["TARGET_ARCH"] = "x86"
env["is_msvc"] = True
msvc.generate(env)
env.Append(CPPDEFINES=["TYPED_METHOD_BIND"])
env.Append(CPPDEFINES=["TYPED_METHOD_BIND", "NOMINMAX"])
env.Append(LINKFLAGS=["/WX"])
if env["target"] == "debug":
env.Append(CCFLAGS=["/Z7", "/Od", "/EHsc", "/D_DEBUG", "/MDd"])