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.

Pick-to: 6.5
Change-Id: Ie3c31aebe00300126a2ac3a6044876ab92d5d99c
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Amir Masoud Abdol 2023-05-19 10:11:23 +02:00
parent 4e860a66d6
commit 585dd9d8d5
2 changed files with 6 additions and 0 deletions

View File

@ -184,6 +184,9 @@ function(qt_internal_add_headersclean_target module_target module_headers)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(hcleanFLAGS -std:c++latest -Zc:__cplusplus -Za -WX -W3 -EHsc)
# 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)
@ -194,6 +197,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

@ -170,6 +170,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