diff --git a/cmake/FindWrapFreetype.cmake b/cmake/FindWrapFreetype.cmake index 3f8317be69..59219df6c2 100644 --- a/cmake/FindWrapFreetype.cmake +++ b/cmake/FindWrapFreetype.cmake @@ -1,17 +1,11 @@ include(QtFindWrapHelper NO_POLICY_SCOPE) -set(_qt_wrap_use_bundled FALSE) -if(QT_FEATURE_freetype AND NOT QT_FEATURE_system_freetype) - set(_qt_wrap_use_bundled TRUE) -endif() - qt_find_package_system_or_bundled(wrap_freetype FRIENDLY_PACKAGE_NAME "Freetype" WRAP_PACKAGE_TARGET "WrapFreetype::WrapFreetype" WRAP_PACKAGE_FOUND_VAR_NAME "WrapFreetype_FOUND" - BUNDLED_PACKAGE_NAME "Qt6BundledFreetype" - BUNDLED_PACKAGE_TARGET "Qt6::BundledFreetype" + BUNDLED_PACKAGE_NAME "BundledFreetype" + BUNDLED_PACKAGE_TARGET "BundledFreetype" SYSTEM_PACKAGE_NAME "WrapSystemFreetype" SYSTEM_PACKAGE_TARGET "WrapSystemFreetype::WrapSystemFreetype" - USE_BUNDLED_PACKAGE "${_qt_wrap_use_bundled}" ) diff --git a/cmake/FindWrapHarfbuzz.cmake b/cmake/FindWrapHarfbuzz.cmake index eac95b669d..a66bb08d89 100644 --- a/cmake/FindWrapHarfbuzz.cmake +++ b/cmake/FindWrapHarfbuzz.cmake @@ -1,17 +1,11 @@ include(QtFindWrapHelper NO_POLICY_SCOPE) -set(_qt_wrap_use_bundled FALSE) -if(QT_FEATURE_harfbuzz AND NOT QT_FEATURE_system_harfbuzz) - set(_qt_wrap_use_bundled TRUE) -endif() - qt_find_package_system_or_bundled(wrap_harfbuzz FRIENDLY_PACKAGE_NAME "Harfbuzz" WRAP_PACKAGE_TARGET "WrapHarfbuzz::WrapHarfbuzz" WRAP_PACKAGE_FOUND_VAR_NAME "WrapHarfbuzz_FOUND" - BUNDLED_PACKAGE_NAME "Qt6BundledHarfbuzz" - BUNDLED_PACKAGE_TARGET "Qt6::BundledHarfbuzz" + BUNDLED_PACKAGE_NAME "BundledHarfbuzz" + BUNDLED_PACKAGE_TARGET "BundledHarfbuzz" SYSTEM_PACKAGE_NAME "WrapSystemHarfbuzz" SYSTEM_PACKAGE_TARGET "WrapSystemHarfbuzz::WrapSystemHarfbuzz" - USE_BUNDLED_PACKAGE "${_qt_wrap_use_bundled}" ) diff --git a/cmake/FindWrapPCRE2.cmake b/cmake/FindWrapPCRE2.cmake index fec46f36b0..08e12163ed 100644 --- a/cmake/FindWrapPCRE2.cmake +++ b/cmake/FindWrapPCRE2.cmake @@ -1,17 +1,11 @@ include(QtFindWrapHelper NO_POLICY_SCOPE) -set(_qt_wrap_use_bundled FALSE) -if(QT_FEATURE_pcre2 AND NOT QT_FEATURE_system_pcre2) - set(_qt_wrap_use_bundled TRUE) -endif() - qt_find_package_system_or_bundled(wrap_pcre2 FRIENDLY_PACKAGE_NAME "PCRE2" WRAP_PACKAGE_TARGET "WrapPCRE2::WrapPCRE2" WRAP_PACKAGE_FOUND_VAR_NAME "WrapPCRE2_FOUND" - BUNDLED_PACKAGE_NAME "Qt6BundledPcre2" - BUNDLED_PACKAGE_TARGET "Qt6::BundledPcre2" + BUNDLED_PACKAGE_NAME "BundledPcre2" + BUNDLED_PACKAGE_TARGET "BundledPcre2" SYSTEM_PACKAGE_NAME "WrapSystemPCRE2" SYSTEM_PACKAGE_TARGET "WrapSystemPCRE2::WrapSystemPCRE2" - USE_BUNDLED_PACKAGE "${_qt_wrap_use_bundled}" ) diff --git a/cmake/FindWrapPNG.cmake b/cmake/FindWrapPNG.cmake index d9e7aa539b..55bfbdcffd 100644 --- a/cmake/FindWrapPNG.cmake +++ b/cmake/FindWrapPNG.cmake @@ -1,17 +1,11 @@ include(QtFindWrapHelper NO_POLICY_SCOPE) -set(_qt_wrap_use_bundled FALSE) -if(QT_FEATURE_png AND NOT QT_FEATURE_system_png) - set(_qt_wrap_use_bundled TRUE) -endif() - qt_find_package_system_or_bundled(wrap_png FRIENDLY_PACKAGE_NAME "PNG" WRAP_PACKAGE_TARGET "WrapPNG::WrapPNG" WRAP_PACKAGE_FOUND_VAR_NAME "WrapPNG_FOUND" - BUNDLED_PACKAGE_NAME "Qt6BundledLibpng" - BUNDLED_PACKAGE_TARGET "Qt6::BundledLibpng" + BUNDLED_PACKAGE_NAME "BundledLibpng" + BUNDLED_PACKAGE_TARGET "BundledLibpng" SYSTEM_PACKAGE_NAME "WrapSystemPNG" SYSTEM_PACKAGE_TARGET "WrapSystemPNG::WrapSystemPNG" - USE_BUNDLED_PACKAGE "${_qt_wrap_use_bundled}" ) diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake index 31e0512732..a788392bad 100644 --- a/cmake/QtBaseGlobalTargets.cmake +++ b/cmake/QtBaseGlobalTargets.cmake @@ -230,6 +230,7 @@ qt_copy_or_install(FILES cmake/QtCompilerOptimization.cmake cmake/QtFeature.cmake cmake/QtFindWrapHelper.cmake + cmake/QtFindWrapConfigExtra.cmake.in cmake/QtPlatformSupport.cmake cmake/QtPlatformAndroid.cmake cmake/QtPostProcess.cmake diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 90306a44c8..e62f5aa196 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -3163,6 +3163,28 @@ function(qt_add_3rdparty_library target) endif() endfunction() +function(qt_install_3rdparty_library_wrap_config_extra_file target) + if(TARGET "${target}") + set(use_bundled "ON") + else() + set(use_bundled "OFF") + endif() + + set(QT_USE_BUNDLED_${target} "${use_bundled}" CACHE BOOL "" FORCE) + set(extra_cmake_code "set(QT_USE_BUNDLED_${target} ${use_bundled} CACHE BOOL \"\" FORCE)") + configure_file( + "${QT_CMAKE_DIR}/QtFindWrapConfigExtra.cmake.in" + "${QT_CONFIG_BUILD_DIR}/${INSTALL_CMAKE_NAMESPACE}/FindWrap${target}ConfigExtra.cmake" + @ONLY + ) + + qt_install(FILES + "${QT_CONFIG_BUILD_DIR}/${INSTALL_CMAKE_NAMESPACE}/FindWrap${target}ConfigExtra.cmake" + DESTINATION "${QT_CONFIG_INSTALL_DIR}/${INSTALL_CMAKE_NAMESPACE}" + COMPONENT Devel + ) +endfunction() + function(qt_get_tool_cmake_configuration out_var) qt_get_main_cmake_configuration("${out_var}") string(TOUPPER "${${out_var}}" upper_config) diff --git a/cmake/QtFindWrapConfigExtra.cmake.in b/cmake/QtFindWrapConfigExtra.cmake.in new file mode 100644 index 0000000000..6ecf43512c --- /dev/null +++ b/cmake/QtFindWrapConfigExtra.cmake.in @@ -0,0 +1 @@ +@extra_cmake_code@ diff --git a/cmake/QtFindWrapHelper.cmake b/cmake/QtFindWrapHelper.cmake index cb6d19600b..f536df99e1 100644 --- a/cmake/QtFindWrapHelper.cmake +++ b/cmake/QtFindWrapHelper.cmake @@ -19,7 +19,6 @@ macro(qt_find_package_system_or_bundled _unique_prefix) BUNDLED_PACKAGE_TARGET SYSTEM_PACKAGE_NAME SYSTEM_PACKAGE_TARGET - USE_BUNDLED_PACKAGE ) set(_multioptions "") @@ -36,11 +35,20 @@ macro(qt_find_package_system_or_bundled _unique_prefix) set(${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_FOUND_VAR_NAME} OFF) - if(_qfwrap_${_unique_prefix}_USE_BUNDLED_PACKAGE) + include("FindWrap${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}ConfigExtra" OPTIONAL) + + if(NOT DEFINED "QT_USE_BUNDLED_${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}") + message(FATAL_ERROR + "Can't find cache variable " + "QT_USE_BUNDLED_${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET} " + "to decide whether to use bundled or system library.") + endif() + + if("${QT_USE_BUNDLED_${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}}") set(${_unique_prefix}_qt_package_name_to_use - "${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_NAME}") + "Qt6${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_NAME}") set(${_unique_prefix}_qt_package_target_to_use - "${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}") + "Qt6::${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}") set(${_unique_prefix}_qt_package_success_message "Using Qt bundled ${_qfwrap_${_unique_prefix}_FRIENDLY_PACKAGE_NAME}.") set(${_unique_prefix}_qt_package_type "bundled") @@ -69,6 +77,6 @@ macro(qt_find_package_system_or_bundled _unique_prefix) INTERFACE_QT_3RD_PARTY_PACKAGE_TYPE "${${_unique_prefix}_qt_package_type}") elseif(${_unique_prefix}_qt_package_type STREQUAL "bundled") - message(FATAL_ERROR "Can't find ${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_TARGET}.") + message(FATAL_ERROR "Can't find ${${_unique_prefix}_qt_package_target_to_use}.") endif() endmacro() diff --git a/src/3rdparty/CMakeLists.txt b/src/3rdparty/CMakeLists.txt index f9a6e7c68b..d0dbb8aef5 100644 --- a/src/3rdparty/CMakeLists.txt +++ b/src/3rdparty/CMakeLists.txt @@ -6,18 +6,22 @@ add_subdirectory(double-conversion) if(QT_FEATURE_png AND NOT QT_FEATURE_system_png) add_subdirectory(libpng) endif() +qt_install_3rdparty_library_wrap_config_extra_file(BundledLibpng) if(QT_FEATURE_freetype AND NOT QT_FEATURE_system_freetype) add_subdirectory(freetype) endif() +qt_install_3rdparty_library_wrap_config_extra_file(BundledFreetype) if(QT_FEATURE_harfbuzz AND NOT QT_FEATURE_system_harfbuzz) add_subdirectory(harfbuzz-ng) endif() +qt_install_3rdparty_library_wrap_config_extra_file(BundledHarfbuzz) if(QT_FEATURE_regularexpression AND NOT QT_FEATURE_system_pcre2) add_subdirectory(pcre2) endif() +qt_install_3rdparty_library_wrap_config_extra_file(BundledPcre2) if (ANDROID) add_subdirectory(gradle)