summaryrefslogtreecommitdiffstats
path: root/cmake/QtBuildRepoHelpers.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/QtBuildRepoHelpers.cmake')
-rw-r--r--cmake/QtBuildRepoHelpers.cmake65
1 files changed, 65 insertions, 0 deletions
diff --git a/cmake/QtBuildRepoHelpers.cmake b/cmake/QtBuildRepoHelpers.cmake
index 1429448c2f8..05876c1ad6d 100644
--- a/cmake/QtBuildRepoHelpers.cmake
+++ b/cmake/QtBuildRepoHelpers.cmake
@@ -724,6 +724,71 @@ macro(qt_internal_find_standalone_test_config_file)
endif()
endmacro()
+# Used inside the standalone parts config file to find all requested Qt module packages.
+# standalone_parts_args_var_name should be the var name in the outer scope that contains
+# all the arguments for this function.
+macro(qt_internal_find_standalone_parts_qt_packages standalone_parts_args_var_name)
+ set(__standalone_parts_opt_args "")
+ set(__standalone_parts_single_args "")
+ set(__standalone_parts_multi_args
+ QT_MODULE_PACKAGES
+ QT_TOOL_PACKAGES
+ )
+ cmake_parse_arguments(__standalone_parts
+ "${__standalone_parts_opt_args}"
+ "${__standalone_parts_single_args}"
+ "${__standalone_parts_multi_args}"
+ ${${standalone_parts_args_var_name}})
+
+ # Packages looked up in standalone tests Config files should use the same version as
+ # the one recorded on the Platform target.
+ qt_internal_get_package_version_of_target(Platform __standalone_parts_main_qt_package_version)
+
+ if(__standalone_parts_QT_TOOL_PACKAGES)
+ # Set up QT_HOST_PATH as an extra root path to look for the Tools packages when
+ # cross-compiling.
+ if(NOT "${QT_HOST_PATH}" STREQUAL "")
+ set(__standalone_parts_CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH})
+ set(__standalone_parts_CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH})
+ list(PREPEND CMAKE_PREFIX_PATH "${QT_HOST_PATH_CMAKE_DIR}")
+ list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_HOST_PATH}")
+ endif()
+
+ foreach(__standalone_parts_package_name IN LISTS __standalone_parts_QT_TOOL_PACKAGES)
+ find_package(${QT_CMAKE_EXPORT_NAMESPACE}${__standalone_parts_package_name}
+ "${__standalone_parts_main_qt_package_version}"
+ PATHS
+ # These come from Qt6Config.cmake
+ ${_qt_additional_packages_prefix_path}
+ ${_qt_additional_packages_prefix_path_env}
+ )
+ endforeach()
+
+ if(NOT "${QT_HOST_PATH}" STREQUAL "")
+ set(CMAKE_PREFIX_PATH ${__standalone_parts_CMAKE_PREFIX_PATH})
+ set(CMAKE_FIND_ROOT_PATH ${__standalone_parts_CMAKE_FIND_ROOT_PATH})
+ endif()
+ endif()
+
+ if(__standalone_parts_QT_MODULE_PACKAGES)
+ foreach(__standalone_parts_package_name IN LISTS __standalone_parts_QT_MODULE_PACKAGES)
+ find_package(${QT_CMAKE_EXPORT_NAMESPACE}
+ "${__standalone_parts_main_qt_package_version}"
+ COMPONENTS "${__standalone_parts_package_name}")
+ endforeach()
+ endif()
+
+ unset(__standalone_parts_opt_args)
+ unset(__standalone_parts_single_args)
+ unset(__standalone_parts_multi_args)
+ unset(__standalone_parts_QT_MODULE_PACKAGES)
+ unset(__standalone_parts_QT_TOOL_PACKAGES)
+ unset(__standalone_parts_main_qt_package_version)
+ unset(__standalone_parts_package_name)
+ unset(__standalone_parts_CMAKE_PREFIX_PATH)
+ unset(__standalone_parts_CMAKE_FIND_ROOT_PATH)
+endmacro()
+
# Used by standalone tests and standalone non-ExternalProject examples to find all installed qt
# packages.
macro(qt_internal_find_standalone_parts_config_files)