CMake: Use namespaced variables in Qt6*Dependencies.cmake

Pick-to: 6.2 6.1
Change-Id: I166988020cfd9750a4d58e519742215d0c03ad3e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Li Xinwei 2021-07-23 15:37:14 +08:00
parent 1ae4c56ceb
commit bd594f9457
5 changed files with 98 additions and 99 deletions

View File

@ -1,50 +1,49 @@
set(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCIES_FOUND FALSE)
# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;"
set(_third_party_deps "@third_party_deps@")
set(__qt_third_party_deps "@third_party_deps@")
@third_party_extra@
foreach(_target_dep ${_third_party_deps})
list(GET _target_dep 0 pkg)
list(GET _target_dep 1 is_optional)
list(GET _target_dep 2 version)
list(GET _target_dep 3 components)
list(GET _target_dep 4 optional_components)
set(find_package_args "${pkg}")
if(version)
list(APPEND find_package_args "${version}")
foreach(__qt_target_dep ${__qt_third_party_deps})
list(GET __qt_target_dep 0 __qt_pkg)
list(GET __qt_target_dep 1 __qt_is_optional)
list(GET __qt_target_dep 2 __qt_version)
list(GET __qt_target_dep 3 __qt_components)
list(GET __qt_target_dep 4 __qt_optional_components)
set(__qt_find_package_args "${__qt_pkg}")
if(__qt_version)
list(APPEND __qt_find_package_args "${__qt_version}")
endif()
if(components)
string(REPLACE " " ";" components "${components}")
list(APPEND find_package_args COMPONENTS ${components})
if(__qt_components)
string(REPLACE " " ";" __qt_components "${__qt_components}")
list(APPEND __qt_find_package_args COMPONENTS ${__qt_components})
endif()
if(optional_components)
string(REPLACE " " ";" optional_components "${optional_components}")
list(APPEND find_package_args OPTIONAL_COMPONENTS ${optional_components})
if(__qt_optional_components)
string(REPLACE " " ";" __qt_optional_components "${__qt_optional_components}")
list(APPEND __qt_find_package_args OPTIONAL_COMPONENTS ${__qt_optional_components})
endif()
# Already build an error message, because find_dependency calls return() on failure.
set(__@INSTALL_CMAKE_NAMESPACE@_message "\nPackage: ${pkg}")
if(version)
string(APPEND __@INSTALL_CMAKE_NAMESPACE@_message "\nVersion: ${version}")
set(__qt_message "\nPackage: ${__qt_pkg}")
if(__qt_version)
string(APPEND __qt_message "\nVersion: ${__qt_version}")
endif()
if(components)
string(APPEND __@INSTALL_CMAKE_NAMESPACE@_message "\nComponents: ${components}")
if(__qt_components)
string(APPEND __qt_message "\nComponents: ${__qt_components}")
endif()
if(optional_components)
string(APPEND __@INSTALL_CMAKE_NAMESPACE@_message "\nComponents: ${optional_components}")
if(__qt_optional_components)
string(APPEND __qt_message "\nComponents: ${__qt_optional_components}")
endif()
set(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCY_NOT_FOUND_MESSAGE
"${__@INSTALL_CMAKE_NAMESPACE@_message}")
set(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCY_NOT_FOUND_MESSAGE "${__qt_message}")
if(is_optional)
if(__qt_is_optional)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
list(APPEND __qt_find_package_args QUIET)
endif()
find_package(${find_package_args})
find_package(${__qt_find_package_args})
else()
find_dependency(${find_package_args})
find_dependency(${__qt_find_package_args})
endif()
endforeach()

View File

