From 081d425277535bd102709e0fea66565033a9227c Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Sun, 11 Sep 2022 13:12:44 +0200 Subject: [PATCH] [MSVC] Add NOMINMAX flag to scons and cmake. Ensures user inclusion of windows.h do not define "min" and "max" macros. --- CMakeLists.txt | 3 +-- test/CMakeLists.txt | 3 +-- tools/windows.py | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0c6be67..cbfbfb1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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]") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 990a0f1a..f229253e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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]") diff --git a/tools/windows.py b/tools/windows.py index 9c5ea6f9..3d5d22e0 100644 --- a/tools/windows.py +++ b/tools/windows.py @@ -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"])