qt5base-lts/cmake/QtPluginDependencies.cmake.in
Alexandru Croitor 81ea5f1906 CMake: Prepare ground work for static Qml plugins importing
For qt_import_qml_plugins to work, it needs to have access to the Qml
plugin targets by the time find_package(Qt6Qml) is called.

To do that, we modify the generation of Qml plugin Config, Targets and
Dependencies files to go into a special 'QmlPlugins' subfolder of the
Qml package.

The Qml package will then GLOB include all the Config files in that
folder, to make them available whenever find_package(Qt6Qml) is
called.

This is similar to how the Qt plugins were glob included in the CMake
integration of Qt 5.15. In fact that glob including is missing in Qt 6
for regular Qt plugins, and should be implemented in a following
change. Currently the Qt Plugins config files that are included are
hardcoded to the list of known plugins at Qt configuration time.

As a drive-by to make this all work, the naming of the various Config
and Dependencies files has been normalized to include the Qt6 prefix.
This is done for both regular Qt plugins and Qml plugins.

Task-number: QTBUG-85961
Change-Id: Id20da72337ca2945fa330ea6fb43535e44a83292
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-08-12 14:20:40 +02:00

43 lines
1.2 KiB
CMake

# note: _third_party_deps example: "ICU\\;1.0\\;i18n uc data;ZLIB\\;\\;"
set(_third_party_deps "@third_party_deps@")
foreach(_target_dep ${_third_party_deps})
list(GET _target_dep 0 pkg)
list(GET _target_dep 1 version)
list(GET _target_dep 2 components)
set(find_package_args "${pkg}")
if(version)
list(APPEND find_package_args "${version}")
endif()
if(components)
string(REPLACE " " ";" components "${components}")
find_dependency(${find_package_args} COMPONENTS ${components})
else()
find_dependency(${find_package_args})
endif()
if (NOT ${pkg}_FOUND)
set(@target@_FOUND FALSE)
return()
endif()
endforeach()
# note: target_deps example: "Qt6Core\;5.12.0;Qt6Gui\;5.12.0"
set(_target_deps "@target_deps@")
foreach(_target_dep ${_target_deps})
list(GET _target_dep 0 pkg)
list(GET _target_dep 1 version)
if (NOT ${pkg}_FOUND)
find_dependency(${pkg} ${version}
PATHS @find_dependency_paths@ ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH
)
endif()
if (NOT ${pkg}_FOUND)
set(@target@_FOUND FALSE)
return()
endif()
endforeach()