@ -15,39 +15,39 @@ find_dependency(@INSTALL_CMAKE_NAMESPACE@ @PROJECT_VERSION@
)
# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;"
set(_third_party_deps "@third_party_deps@")
set(__qt_@target@_third_party_deps "@third_party_deps@")
foreach(_target_dep ${_third_party_deps})
list(GET _target_dep 0 pkg)
list(GET _target_dep 1 is_optional)
list(GET _target_dep 2 version)
list(GET _target_dep 3 components)
list(GET _target_dep 4 optional_components)
set(find_package_args "${pkg}")
if(version)
list(APPEND find_package_args "${version}")
foreach(__qt_@target@_target_dep ${__qt_@target@_third_party_deps})
list(GET __qt_@target@_target_dep 0 __qt_@target@_pkg)
list(GET __qt_@target@_target_dep 1 __qt_@target@_is_optional)
list(GET __qt_@target@_target_dep 2 __qt_@target@_version)
list(GET __qt_@target@_target_dep 3 __qt_@target@_components)
list(GET __qt_@target@_target_dep 4 __qt_@target@_optional_components)
set(__qt_@target@_find_package_args "${__qt_@target@_pkg}")
if(__qt_@target@_version)
list(APPEND __qt_@target@_find_package_args "${__qt_@target@_version}")
endif()
if(components)
string(REPLACE " " ";" components "${components}")
list(APPEND find_package_args COMPONENTS ${components})
if(__qt_@target@_components)
string(REPLACE " " ";" __qt_@target@_components "${__qt_@target@_components}")
list(APPEND __qt_@target@_find_package_args COMPONENTS ${__qt_@target@_components})
endif()
if(optional_components)
string(REPLACE " " ";" optional_components "${optional_components}")
list(APPEND find_package_args OPTIONAL_COMPONENTS ${optional_components})
if(__qt_@target@_optional_components)
string(REPLACE " " ";" __qt_@target@_optional_components "${__qt_@target@_optional_components}")
list(APPEND __qt_@target@_find_package_args OPTIONAL_COMPONENTS ${__qt_@target@_optional_components})
endif()
if(is_optional)
if(__qt_@target@_is_optional)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
list(APPEND __qt_@target@_find_package_args QUIET)
endif()
find_package(${find_package_args})
find_package(${__qt_@target@_find_package_args})
else()
find_dependency(${find_package_args})
find_dependency(${__qt_@target@_find_package_args})
endif()
endforeach()
# Find Qt tool package.
set(_tool_deps "@main_module_tool_deps@")
set(__qt_@target@_tool_deps "@main_module_tool_deps@")
if(NOT "${QT_HOST_PATH}" STREQUAL "")
# Make sure that the tools find the host tools first
@ -57,23 +57,23 @@ if(NOT "${QT_HOST_PATH}" STREQUAL "")
list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_HOST_PATH}")
endif()
foreach(_target_dep ${_tool_deps})
list(GET _target_dep 0 pkg)
list(GET _target_dep 1 version)
foreach(__qt_@target@_target_dep ${__qt_@target@_tool_deps})
list(GET __qt_@target@_target_dep 0 __qt_@target@_pkg)
list(GET __qt_@target@_target_dep 1 __qt_@target@_version)
unset(find_package_args)
unset(__qt_@target@_find_package_args)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
list(APPEND __qt_@target@_find_package_args QUIET)
endif()
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
list(APPEND find_package_args REQUIRED)
list(APPEND __qt_@target@_find_package_args REQUIRED)
endif()
find_package(${pkg} ${version} ${find_package_args}
find_package(${__qt_@target@_pkg} ${__qt_@target@_version} ${__qt_@target@_find_package_args}
PATHS
${_qt_additional_packages_prefix_path}
${_qt_additional_packages_prefix_path_env}
)
if (NOT ${pkg}_FOUND)
if (NOT ${__qt_@target@_pkg}_FOUND)
if(NOT "${QT_HOST_PATH}" STREQUAL "")
set(CMAKE_PREFIX_PATH ${BACKUP_@target@_CMAKE_PREFIX_PATH})
set(CMAKE_FIND_ROOT_PATH ${BACKUP_@target@_CMAKE_FIND_ROOT_PATH})
@ -87,9 +87,9 @@ if(NOT "${QT_HOST_PATH}" STREQUAL "")
endif()
# note: target_deps example: "Qt6Core\;5.12.0;Qt6Gui\;5.12.0"
set(_@target@_target_deps "@target_deps@")
set(_@target@_find_dependency_paths "${CMAKE_CURRENT_LIST_DIR}/..")
_qt_internal_find_dependencies(_@target@_target_deps _@target@_find_dependency_paths)
set(__qt_@target@_target_deps "@target_deps@")
set(__qt_@target@_find_dependency_paths "${CMAKE_CURRENT_LIST_DIR}/..")
_qt_internal_find_dependencies(__qt_@target@_target_deps __qt_@target@_find_dependency_paths)
set(_@QT_CMAKE_EXPORT_NAMESPACE@@target@_MODULE_DEPENDENCIES "@qt_module_dependencies@")
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND TRUE)

View File

@ -1,12 +1,12 @@
# Find "ModuleTools" dependencies, which are other ModuleTools packages.
set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE)
set(_tool_deps "@package_deps@")
foreach(_target_dep ${_tool_deps})
list(GET _target_dep 0 pkg)
list(GET _target_dep 1 version)
set(__qt_@target@_tool_deps "@package_deps@")
foreach(__qt_@target@_target_dep ${__qt_@target@_tool_deps})
list(GET __qt_@target@_target_dep 0 __qt_@target@_pkg)
list(GET __qt_@target@_target_dep 1 __qt_@target@_version)
if (NOT ${pkg}_FOUND)
find_dependency(${pkg} ${version})
if (NOT ${__qt_@target@_pkg}_FOUND)
find_dependency(${__qt_@target@_pkg} ${__qt_@target@_version})
endif()
endforeach()

