summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2020-02-14 14:53:28 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2020-02-25 15:43:16 +0100
commit26059d1b9b84bbaaa6c5a50a7dea88ffa9051c5a (patch)
tree8fb5694a33a28771f241db97c8b777ca0f5b9156 /cmake
parent1b474118326d0cc7a69b20d22d1e52d9ed42c07e (diff)
CMake: Allow building bundled 3rd party libraries in qtbase
A few things are needed to accomplish that: - the python scripts do not ignore certain system_foo features anymore (it is a hardcoded list for now just to be safe) - configurejson2cmake now outputs qt_find_package(WrapSystemFoo) calls for bundled libraries (see below) - the harfbuzz .pro file is modified to accommodate pro2cmake not being able to correctly parse some conditional scopes - the freetype .pro file is modified to make sure linking of the library succeeds without duplicate symbol errors, which qmake doesn't encounter due to magical exclusion of cpp files that are included in other cpp files (presumably for include moc_foo.cpp support) - feature evaluation for Core, Gui, Network now happens in the qtbase/src directory, so that bundled libraries can be conditionally built - for each bundled library there are now two FindWrap scripts: - FindWrapSystemFoo which finds an installed library in the system - FindWrapFoo which either uses the system installed library or the built bundled one depending on a condition - projects that intend to use bundled libraries need to link against WrapFoo::WrapFoo instead of WrapSystemFoo::WrapSystemFoo targets (this is handled by pro2cmake). Unfortunately manually added qt_find_package(WrapFoo) calls might still be needed as is the case for WrapFreetype and others. - a new cmake/QtFindWrapHelper.cmake file is added that provides a macro to simplify creation of WrapFoo targets that link against a bundled or system library. The implementation is fairly ugly due to CMake macro constraints, but it was deemed better than copy-pasting a bunch of almost identical code across all FindWrapFoo.cmake files. - a qtzlib header-only module is now created when using bundled zlib, to provide public syncqt created headers for consumers that need them. These are projects that have 'QT_PRIVATE += zlib-private' in their .pro files (e.g. qtimageformats, qtlocation, qt3d, etc.) This is unfortunately needed due to QtNetwork using zlib types in its private C++ API. The change includes support for building the following bundled libraries: - zlib - libpng - libjpeg - Freetype - Harfbuzz-ng - PCRE2 The following 3rd party libraries are still using an old implementation within the CMake build system, and should be migrated to the new one in the near future: - double-conversion - Old harfbuzz The are a few libraries that are not yet ported: - system-sqlite - systemxcb - maybe others Among other things, this change allows building qtbase on Windows without requiring vcpkg. Task-number: QTBUG-82167 Change-Id: I35ecea0d832f66c1943c82e618de4a51440971a5 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindWrapFreetype.cmake44
-rw-r--r--cmake/FindWrapHarfbuzz.cmake56
-rw-r--r--cmake/FindWrapPCRE2.cmake36
-rw-r--r--cmake/FindWrapPNG.cmake17
-rw-r--r--cmake/FindWrapSystemFreetype.cmake35
-rw-r--r--cmake/FindWrapSystemHarfbuzz.cmake45
-rw-r--r--cmake/FindWrapSystemPCRE2.cmake23
-rw-r--r--cmake/FindWrapSystemPNG.cmake27
-rw-r--r--cmake/QtBaseGlobalTargets.cmake1
-rw-r--r--cmake/QtFindWrapHelper.cmake74
-rw-r--r--cmake/QtPostProcess.cmake23
11 files changed, 287 insertions, 94 deletions
diff --git a/cmake/FindWrapFreetype.cmake b/cmake/FindWrapFreetype.cmake
index ec7d2a8d24..3f8317be69 100644
--- a/cmake/FindWrapFreetype.cmake
+++ b/cmake/FindWrapFreetype.cmake
@@ -1,33 +1,17 @@
-# We can't create the same interface imported target multiple times, CMake will complain if we do
-# that. This can happen if the find_package call is done in multiple different subdirectories.
-if(TARGET WrapFreetype::WrapFreetype)
- set(WrapFreetype_FOUND ON)
- return()
-endif()
-
-set(WrapFreetype_FOUND OFF)
-
-# Hunter has the package named freetype, but exports the Freetype::Freetype target as upstream
-# First try the CONFIG package, and afterwards the MODULE if not found
+include(QtFindWrapHelper NO_POLICY_SCOPE)
-find_package(Freetype CONFIG NAMES Freetype freetype QUIET)
-if(NOT Freetype_FOUND)
- find_package(Freetype MODULE)
+set(_qt_wrap_use_bundled FALSE)
+if(QT_FEATURE_freetype AND NOT QT_FEATURE_system_freetype)
+ set(_qt_wrap_use_bundled TRUE)
endif()
-if(Freetype_FOUND)
- # vcpkg defines a lower case target name, while upstream Find module defines a prefixed
- # upper case name.
- set(potential_target_names Freetype::Freetype freetype)
- foreach(target_name ${potential_target_names})
- if(TARGET ${target_name})
- set(WrapFreetype_FOUND ON)
- set(final_target_name ${target_name})
-
- add_library(WrapFreetype::WrapFreetype INTERFACE IMPORTED)
- target_link_libraries(WrapFreetype::WrapFreetype INTERFACE ${final_target_name})
-
- break()
- endif()
- endforeach()
-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"
+ 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 f7845b28bd..eac95b669d 100644
--- a/cmake/FindWrapHarfbuzz.cmake
+++ b/cmake/FindWrapHarfbuzz.cmake
@@ -1,45 +1,17 @@
-# We can't create the same interface imported target multiple times, CMake will complain if we do
-# that. This can happen if the find_package call is done in multiple different subdirectories.
-if(TARGET WrapHarfbuzz::WrapHarfbuzz)
- set(WrapHarfbuzz_FOUND ON)
- return()
-endif()
-
-set(WrapHarfbuzz_FOUND OFF)
-
-find_package(harfbuzz)
+include(QtFindWrapHelper NO_POLICY_SCOPE)
-# Gentoo has some buggy version of a harfbuzz Config file. Check if include paths are valid.
-set(__harfbuzz_target_name "harfbuzz::harfbuzz")
-if(harfbuzz_FOUND AND TARGET "${__harfbuzz_target_name}")
- get_property(__harfbuzz_include_paths TARGET "${__harfbuzz_target_name}"
- PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
- foreach(__harfbuzz_include_dir ${__harfbuzz_include_paths})
- if(NOT EXISTS "${__harfbuzz_include_dir}")
- # Must be the broken Gentoo harfbuzzConfig.cmake file. Try to use pkg-config instead.
- set(__harfbuzz_broken_config_file TRUE)
- break()
- endif()
- endforeach()
+set(_qt_wrap_use_bundled FALSE)
+if(QT_FEATURE_harfbuzz AND NOT QT_FEATURE_system_harfbuzz)
+ set(_qt_wrap_use_bundled TRUE)
endif()
-if(__harfbuzz_broken_config_file)
- find_package(PkgConfig)
-
- pkg_check_modules(harfbuzz harfbuzz IMPORTED_TARGET)
- set(__harfbuzz_target_name "PkgConfig::harfbuzz")
-
- if (NOT TARGET "${__harfbuzz_target_name}")
- set(harfbuzz_FOUND 0)
- endif()
-endif()
-
-if(TARGET "${__harfbuzz_target_name}")
- set(WrapHarfbuzz_FOUND ON)
-
- add_library(WrapHarfbuzz::WrapHarfbuzz INTERFACE IMPORTED)
- target_link_libraries(WrapHarfbuzz::WrapHarfbuzz INTERFACE ${__harfbuzz_target_name})
-endif()
-unset(__harfbuzz_target_name)
-unset(__harfbuzz_include_dir)
-unset(__harfbuzz_broken_config_file)
+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"
+ 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 08f660bdfc..fec46f36b0 100644
--- a/cmake/FindWrapPCRE2.cmake
+++ b/cmake/FindWrapPCRE2.cmake
@@ -1,23 +1,17 @@
-if(TARGET WrapPCRE2::WrapPCRE2)
- set(WrapPCRE2_FOUND TRUE)
- return()
-endif()
-
-find_package(PCRE2 CONFIG QUIET)
+include(QtFindWrapHelper NO_POLICY_SCOPE)
-if(PCRE2_FOUND AND TARGET PCRE2::pcre2-16)
- # Hunter case.
- add_library(WrapPCRE2::WrapPCRE2 INTERFACE IMPORTED)
- target_link_libraries(WrapPCRE2::WrapPCRE2 INTERFACE PCRE2::pcre2-16)
- set(WrapPCRE2_FOUND TRUE)
-else()
- find_library(PCRE2_LIBRARIES NAMES pcre2-16)
- find_path(PCRE2_INCLUDE_DIRS pcre2.h)
-
- if (PCRE2_LIBRARIES AND PCRE2_INCLUDE_DIRS)
- add_library(WrapPCRE2::WrapPCRE2 INTERFACE IMPORTED)
- target_link_libraries(WrapPCRE2::WrapPCRE2 INTERFACE ${PCRE2_LIBRARIES})
- target_include_directories(WrapPCRE2::WrapPCRE2 INTERFACE ${PCRE2_INCLUDE_DIRS})
- set(WrapPCRE2_FOUND TRUE)
- endif()
+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"
+ 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
new file mode 100644
index 0000000000..d9e7aa539b
--- /dev/null
+++ b/cmake/FindWrapPNG.cmake
@@ -0,0 +1,17 @@
+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"
+ SYSTEM_PACKAGE_NAME "WrapSystemPNG"
+ SYSTEM_PACKAGE_TARGET "WrapSystemPNG::WrapSystemPNG"
+ USE_BUNDLED_PACKAGE "${_qt_wrap_use_bundled}"
+)
diff --git a/cmake/FindWrapSystemFreetype.cmake b/cmake/FindWrapSystemFreetype.cmake
new file mode 100644
index 0000000000..d41906f949
--- /dev/null
+++ b/cmake/FindWrapSystemFreetype.cmake
@@ -0,0 +1,35 @@
+# We can't create the same interface imported target multiple times, CMake will complain if we do
+# that. This can happen if the find_package call is done in multiple different subdirectories.
+if(TARGET WrapSystemFreetype::WrapSystemFreetype)
+ set(WrapSystemFreetype_FOUND ON)
+ return()
+endif()
+
+set(WrapSystemFreetype_FOUND OFF)
+
+# Hunter has the package named freetype, but exports the Freetype::Freetype target as upstream
+# First try the CONFIG package, and afterwards the MODULE if not found
+
+find_package(Freetype CONFIG NAMES Freetype freetype QUIET)
+if(NOT Freetype_FOUND)
+ find_package(Freetype MODULE)
+endif()
+
+if(Freetype_FOUND)
+ # vcpkg defines a lower case target name, while upstream Find module defines a prefixed
+ # upper case name.
+ set(potential_target_names Freetype::Freetype freetype)
+ foreach(target_name ${potential_target_names})
+ if(TARGET ${target_name})
+ set(WrapSystemFreetype_FOUND ON)
+ set(final_target_name ${target_name})
+
+ add_library(WrapSystemFreetype::WrapSystemFreetype INTERFACE IMPORTED)
+ target_link_libraries(WrapSystemFreetype::WrapSystemFreetype INTERFACE
+ ${final_target_name})
+
+ break()
+ endif()
+ endforeach()
+endif()
+
diff --git a/cmake/FindWrapSystemHarfbuzz.cmake b/cmake/FindWrapSystemHarfbuzz.cmake
new file mode 100644
index 0000000000..6829dc1430
--- /dev/null
+++ b/cmake/FindWrapSystemHarfbuzz.cmake
@@ -0,0 +1,45 @@
+# We can't create the same interface imported target multiple times, CMake will complain if we do
+# that. This can happen if the find_package call is done in multiple different subdirectories.
+if(TARGET WrapSystemHarfbuzz::WrapSystemHarfbuzz)
+ set(WrapSystemHarfbuzz_FOUND ON)
+ return()
+endif()
+
+set(WrapSystemHarfbuzz_FOUND OFF)
+
+find_package(harfbuzz)
+
+# Gentoo has some buggy version of a harfbuzz Config file. Check if include paths are valid.
+set(__harfbuzz_target_name "harfbuzz::harfbuzz")
+if(harfbuzz_FOUND AND TARGET "${__harfbuzz_target_name}")
+ get_property(__harfbuzz_include_paths TARGET "${__harfbuzz_target_name}"
+ PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+ foreach(__harfbuzz_include_dir ${__harfbuzz_include_paths})
+ if(NOT EXISTS "${__harfbuzz_include_dir}")
+ # Must be the broken Gentoo harfbuzzConfig.cmake file. Try to use pkg-config instead.
+ set(__harfbuzz_broken_config_file TRUE)
+ break()
+ endif()
+ endforeach()
+endif()
+
+if(__harfbuzz_broken_config_file)
+ find_package(PkgConfig)
+
+ pkg_check_modules(harfbuzz harfbuzz IMPORTED_TARGET)
+ set(__harfbuzz_target_name "PkgConfig::harfbuzz")
+
+ if (NOT TARGET "${__harfbuzz_target_name}")
+ set(harfbuzz_FOUND 0)
+ endif()
+endif()
+
+if(TARGET "${__harfbuzz_target_name}")
+ set(WrapSystemHarfbuzz_FOUND ON)
+
+ add_library(WrapSystemHarfbuzz::WrapSystemHarfbuzz INTERFACE IMPORTED)
+ target_link_libraries(WrapSystemHarfbuzz::WrapSystemHarfbuzz INTERFACE ${__harfbuzz_target_name})
+endif()
+unset(__harfbuzz_target_name)
+unset(__harfbuzz_include_dir)
+unset(__harfbuzz_broken_config_file)
diff --git a/cmake/FindWrapSystemPCRE2.cmake b/cmake/FindWrapSystemPCRE2.cmake
new file mode 100644
index 0000000000..31379ecc63
--- /dev/null
+++ b/cmake/FindWrapSystemPCRE2.cmake
@@ -0,0 +1,23 @@
+if(TARGET WrapSystemPCRE2::WrapSystemPCRE2)
+ set(WrapSystemPCRE2_FOUND TRUE)
+ return()
+endif()
+
+find_package(PCRE2 CONFIG QUIET)
+
+if(PCRE2_FOUND AND TARGET PCRE2::pcre2-16)
+ # Hunter case.
+ add_library(WrapSystemPCRE2::WrapSystemPCRE2 INTERFACE IMPORTED)
+ target_link_libraries(WrapSystemPCRE2::WrapSystemPCRE2 INTERFACE PCRE2::pcre2-16)
+ set(WrapSystemPCRE2_FOUND TRUE)
+else()
+ find_library(PCRE2_LIBRARIES NAMES pcre2-16)
+ find_path(PCRE2_INCLUDE_DIRS pcre2.h)
+
+ if (PCRE2_LIBRARIES AND PCRE2_INCLUDE_DIRS)
+ add_library(WrapSystemPCRE2::WrapSystemPCRE2 INTERFACE IMPORTED)
+ target_link_libraries(WrapSystemPCRE2::WrapSystemPCRE2 INTERFACE ${PCRE2_LIBRARIES})
+ target_include_directories(WrapSystemPCRE2::WrapSystemPCRE2 INTERFACE ${PCRE2_INCLUDE_DIRS})
+ set(WrapSystemPCRE2_FOUND TRUE)
+ endif()
+endif()
diff --git a/cmake/FindWrapSystemPNG.cmake b/cmake/FindWrapSystemPNG.cmake
new file mode 100644
index 0000000000..cff160ad04
--- /dev/null
+++ b/cmake/FindWrapSystemPNG.cmake
@@ -0,0 +1,27 @@
+# We can't create the same interface imported target multiple times, CMake will complain if we do
+# that. This can happen if the find_package call is done in multiple different subdirectories.
+if(TARGET WrapSystemPNG::WrapSystemPNG)
+ set(WrapSystemPNG_FOUND ON)
+ return()
+endif()
+
+set(WrapSystemPNG_FOUND OFF)
+
+find_package(PNG QUIET)
+
+if(PNG_FOUND)
+ set(potential_target_names PNG::PNG)
+ foreach(target_name ${potential_target_names})
+ if(TARGET ${target_name})
+ set(WrapSystemPNG_FOUND ON)
+ set(final_target_name ${target_name})
+
+ add_library(WrapSystemPNG::WrapSystemPNG INTERFACE IMPORTED)
+ target_link_libraries(WrapSystemPNG::WrapSystemPNG INTERFACE
+ ${final_target_name})
+
+ break()
+ endif()
+ endforeach()
+endif()
+
diff --git a/cmake/QtBaseGlobalTargets.cmake b/cmake/QtBaseGlobalTargets.cmake
index 182d2986f0..31e0512732 100644
--- a/cmake/QtBaseGlobalTargets.cmake
+++ b/cmake/QtBaseGlobalTargets.cmake
@@ -229,6 +229,7 @@ qt_copy_or_install(FILES
cmake/QtCompilerFlags.cmake
cmake/QtCompilerOptimization.cmake
cmake/QtFeature.cmake
+ cmake/QtFindWrapHelper.cmake
cmake/QtPlatformSupport.cmake
cmake/QtPlatformAndroid.cmake
cmake/QtPostProcess.cmake
diff --git a/cmake/QtFindWrapHelper.cmake b/cmake/QtFindWrapHelper.cmake
new file mode 100644
index 0000000000..cb6d19600b
--- /dev/null
+++ b/cmake/QtFindWrapHelper.cmake
@@ -0,0 +1,74 @@
+# Creates an imported wrapper target that links against either a Qt bundled package
+# or a system package.
+#
+# Used for consuming 3rd party libraries in Qt.
+#
+# Example: Creates WrapFreetype::WrapFreetype linking against either
+# Qt6::BundledFreetype or WrapSystemFreetype::WrapSystemFreetype.
+#
+# The implementation has to use a unique prefix in each variable, otherwise when WrapFreetype
+# find_package()s WrapPNG, the nested call would override the parent call variables, due to macros
+# using the same scope.
+macro(qt_find_package_system_or_bundled _unique_prefix)
+ set(_flags "")
+ set(_options
+ FRIENDLY_PACKAGE_NAME
+ WRAP_PACKAGE_TARGET
+ WRAP_PACKAGE_FOUND_VAR_NAME
+ BUNDLED_PACKAGE_NAME
+ BUNDLED_PACKAGE_TARGET
+ SYSTEM_PACKAGE_NAME
+ SYSTEM_PACKAGE_TARGET
+ USE_BUNDLED_PACKAGE
+ )
+ set(_multioptions "")
+
+ cmake_parse_arguments("_qfwrap_${_unique_prefix}"
+ "${_flags}" "${_options}" "${_multioptions}" ${ARGN})
+
+ # We can't create the same interface imported target multiple times, CMake will complain if we
+ # do that. This can happen if the find_package call is done in multiple different
+ # subdirectories.
+ if(TARGET "${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_TARGET}")
+ set(${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_FOUND_VAR_NAME} ON)
+ return()
+ endif()
+
+ set(${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_FOUND_VAR_NAME} OFF)
+
+ if(_qfwrap_${_unique_prefix}_USE_BUNDLED_PACKAGE)
+ set(${_unique_prefix}_qt_package_name_to_use
+ "${_qfwrap_${_unique_prefix}_BUNDLED_PACKAGE_NAME}")
+ set(${_unique_prefix}_qt_package_target_to_use
+ "${_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")
+ else()
+ set(${_unique_prefix}_qt_package_name_to_use
+ "${_qfwrap_${_unique_prefix}_SYSTEM_PACKAGE_NAME}")
+ set(${_unique_prefix}_qt_package_target_to_use
+ "${_qfwrap_${_unique_prefix}_SYSTEM_PACKAGE_TARGET}")
+ set(${_unique_prefix}_qt_package_success_message
+ "Using system ${_qfwrap_${_unique_prefix}_FRIENDLY_PACKAGE_NAME}.")
+ set(${_unique_prefix}_qt_package_type "system")
+ endif()
+
+ if(NOT TARGET "${${_unique_prefix}_qt_package_target_to_use}")
+ find_package("${${_unique_prefix}_qt_package_name_to_use}")
+ endif()
+
+ if(TARGET "${${_unique_prefix}_qt_package_target_to_use}")
+ set(${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_FOUND_VAR_NAME} ON)
+ message(STATUS "${${_unique_prefix}_qt_package_success_message}")
+ add_library("${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_TARGET}" INTERFACE IMPORTED)
+ target_link_libraries("${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_TARGET}"
+ INTERFACE
+ ${${_unique_prefix}_qt_package_target_to_use})
+ set_target_properties("${_qfwrap_${_unique_prefix}_WRAP_PACKAGE_TARGET}" PROPERTIES
+ 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}.")
+ endif()
+endmacro()
diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake
index 19cd4b699b..e8e6c2b3aa 100644
--- a/cmake/QtPostProcess.cmake
+++ b/cmake/QtPostProcess.cmake
@@ -371,7 +371,28 @@ function(qt_internal_create_config_file_for_standalone_tests)
${QT_CONFIG_INSTALL_DIR}
"${INSTALL_CMAKE_NAMESPACE}BuildInternals" "${standalone_tests_config_dir}")
- list(JOIN QT_REPO_KNOWN_MODULES " " QT_REPO_KNOWN_MODULES_STRING)
+ # Filter out bundled system libraries. Otherwise when looking for their dependencies
+ # (like PNG for Freetype) FindWrapPNG is searched for during configuration of
+ # standalone tests, and it can happen that Core or Gui features are not
+ # imported early enough, which means FindWrapPNG will try to find a system PNG library instead
+ # of the bundled one.
+ set(modules)
+ foreach(m ${QT_REPO_KNOWN_MODULES})
+ get_target_property(target_type "${m}" TYPE)
+
+ # Interface libraries are never bundled system libraries (hopefully).
+ if(target_type STREQUAL "INTERFACE_LIBRARY")
+ list(APPEND modules "${m}")
+ continue()
+ endif()
+
+ get_target_property(is_3rd_party "${m}" QT_MODULE_IS_3RDPARTY_LIBRARY)
+ if(NOT is_3rd_party)
+ list(APPEND modules "${m}")
+ endif()
+ endforeach()
+
+ list(JOIN modules " " QT_REPO_KNOWN_MODULES_STRING)
string(STRIP "${QT_REPO_KNOWN_MODULES_STRING}" QT_REPO_KNOWN_MODULES_STRING)
# Skip generating and installing file if no modules were built. This make sure not to install