summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-09-13 17:27:42 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2022-09-16 13:21:09 +0200
commit08e7d943ef6136f3f584e77615eba3824d97c9b7 (patch)
tree0506fde424939ac423f155982723ceb85fac0442 /cmake
parente1db632ad929aa04af770844e56f2545ecec098f (diff)
CMake: Move __qt_internal_collect_additional_prefix_paths
Move it out of QtConfig.cmake.in into QtPublicCMakeHelpers.cmake so that the Qt6Config file is less cluttered. Change-Id: I772a0cca35d5c03cd688c3f1de34984484444105 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 59f0f25f7161313988b2c40f3c26b8ee12a88877) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtConfig.cmake.in62
-rw-r--r--cmake/QtPublicCMakeHelpers.cmake42
2 files changed, 52 insertions, 52 deletions
diff --git a/cmake/QtConfig.cmake.in b/cmake/QtConfig.cmake.in
index 3127d50858..8834ac4ea6 100644
--- a/cmake/QtConfig.cmake.in
+++ b/cmake/QtConfig.cmake.in
@@ -38,58 +38,6 @@ elseif(APPLE AND CMAKE_SYSTEM_NAME STREQUAL "iOS")
list(APPEND CMAKE_MODULE_PATH "${__qt_internal_cmake_ios_support_files_path}")
endif()
-set(QT_ADDITIONAL_PACKAGES_PREFIX_PATH "" CACHE STRING
- "Additional directories where find(Qt6 ...) components are searched")
-set(QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH "" CACHE STRING
- "Additional directories where find(Qt6 ...) host Qt components are searched")
-
-# Collect additional package prefix paths to look for Qt packages, both from command line and the
-# env variable ${prefixes_var}. The result is stored in ${out_var} and is a list of paths ending
-# with "/lib/cmake".
-function(__qt_internal_collect_additional_prefix_paths out_var prefixes_var)
- if(DEFINED "${out_var}")
- return()
- endif()
-
- set(additional_packages_prefix_paths "")
-
- set(additional_packages_prefixes "")
- if(${prefixes_var})
- list(APPEND additional_packages_prefixes ${${prefixes_var}})
- endif()
- if(DEFINED ENV{${prefixes_var}}
- AND NOT "$ENV{${prefixes_var}}" STREQUAL "")
- set(prefixes_from_env "$ENV{${prefixes_var}}")
- if(NOT CMAKE_HOST_WIN32)
- string(REPLACE ":" ";" prefixes_from_env "${prefixes_from_env}")
- endif()
- list(APPEND additional_packages_prefixes ${prefixes_from_env})
- endif()
-
- foreach(additional_path IN LISTS additional_packages_prefixes)
- file(TO_CMAKE_PATH "${additional_path}" additional_path)
-
- # The prefix paths need to end with lib/cmake to ensure the packages are found when
- # cross compiling. Search for REROOT_PATH_ISSUE_MARKER in the qt.toolchain.cmake file for
- # details.
- # We must pass the values via the PATHS options because the main find_package call uses
- # NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH values are discarded.
- # CMAKE_FIND_ROOT_PATH values are not discarded and togegher with the PATHS option, it
- # ensures packages from additional prefixes are found.
- if(NOT additional_path MATCHES "/lib/cmake$")
- string(APPEND additional_path "/lib/cmake")
- endif()
- list(APPEND additional_packages_prefix_paths "${additional_path}")
- endforeach()
-
- set("${out_var}" "${additional_packages_prefix_paths}" PARENT_SCOPE)
-endfunction()
-
-__qt_internal_collect_additional_prefix_paths(_qt_additional_packages_prefix_paths
- QT_ADDITIONAL_PACKAGES_PREFIX_PATH)
-__qt_internal_collect_additional_prefix_paths(_qt_additional_host_packages_prefix_paths
- QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH)
-
# Take a list of prefix paths ending with "/lib/cmake", and return a list of absolute paths with
# "/lib/cmake" removed.
function(__qt_internal_prefix_paths_to_roots out_var prefix_paths)
@@ -120,6 +68,16 @@ include("${CMAKE_CURRENT_LIST_DIR}/QtPublicTestHelpers.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicToolHelpers.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicCMakeHelpers.cmake")
+set(QT_ADDITIONAL_PACKAGES_PREFIX_PATH "" CACHE STRING
+ "Additional directories where find(Qt6 ...) components are searched")
+set(QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH "" CACHE STRING
+ "Additional directories where find(Qt6 ...) host Qt components are searched")
+
+__qt_internal_collect_additional_prefix_paths(_qt_additional_packages_prefix_paths
+ QT_ADDITIONAL_PACKAGES_PREFIX_PATH)
+__qt_internal_collect_additional_prefix_paths(_qt_additional_host_packages_prefix_paths
+ QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH)
+
if(NOT DEFINED QT_CMAKE_EXPORT_NAMESPACE)
set(QT_CMAKE_EXPORT_NAMESPACE @QT_CMAKE_EXPORT_NAMESPACE@)
endif()
diff --git a/cmake/QtPublicCMakeHelpers.cmake b/cmake/QtPublicCMakeHelpers.cmake
index 35cd4fe1f3..0b0577f2e0 100644
--- a/cmake/QtPublicCMakeHelpers.cmake
+++ b/cmake/QtPublicCMakeHelpers.cmake
@@ -32,3 +32,45 @@ function(_qt_internal_check_depfile_support out_var)
endif()
set(${out_var} "${${out_var}}" PARENT_SCOPE)
endfunction()
+
+# Collect additional package prefix paths to look for Qt packages, both from command line and the
+# env variable ${prefixes_var}. The result is stored in ${out_var} and is a list of paths ending
+# with "/lib/cmake".
+function(__qt_internal_collect_additional_prefix_paths out_var prefixes_var)
+ if(DEFINED "${out_var}")
+ return()
+ endif()
+
+ set(additional_packages_prefix_paths "")
+
+ set(additional_packages_prefixes "")
+ if(${prefixes_var})
+ list(APPEND additional_packages_prefixes ${${prefixes_var}})
+ endif()
+ if(DEFINED ENV{${prefixes_var}}
+ AND NOT "$ENV{${prefixes_var}}" STREQUAL "")
+ set(prefixes_from_env "$ENV{${prefixes_var}}")
+ if(NOT CMAKE_HOST_WIN32)
+ string(REPLACE ":" ";" prefixes_from_env "${prefixes_from_env}")
+ endif()
+ list(APPEND additional_packages_prefixes ${prefixes_from_env})
+ endif()
+
+ foreach(additional_path IN LISTS additional_packages_prefixes)
+ file(TO_CMAKE_PATH "${additional_path}" additional_path)
+
+ # The prefix paths need to end with lib/cmake to ensure the packages are found when
+ # cross compiling. Search for REROOT_PATH_ISSUE_MARKER in the qt.toolchain.cmake file for
+ # details.
+ # We must pass the values via the PATHS options because the main find_package call uses
+ # NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH values are discarded.
+ # CMAKE_FIND_ROOT_PATH values are not discarded and togegher with the PATHS option, it
+ # ensures packages from additional prefixes are found.
+ if(NOT additional_path MATCHES "/lib/cmake$")
+ string(APPEND additional_path "/lib/cmake")
+ endif()
+ list(APPEND additional_packages_prefix_paths "${additional_path}")
+ endforeach()
+
+ set("${out_var}" "${additional_packages_prefix_paths}" PARENT_SCOPE)
+endfunction()