View File

@ -1,34 +1,34 @@
set(@target@_FOUND FALSE)
# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;"
set(_third_party_deps "@third_party_deps@")
set(__qt_@target@_third_party_deps "@third_party_deps@")
foreach(_target_dep ${_third_party_deps})
list(GET _target_dep 0 pkg)
list(GET _target_dep 1 is_optional)
list(GET _target_dep 2 version)
list(GET _target_dep 3 components)
list(GET _target_dep 4 optional_components)
set(find_package_args "${pkg}")
if(version)
list(APPEND find_package_args "${version}")
foreach(__qt_@target@_target_dep ${__qt_@target@_third_party_deps})
list(GET __qt_@target@_target_dep 0 __qt_@target@_pkg)
list(GET __qt_@target@_target_dep 1 __qt_@target@_is_optional)
list(GET __qt_@target@_target_dep 2 __qt_@target@_version)
list(GET __qt_@target@_target_dep 3 __qt_@target@_components)
list(GET __qt_@target@_target_dep 4 __qt_@target@_optional_components)
set(__qt_@target@_find_package_args "${__qt_@target@_pkg}")
if(__qt_@target@_version)
list(APPEND __qt_@target@_find_package_args "${__qt_@target@_version}")
endif()
if(components)
string(REPLACE " " ";" components "${components}")
list(APPEND find_package_args COMPONENTS ${components})
if(__qt_@target@_components)
string(REPLACE " " ";" __qt_@target@_components "${__qt_@target@_components}")
list(APPEND __qt_@target@_find_package_args COMPONENTS ${__qt_@target@_components})
endif()
if(optional_components)
string(REPLACE " " ";" optional_components "${optional_components}")
list(APPEND find_package_args OPTIONAL_COMPONENTS ${optional_components})
if(__qt_@target@_optional_components)
string(REPLACE " " ";" __qt_@target@_optional_components "${__qt_@target@_optional_components}")
list(APPEND __qt_@target@_find_package_args OPTIONAL_COMPONENTS ${__qt_@target@_optional_components})
endif()
if(is_optional)
if(__qt_@target@_is_optional)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
list(APPEND __qt_@target@_find_package_args QUIET)
endif()
find_package(${find_package_args})
find_package(${__qt_@target@_find_package_args})
else()
find_dependency(${find_package_args})
find_dependency(${__qt_@target@_find_package_args})
endif()
endforeach()
@ -38,8 +38,8 @@ if(QT_DISABLE_NO_DEFAULT_PATH_IN_QT_PACKAGES)
endif()
# note: target_deps example: "Qt6Core\;5.12.0;Qt6Gui\;5.12.0"
set(_@target@_target_deps "@target_deps@")
set(_@target@_find_dependency_paths "@find_dependency_paths@")
_qt_internal_find_dependencies(_@target@_target_deps _@target@_find_dependency_paths)
set(__qt_@target@_target_deps "@target_deps@")
set(__qt_@target@_find_dependency_paths "@find_dependency_paths@")
_qt_internal_find_dependencies(__qt_@target@_target_deps __qt_@target@_find_dependency_paths)
set(@target@_FOUND TRUE)

View File

@ -2,18 +2,18 @@
# contain preformed dependencies. See foreach block for reference.
# The same applies for find_dependency_path_list.
macro(_qt_internal_find_dependencies target_dep_list find_dependency_path_list)
foreach(target_dep IN LISTS ${target_dep_list})
list(GET target_dep 0 pkg)
list(GET target_dep 1 version)
foreach(__qt_target_dep IN LISTS ${target_dep_list})
list(GET __qt_target_dep 0 __qt_pkg)
list(GET __qt_target_dep 1 __qt_version)
if (NOT ${pkg}_FOUND)
set(pkg_names ${pkg})
if(pkg MATCHES "(.*)Private$")
set(pkg_names "${CMAKE_MATCH_1};${pkg}")
if (NOT ${__qt_pkg}_FOUND)
set(__qt_pkg_names ${__qt_pkg})
if(__qt_pkg MATCHES "(.*)Private$")
set(__qt_pkg_names "${CMAKE_MATCH_1};${__qt_pkg}")
endif()
find_dependency(${pkg} ${version}
find_dependency(${__qt_pkg} ${__qt_version}
NAMES
${pkg_names}
${__qt_pkg_names}
PATHS
${${find_dependency_path_list}}
${_qt_additional_packages_prefix_path}