From 31fb616a932be0363bff72ad31e7d53b82ad6af1 Mon Sep 17 00:00:00 2001 From: Belonit <54427022+Belonit@users.noreply.github.com> Date: Mon, 31 Aug 2026 01:43:56 +0300 Subject: [PATCH] Define NOMINMAX for all OpenTS targets --- code/CMakeLists.txt | 1 + code/always.h | 12 ------------ code/language/CMakeLists.txt | 1 + code/vqalib/CMakeLists.txt | 1 + tests/cpudetect/CMakeLists.txt | 2 +- tests/gamedirs/CMakeLists.txt | 2 +- tests/logstress/CMakeLists.txt | 2 +- 7 files changed, 6 insertions(+), 15 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 4c1fb2a7..d7c705fb 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -171,6 +171,7 @@ target_compile_definitions(OpenTS PRIVATE WIN32 _WINDOWS _MBCS + NOMINMAX # Compiles Blowfish into the binary instead of reaching it through the COM object in # blowfish.dll. It decides the layout of BlowfishEngine, so every translation unit has diff --git a/code/always.h b/code/always.h index a07219e2..534c242a 100644 --- a/code/always.h +++ b/code/always.h @@ -81,18 +81,6 @@ void __cdecl operator delete(void * ptr); #define WWINLINE inline #endif -// Windows headers define 'min' and 'max' as macros, which would break every -// std::min and std::max call in the tree. -#define NOMINMAX - -#ifdef min -#undef min -#endif - -#ifdef max -#undef max -#endif - /* ** This includes the minimum set of compiler defines and pragmas in order to bring the diff --git a/code/language/CMakeLists.txt b/code/language/CMakeLists.txt index b72a8b22..4d1feabe 100644 --- a/code/language/CMakeLists.txt +++ b/code/language/CMakeLists.txt @@ -5,6 +5,7 @@ file(GLOB_RECURSE LANG_SRC CONFIGURE_DEPENDS add_library(Language SHARED ${LANG_SRC}) target_compile_features(Language PRIVATE cxx_std_20) +target_compile_definitions(Language PRIVATE NOMINMAX) # The version resource is stamped from the generated headers, which the resource compiler # reaches through the target's include paths. diff --git a/code/vqalib/CMakeLists.txt b/code/vqalib/CMakeLists.txt index f9a95aa1..9b3b579d 100644 --- a/code/vqalib/CMakeLists.txt +++ b/code/vqalib/CMakeLists.txt @@ -30,6 +30,7 @@ target_compile_definitions(VQALib PRIVATE WIN32 _WINDOWS _MBCS + NOMINMAX ) # Callers reach the vqaplay.h family through the library, while the player itself reaches diff --git a/tests/cpudetect/CMakeLists.txt b/tests/cpudetect/CMakeLists.txt index 13c2f535..75a43288 100644 --- a/tests/cpudetect/CMakeLists.txt +++ b/tests/cpudetect/CMakeLists.txt @@ -12,7 +12,7 @@ target_include_directories(CpuDetect PRIVATE "${CMAKE_SOURCE_DIR}/code" ) -target_compile_definitions(CpuDetect PRIVATE WIN32 _WINDOWS _MBCS) +target_compile_definitions(CpuDetect PRIVATE WIN32 _WINDOWS _MBCS NOMINMAX) # The engine builds these sources with SSE2 and precise floating point. The harness matches # that so a result here carries over to the engine. diff --git a/tests/gamedirs/CMakeLists.txt b/tests/gamedirs/CMakeLists.txt index 97e40385..8a79eb19 100644 --- a/tests/gamedirs/CMakeLists.txt +++ b/tests/gamedirs/CMakeLists.txt @@ -36,7 +36,7 @@ target_include_directories(GameDirs PRIVATE add_dependencies(GameDirs OpenTSBuildStamp) -target_compile_definitions(GameDirs PRIVATE WIN32 _WINDOWS _MBCS) +target_compile_definitions(GameDirs PRIVATE WIN32 _WINDOWS _MBCS NOMINMAX) target_compile_options(GameDirs PRIVATE $<$:/MTd /EHsc /Zc:__cplusplus> diff --git a/tests/logstress/CMakeLists.txt b/tests/logstress/CMakeLists.txt index 7d205c87..a7c90b70 100644 --- a/tests/logstress/CMakeLists.txt +++ b/tests/logstress/CMakeLists.txt @@ -15,7 +15,7 @@ target_include_directories(LogStress PRIVATE add_dependencies(LogStress OpenTSBuildStamp) -target_compile_definitions(LogStress PRIVATE WIN32 _WINDOWS _MBCS) +target_compile_definitions(LogStress PRIVATE WIN32 _WINDOWS _MBCS NOMINMAX) target_compile_options(LogStress PRIVATE $<$:/MTd /EHsc /Zc:__cplusplus>