Add NOMINMAX to PlatformCommonInternal

By not explicitly disabling min/max macros of `windows.h`, we may see
some unintended substitutions. This is especially important now that we
are moving toward enabling Unity Build, and some of the constructs for
manually dealing with this issue, eg., `#ifdef max`, `#undef max`, might
not make it to the pool, and as a result we get build failure.

Change-Id: Ie3c31aebe00300126a2ac3a6044876ab92d5d99c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 585dd9d8d542c85a36cc36bd7420e83b722ad744)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Amir Masoud Abdol 2023-05-19 10:11:23 +02:00 committed by Qt Cherry-pick Bot
parent 07fd20a0e1
commit 9832fb96f6
2 changed files with 6 additions and 0 deletions

View File

@ -185,6 +185,9 @@ function(qt_internal_add_headersclean_target module_target module_headers)
# <windows.h> and <GL.h> violate the standards.
set(hcleanFLAGS -std:c++latest -Zc:__cplusplus -WX -W3)
# Because we now add `-DNOMINMAX` to `PlatformCommonInternal`.
set(hcleanUDEFS -UNOMINMAX)
# cl.exe needs a source path
get_filename_component(source_path "${QT_MKSPECS_DIR}/features/data/dummy.cpp" REALPATH)
@ -195,6 +198,7 @@ function(qt_internal_add_headersclean_target module_target module_headers)
"${hcleanFLAGS}"
"${target_includes_joined_genex}"
"${hcleanDEFS}"
"${hcleanUDEFS}"
)
string(JOIN " " compiler_command_line_variables
"-FI"

View File

@ -168,6 +168,8 @@ if(WIN32)
# Needed for M_PI define. Same as mkspecs/features/qt_module.prf.
# It's set for every module being built, but it's not propagated to user apps.
target_compile_definitions(PlatformModuleInternal INTERFACE _USE_MATH_DEFINES)
# Not disabling min/max macros may result in unintended substitutions of std::min/max
target_compile_definitions(PlatformCommonInternal INTERFACE NOMINMAX)
endif()
if(FEATURE_largefile AND UNIX)
target_compile_definitions(PlatformCommonInternal