diff options
-rw-r--r-- | cmake/QtFlagHandlingHelpers.cmake | 9 | ||||
-rw-r--r-- | cmake/QtInternalTargets.cmake | 13 | ||||
-rw-r--r-- | cmake/QtPlatformTargetHelpers.cmake | 2 | ||||
-rw-r--r-- | src/corelib/Qt6CoreMacros.cmake | 11 |
4 files changed, 27 insertions, 8 deletions
diff --git a/cmake/QtFlagHandlingHelpers.cmake b/cmake/QtFlagHandlingHelpers.cmake index cbc39cbf1a..0c57d9e0e1 100644 --- a/cmake/QtFlagHandlingHelpers.cmake +++ b/cmake/QtFlagHandlingHelpers.cmake @@ -256,6 +256,15 @@ function(qt_enable_utf8_sources target) endif() endfunction() +function(qt_internal_enable_unicode_defines) + if(WIN32) + set(no_unicode_condition + "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_NO_UNICODE_DEFINES>>>") + target_compile_definitions(Platform + INTERFACE "$<${no_unicode_condition}:UNICODE;_UNICODE>") + endif() +endfunction() + # Saves the list of known optimization flags for the current compiler in out_var. # # Mostly used for removing them before adding new ones. diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake index 006c0c0213..c10cd285e9 100644 --- a/cmake/QtInternalTargets.cmake +++ b/cmake/QtInternalTargets.cmake @@ -148,14 +148,11 @@ elseif(UIKIT) target_compile_definitions(PlatformCommonInternal INTERFACE GLES_SILENCE_DEPRECATION) endif() -if(WIN32) - target_compile_definitions(PlatformCommonInternal INTERFACE "UNICODE;_UNICODE") - if(MSVC) - target_compile_definitions(PlatformCommonInternal INTERFACE - "_CRT_SECURE_NO_WARNINGS" - "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:_WINDLL>" - ) - endif() +if(MSVC) + target_compile_definitions(PlatformCommonInternal INTERFACE + "_CRT_SECURE_NO_WARNINGS" + "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:_WINDLL>" + ) endif() if(UIKIT) diff --git a/cmake/QtPlatformTargetHelpers.cmake b/cmake/QtPlatformTargetHelpers.cmake index 68ff8a3ea0..0ff8761f33 100644 --- a/cmake/QtPlatformTargetHelpers.cmake +++ b/cmake/QtPlatformTargetHelpers.cmake @@ -30,4 +30,6 @@ function(qt_internal_setup_public_platform_target) # By default enable utf8 sources for both Qt and Qt consumers. Can be opted out. qt_enable_utf8_sources(Platform) + # By default enable unicode on WIN32 platforms for both Qt and Qt consumers. Can be opted out. + qt_internal_enable_unicode_defines(Platform) endfunction() diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 96b25b4ad9..2fd6d3a18c 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -1884,3 +1884,14 @@ properties of both types." ) endforeach() endfunction() + +# Disables the default unicode definitions for the target +function(qt6_disable_unicode_defines target) + set_target_properties(${target} PROPERTIES QT_NO_UNICODE_DEFINES TRUE) +endfunction() + +if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) + function(qt_disable_unicode_defines) + qt6_disable_unicode_defines(${ARGV}) + endfunction() +endif() |