diff options
Diffstat (limited to 'cmake/QtInternalTargets.cmake')
-rw-r--r-- | cmake/QtInternalTargets.cmake | 363 |
1 files changed, 261 insertions, 102 deletions
diff --git a/cmake/QtInternalTargets.cmake b/cmake/QtInternalTargets.cmake index 97386e22d8..d7eadc1a73 100644 --- a/cmake/QtInternalTargets.cmake +++ b/cmake/QtInternalTargets.cmake @@ -1,16 +1,21 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause -function(qt_internal_set_warnings_are_errors_flags target) + +function(qt_internal_set_warnings_are_errors_flags target target_scope) set(flags "") - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - # Regular clang 3.0+ - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "3.0.0") - list(APPEND flags -Werror -Wno-error=\#warnings -Wno-error=deprecated-declarations) - endif() - elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") - # using AppleClang - # Apple clang 4.0+ - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "4.0.0" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS_EQUAL "9.2") - list(APPEND flags -Werror -Wno-error=\#warnings -Wno-error=deprecated-declarations) + if (CLANG AND NOT MSVC) + list(APPEND flags -Werror -Wno-error=\#warnings -Wno-error=deprecated-declarations) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # as in: not AppleClang + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "10.0.0") + # We do mixed enum arithmetic all over the place: + list(APPEND flags -Wno-error=deprecated-enum-enum-conversion) + endif() + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "14.0.0") + # Clang 14 introduced these two but we are not clean for it. + list(APPEND flags -Wno-error=deprecated-copy-with-user-provided-copy) + list(APPEND flags -Wno-error=unused-but-set-variable) + endif() endif() elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") # using GCC @@ -32,72 +37,143 @@ function(qt_internal_set_warnings_are_errors_flags target) list(APPEND flags -Wno-error=format-overflow) endif() + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "10.0.0") + # GCC 10 has a number of bugs in -Wstringop-overflow. Do not make them an error. + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92955 + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94335 + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101134 + list(APPEND flags -Wno-error=stringop-overflow) + endif() + + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11.0.0") + # We do mixed enum arithmetic all over the place: + list(APPEND flags -Wno-error=deprecated-enum-enum-conversion -Wno-error=deprecated-enum-float-conversion) + + # GCC has some false positive, and it specifically comes through in MINGW + if (MINGW) + list(APPEND flags -Wno-error=stringop-overread) + endif() + endif() + + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11.0.0" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.2.0") + # GCC 11.1 has a regression in the integrated preprocessor, so disable it as a workaround (QTBUG-93360) + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100796 + # This in turn triggers a fallthrough warning in cborparser.c, so we disable this warning. + list(APPEND flags -no-integrated-cpp -Wno-implicit-fallthrough) + endif() + # Work-around for bug https://code.google.com/p/android/issues/detail?id=58135 if (ANDROID) list(APPEND flags -Wno-error=literal-suffix) endif() - elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") - # Intel CC 13.0 +, on Linux only - if (LINUX) - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "13.0.0") - # 177: function "entity" was declared but never referenced - # (too aggressive; ICC reports even for functions created due to template instantiation) - # 1224: #warning directive - # 1478: function "entity" (declared at line N) was declared deprecated - # 1786: function "entity" (declared at line N of "file") was declared deprecated ("message") - # 1881: argument must be a constant null pointer value - # (NULL in C++ is usually a literal 0) - list(APPEND flags -Werror -ww177,1224,1478,1786,1881) - endif() - endif() elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - # In qmake land, currently warnings as errors are only enabled for - # MSVC 2012, 2013, 2015. - # Respectively MSVC_VERRSIONs are: 1700-1799, 1800-1899, 1900-1909. - if(MSVC_VERSION GREATER_EQUAL 1700 AND MSVC_VERSION LESS_EQUAL 1909) + # Only enable for versions of MSVC that are known to work + # 1939 is Visual Studio 2022 version 17.0 + if(MSVC_VERSION LESS_EQUAL 1939) list(APPEND flags /WX) endif() endif() set(warnings_are_errors_enabled_genex "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_SKIP_WARNINGS_ARE_ERRORS>>>") - # Apprently qmake only adds -Werror to CXX and OBJCXX files, not C files. We have to do the + # Apparently qmake only adds -Werror to CXX and OBJCXX files, not C files. We have to do the # same otherwise MinGW builds break when building 3rdparty\md4c\md4c.c (and probably on other # platforms too). set(cxx_only_genex "$<OR:$<COMPILE_LANGUAGE:CXX>,$<COMPILE_LANGUAGE:OBJCXX>>") set(final_condition_genex "$<AND:${warnings_are_errors_enabled_genex},${cxx_only_genex}>") set(flags_generator_expression "$<${final_condition_genex}:${flags}>") - target_compile_options("${target}" INTERFACE "${flags_generator_expression}") + + target_compile_options("${target}" ${target_scope} "${flags_generator_expression}") +endfunction() + +# The function adds a global 'definition' to the platform internal targets and the target +# property-based switch to disable the definition. +# Arguments: +# VALUE optional value that the definition will take. +# SCOPE the list of scopes the definition needs to be set for. If the SCOPE is not specified the +# definition is added to PlatformCommonInternal target. +# Possible values: +# MODULE - set the definition for all Qt modules +# PLUGIN - set the definition for all Qt plugins +# TOOL - set the definition for all Qt tools +# APP - set the definition for all Qt applications +# TODO: Add a tests specific platform target and the definition scope for it. +function(qt_internal_add_global_definition definition) + set(optional_args) + set(single_value_args VALUE) + set(multi_value_args SCOPE) + cmake_parse_arguments(arg + "${optional_args}" + "${single_value_args}" + "${multi_value_args}" + ${ARGN} + ) + + set(scope_MODULE PlatformModuleInternal) + set(scope_PLUGIN PlatformPluginInternal) + set(scope_TOOL PlatformToolInternal) + set(scope_APP PlatformAppInternal) + + set(undef_property_name "QT_INTERNAL_UNDEF_${definition}") + + if(DEFINED arg_VALUE) + set(definition "${definition}=${arg_VALUE}") + endif() + + set(definition_genex + "$<$<NOT:$<BOOL:$<TARGET_PROPERTY:${undef_property_name}>>>:${definition}>") + + if(NOT DEFINED arg_SCOPE) + target_compile_definitions(PlatformCommonInternal INTERFACE "${definition_genex}") + else() + foreach(scope IN LISTS arg_SCOPE) + if(NOT DEFINED scope_${scope}) + message(FATAL_ERROR "Unknown scope ${scope}.") + endif() + target_compile_definitions("${scope_${scope}}" INTERFACE "${definition_genex}") + endforeach() + endif() endfunction() add_library(PlatformCommonInternal INTERFACE) -add_library(Qt::PlatformCommonInternal ALIAS PlatformCommonInternal) +qt_internal_add_target_aliases(PlatformCommonInternal) +target_link_libraries(PlatformCommonInternal INTERFACE Platform) add_library(PlatformModuleInternal INTERFACE) -add_library(Qt::PlatformModuleInternal ALIAS PlatformModuleInternal) +qt_internal_add_target_aliases(PlatformModuleInternal) target_link_libraries(PlatformModuleInternal INTERFACE PlatformCommonInternal) add_library(PlatformPluginInternal INTERFACE) -add_library(Qt::PlatformPluginInternal ALIAS PlatformPluginInternal) +qt_internal_add_target_aliases(PlatformPluginInternal) target_link_libraries(PlatformPluginInternal INTERFACE PlatformCommonInternal) add_library(PlatformAppInternal INTERFACE) -add_library(Qt::PlatformAppInternal ALIAS PlatformAppInternal) +qt_internal_add_target_aliases(PlatformAppInternal) target_link_libraries(PlatformAppInternal INTERFACE PlatformCommonInternal) add_library(PlatformToolInternal INTERFACE) -add_library(Qt::PlatformToolInternal ALIAS PlatformToolInternal) +qt_internal_add_target_aliases(PlatformToolInternal) target_link_libraries(PlatformToolInternal INTERFACE PlatformAppInternal) +qt_internal_add_global_definition(QT_NO_JAVA_STYLE_ITERATORS) +qt_internal_add_global_definition(QT_NO_QASCONST) +qt_internal_add_global_definition(QT_NO_QEXCHANGE) +qt_internal_add_global_definition(QT_NO_NARROWING_CONVERSIONS_IN_CONNECT) +qt_internal_add_global_definition(QT_EXPLICIT_QFILE_CONSTRUCTION_FROM_PATH) +qt_internal_add_global_definition(QT_USE_QSTRINGBUILDER SCOPE PLUGIN TOOL MODULE) +qt_internal_add_global_definition(QT_NO_FOREACH) + if(WARNINGS_ARE_ERRORS) - qt_internal_set_warnings_are_errors_flags(PlatformModuleInternal) - qt_internal_set_warnings_are_errors_flags(PlatformPluginInternal) - qt_internal_set_warnings_are_errors_flags(PlatformAppInternal) + qt_internal_set_warnings_are_errors_flags(PlatformModuleInternal INTERFACE) + qt_internal_set_warnings_are_errors_flags(PlatformPluginInternal INTERFACE) + qt_internal_set_warnings_are_errors_flags(PlatformAppInternal INTERFACE) endif() 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 @@ -111,17 +187,16 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND CMAKE_SYSTEM_NAME STREQUAL " target_compile_options(PlatformCommonInternal INTERFACE -Wno-ignored-attributes) endif() -# We can't use the gold linker on android with the NDK, which is the default -# linker. To build our own target we will use the lld linker. -# TODO: Why not? -# Linking Android libs with lld on Windows sometimes deadlocks. Don't use lld on -# Windows. qmake doesn't use lld to build Android on any host platform. -if (ANDROID AND NOT CMAKE_HOST_WIN32) - target_link_options(PlatformModuleInternal INTERFACE -fuse-ld=lld) -endif() - +target_compile_definitions(PlatformCommonInternal INTERFACE QT_NO_NARROWING_CONVERSIONS_IN_CONNECT) target_compile_definitions(PlatformCommonInternal INTERFACE $<$<NOT:$<CONFIG:Debug>>:QT_NO_DEBUG>) +if(FEATURE_developer_build) + # This causes an ABI break on Windows, so we cannot unconditionally + # enable it. Keep it for developer builds only for now. + ### Qt 7: remove the if. + target_compile_definitions(PlatformCommonInternal INTERFACE QT_STRICT_QLIST_ITERATORS) +endif() + function(qt_internal_apply_bitcode_flags target) # See mkspecs/features/uikit/bitcode.prf set(release_flags "-fembed-bitcode") @@ -133,10 +208,17 @@ function(qt_internal_apply_bitcode_flags target) set(bitcode_flags "$<${is_enabled_genex}:${flags_genex}>") - target_link_options("${target}" INTERFACE ${bitcode_flags}) target_compile_options("${target}" INTERFACE ${bitcode_flags}) endfunction() +# Function guards linker options that are applicable for internal Qt targets only from propagating +# them to user projects. +function(qt_internal_platform_link_options target scope) + set(options ${ARGN}) + set(is_internal_target_genex "$<BOOL:$<TARGET_PROPERTY:_qt_is_internal_target>>") + target_link_options(${target} ${scope} "$<${is_internal_target_genex}:${options}>") +endfunction() + # Apple deprecated the entire OpenGL API in favor of Metal, which # we are aware of, so silence the deprecation warnings in code. # This does not apply to user-code, which will need to silence @@ -147,30 +229,44 @@ 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 - "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:_WINDLL>" +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "14.0.0") + # Xcode 14's Clang will emit objc_msgSend stubs by default, which ld + # from earlier Xcode versions will fail to understand when linking + # against static libraries with these stubs. Disable the stubs explicitly, + # for as long as we do support Xcode < 14. + set(is_static_lib "$<STREQUAL:$<TARGET_PROPERTY:TYPE>,STATIC_LIBRARY>") + set(is_objc "$<COMPILE_LANGUAGE:OBJC,OBJCXX>") + set(is_static_and_objc "$<AND:${is_static_lib},${is_objc}>") + target_compile_options(PlatformCommonInternal INTERFACE + "$<${is_static_and_objc}:-fno-objc-msgsend-selector-stubs>" ) endif() + + # A bug in Xcode 15 adds duplicate flags to the linker. In addition, the + # `-warn_duplicate_libraries` is now enabled by default which may result + # in several 'duplicate libraries warning'. + # - https://gitlab.kitware.com/cmake/cmake/-/issues/25297 and + # - https://indiestack.com/2023/10/xcode-15-duplicate-library-linker-warnings/ + set(is_xcode15 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,15>") + set(not_disabled "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_NO_DISABLE_WARN_DUPLICATE_LIBRARIES>>>") + target_link_options(PlatformCommonInternal INTERFACE + "$<$<AND:${not_disabled},${is_xcode15}>:LINKER:-no_warn_duplicate_libraries>") endif() -if(UIKIT) - # Do what mkspecs/features/uikit/default_pre.prf does, aka enable sse2 for - # simulator_and_device_builds. - if(FEATURE_simulator_and_device) - # Setting the definition on PlatformCommonInternal behaves slightly differently from what - # is done in qmake land. This way the define is not propagated to tests, examples, or - # user projects built with qmake, but only modules, plugins and tools. - # TODO: Figure out if this ok or not (sounds ok to me). - target_compile_definitions(PlatformCommonInternal INTERFACE QT_COMPILER_SUPPORTS_SSE2) - endif() - qt_internal_apply_bitcode_flags(PlatformCommonInternal) +if(MSVC) + target_compile_definitions(PlatformCommonInternal INTERFACE + "_CRT_SECURE_NO_WARNINGS" + "$<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>:_WINDLL>" + ) +endif() + +if(WASM AND QT_FEATURE_sse2) + target_compile_definitions(PlatformCommonInternal INTERFACE QT_COMPILER_SUPPORTS_SSE2) endif() # Taken from mkspecs/common/msvc-version.conf and mkspecs/common/msvc-desktop.conf -if (MSVC) +if (MSVC AND NOT CLANG) if (MSVC_VERSION GREATER_EQUAL 1799) target_compile_options(PlatformCommonInternal INTERFACE -FS @@ -181,40 +277,92 @@ if (MSVC) if (MSVC_VERSION GREATER_EQUAL 1899) target_compile_options(PlatformCommonInternal INTERFACE -Zc:strictStrings + -Zc:throwingNew ) - if (NOT CLANG) - target_compile_options(PlatformCommonInternal INTERFACE - -Zc:throwingNew - ) - endif() endif() - if (MSVC_VERSION GREATER_EQUAL 1909 AND NOT CLANG) + if (MSVC_VERSION GREATER_EQUAL 1909) # MSVC 2017 target_compile_options(PlatformCommonInternal INTERFACE -Zc:referenceBinding + -Zc:ternary ) endif() - if (MSVC_VERSION GREATER_EQUAL 1919 AND NOT CLANG) + if (MSVC_VERSION GREATER_EQUAL 1919) # MSVC 2019 target_compile_options(PlatformCommonInternal INTERFACE -Zc:externConstexpr + #-Zc:lambda # Buggy. TODO: Enable again when stable enough. + #-Zc:preprocessor # breaks build due to bug in default Windows SDK 10.0.19041 ) endif() - target_compile_options(PlatformCommonInternal INTERFACE -Zc:wchar_t) + target_compile_options(PlatformCommonInternal INTERFACE + -Zc:wchar_t + -bigobj + ) target_compile_options(PlatformCommonInternal INTERFACE - $<$<NOT:$<CONFIG:Debug>>:-guard:cf> + $<$<NOT:$<CONFIG:Debug>>:-guard:cf -Gw> ) - target_link_options(PlatformCommonInternal INTERFACE - -DYNAMICBASE -NXCOMPAT + qt_internal_platform_link_options(PlatformCommonInternal INTERFACE + -DYNAMICBASE -NXCOMPAT -LARGEADDRESSAWARE $<$<NOT:$<CONFIG:Debug>>:-OPT:REF -OPT:ICF -GUARD:CF> ) endif() +if(MINGW) + target_compile_options(PlatformCommonInternal INTERFACE -Wa,-mbig-obj) +endif() + if (GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "9.2") target_compile_options(PlatformCommonInternal INTERFACE $<$<COMPILE_LANGUAGE:CXX>:-Wsuggest-override>) endif() +# Hardening options +if(QT_FEATURE_intelcet) + if(MSVC) + qt_internal_platform_link_options(PlatformCommonInternal INTERFACE -CETCOMPAT) + else() + target_compile_options(PlatformCommonInternal INTERFACE -fcf-protection=full) + endif() +endif() + +if(QT_FEATURE_glibc_fortify_source) + set(is_optimized_build "$<OR:$<NOT:$<CONFIG:Debug>>,$<BOOL:${QT_FEATURE_optimize_debug}>>") + # Some compilers may define _FORTIFY_SOURCE by default when optimizing, remove it + # before defining our own + target_compile_options(PlatformCommonInternal BEFORE INTERFACE "$<${is_optimized_build}:-U_FORTIFY_SOURCE>") + if(TEST_glibc_234) + target_compile_options(PlatformCommonInternal INTERFACE "$<${is_optimized_build}:-D_FORTIFY_SOURCE=3>") + else() + target_compile_options(PlatformCommonInternal INTERFACE "$<${is_optimized_build}:-D_FORTIFY_SOURCE=2>") + endif() +endif() + +if(QT_FEATURE_trivial_auto_var_init_pattern) + target_compile_options(PlatformCommonInternal INTERFACE -ftrivial-auto-var-init=pattern) +endif() + +if(QT_FEATURE_stack_protector) + target_compile_options(PlatformCommonInternal INTERFACE -fstack-protector-strong) +endif() + +if(QT_FEATURE_stack_clash_protection) + target_compile_options(PlatformCommonInternal INTERFACE -fstack-clash-protection) +endif() + +if(QT_FEATURE_libstdcpp_assertions) + target_compile_definitions(PlatformCommonInternal INTERFACE _GLIBCXX_ASSERTIONS) +endif() + +if(QT_FEATURE_libcpp_hardening) + target_compile_definitions(PlatformCommonInternal INTERFACE -D_LIBCPP_HARDENING_MODE=$<IF:$<CONFIG:Debug>,_LIBCPP_HARDENING_MODE_EXTENSIVE,_LIBCPP_HARDENING_MODE_FAST>) +endif() + +if(QT_FEATURE_relro_now_linker) + qt_internal_platform_link_options(PlatformCommonInternal INTERFACE "-Wl,-z,relro,-z,now") +endif() + + if(QT_FEATURE_force_asserts) target_compile_definitions(PlatformCommonInternal INTERFACE QT_FORCE_ASSERTS) endif() @@ -234,32 +382,40 @@ endif() if(DEFINED QT_EXTRA_FRAMEWORKPATHS AND APPLE) list(TRANSFORM QT_EXTRA_FRAMEWORKPATHS PREPEND "-F" OUTPUT_VARIABLE __qt_fw_flags) target_compile_options(PlatformCommonInternal INTERFACE ${__qt_fw_flags}) - target_link_options(PlatformCommonInternal INTERFACE ${__qt_fw_flags}) + qt_internal_platform_link_options(PlatformCommonInternal INTERFACE ${__qt_fw_flags}) unset(__qt_fw_flags) endif() -if(QT_FEATURE_use_gold_linker) - target_link_options(PlatformCommonInternal INTERFACE "-fuse-ld=gold") -elseif(QT_FEATURE_use_bfd_linker) - target_link_options(PlatformCommonInternal INTERFACE "-fuse-ld=bfd") -elseif(QT_FEATURE_use_lld_linker) - target_link_options(PlatformCommonInternal INTERFACE "-fuse-ld=lld") +qt_internal_get_active_linker_flags(__qt_internal_active_linker_flags) +if(__qt_internal_active_linker_flags) + qt_internal_platform_link_options(PlatformCommonInternal INTERFACE + "${__qt_internal_active_linker_flags}") endif() +unset(__qt_internal_active_linker_flags) if(QT_FEATURE_enable_gdb_index) - target_link_options(PlatformCommonInternal INTERFACE "-Wl,--gdb-index") + qt_internal_platform_link_options(PlatformCommonInternal INTERFACE "-Wl,--gdb-index") endif() if(QT_FEATURE_enable_new_dtags) - target_link_options(PlatformCommonInternal INTERFACE "-Wl,--enable-new-dtags") + qt_internal_platform_link_options(PlatformCommonInternal INTERFACE "-Wl,--enable-new-dtags") endif() +function(qt_internal_apply_coverage_flags) + if(QT_FEATURE_coverage_gcov) + target_compile_options(PlatformCommonInternal INTERFACE + "$<$<CONFIG:Debug>:--coverage>") + target_link_options(PlatformCommonInternal INTERFACE "$<$<CONFIG:Debug>:--coverage>") + endif() +endfunction() +qt_internal_apply_coverage_flags() + function(qt_get_implicit_sse2_genex_condition out_var) set(is_shared_lib "$<STREQUAL:$<TARGET_PROPERTY:TYPE>,SHARED_LIBRARY>") set(is_static_lib "$<STREQUAL:$<TARGET_PROPERTY:TYPE>,STATIC_LIBRARY>") set(is_static_qt_build "$<NOT:$<BOOL:${QT_BUILD_SHARED_LIBS}>>") - set(is_staitc_lib_during_static_qt_build "$<AND:${is_static_qt_build},${is_static_lib}>") - set(enable_sse2_condition "$<OR:${is_shared_lib},${is_staitc_lib_during_static_qt_build}>") + set(is_static_lib_during_static_qt_build "$<AND:${is_static_qt_build},${is_static_lib}>") + set(enable_sse2_condition "$<OR:${is_shared_lib},${is_static_lib_during_static_qt_build}>") set(${out_var} "${enable_sse2_condition}" PARENT_SCOPE) endfunction() @@ -284,15 +440,7 @@ qt_auto_detect_implicit_sse2() function(qt_auto_detect_fpmath) # fpmath configuration adjustment in qt_module.prf set(fpmath_supported FALSE) - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "3.4") - set(fpmath_supported TRUE) - endif() - elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") - if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "5.1") - set(fpmath_supported TRUE) - endif() - elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang|GNU|IntelLLVM") set(fpmath_supported TRUE) endif() if(fpmath_supported AND TEST_architecture_arch STREQUAL "i386" AND __implicit_sse2_for_qt_modules_enabled) @@ -308,16 +456,27 @@ function(qt_handle_apple_app_extension_api_only) # Build Qt libraries with -fapplication-extension. Needed to avoid linker warnings # transformed into errors on darwin platforms. set(flags "-fapplication-extension") - set(genex_condition "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_NO_APP_EXTENSION_ONLY_API>>>") - set(flags "$<${genex_condition}:${flags}>") + + # The flags should only be applied to internal Qt libraries like modules and plugins. + # The reason why we use a custom property to apply the flags is because there's no other + # way to prevent the link options spilling out into user projects if the target that links + # against PlatformXInternal is a static library. + # The exported static library's INTERFACE_LINK_LIBRARIES property would contain + # $<LINK_ONLY:PlatformXInternal> and PlatformXInternal's INTERFACE_LINK_OPTIONS would be + # applied to a user project target. + # So to contain the spilling out of the flags, we ensure the link options are only added + # to internal Qt libraries that are marked with the property. + set(not_disabled "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_NO_APP_EXTENSION_ONLY_API>>>") + set(is_qt_internal_library "$<BOOL:$<TARGET_PROPERTY:_qt_is_internal_library>>") + + set(condition "$<AND:${not_disabled},${is_qt_internal_library}>") + + set(flags "$<${condition}:${flags}>") target_compile_options(PlatformModuleInternal INTERFACE ${flags}) target_link_options(PlatformModuleInternal INTERFACE ${flags}) target_compile_options(PlatformPluginInternal INTERFACE ${flags}) target_link_options(PlatformPluginInternal INTERFACE ${flags}) endif() endfunction() -function(qt_disable_apple_app_extension_api_only target) - set_target_properties("${target}" PROPERTIES QT_NO_APP_EXTENSION_ONLY_API TRUE) -endfunction() qt_handle_apple_app_extension_api_only() |