qt5base-lts/cmake/QtModuleDependencies.cmake.in
Simon Hausmann 6290efc4eb Fix building against an installed static Qt
For ICU we have multiple components, and ICU becomes a public dependency
to QtCore.

When storing the INTERFACE_QT_PACKAGE_COMPONENTS property, make sure to
store the entire list of components, not just the first component -- by
turning the semi-colon separated list into a space separated list.

When processing the components at find_dependency time, we need to
reverse that and pass COMPONENTS directly to ensure a correct parameter
expansion.

Change-Id: I24a0708520e7d5fba039395a151034aee4d4c0e2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-06-25 13:38:33 +00:00

77 lines
2.4 KiB
CMake

# Save old module path, and append a new path that points to the copied over Find modules
# so that find_dependency() can find the third party packages.
set(old_CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}")
list(APPEND CMAKE_MODULE_PATH "${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@")
list(APPEND CMAKE_MODULE_PATH "${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@/3rdparty/extra-cmake-modules/find-modules")
list(APPEND CMAKE_MODULE_PATH "${_import_prefix}/../@INSTALL_CMAKE_NAMESPACE@/3rdparty/kwin")
# 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(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
return()
endif()
endforeach()
# Restore old module path.
set(CMAKE_MODULE_PATH "${old_CMAKE_MODULE_PATH}")
# Find Qt tool package.
set(_tool_deps "@main_module_tool_deps@")
# The tools do not provide linkage targets but executables, where a mismatch
# between 32-bit target and 64-bit host does not matter.
set(BACKUP_CMAKE_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}")
set(CMAKE_SIZEOF_VOID_P "")
foreach(_target_dep ${_tool_deps})
list(GET _target_dep 0 pkg)
list(GET _target_dep 1 version)
find_dependency(${pkg} ${version})
if (NOT ${pkg}_FOUND)
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
set(CMAKE_SIZEOF_VOID_P "${BACKUP_CMAKE_SIZEOF_VOID_P}")
return()
endif()
endforeach()
set(CMAKE_SIZEOF_VOID_P "${BACKUP_CMAKE_SIZEOF_VOID_P}")
# 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 "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH
)
endif()
if (NOT ${pkg}_FOUND)
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
return()
endif()
endforeach()