CMake: Move __qt_internal_prefix_paths_to_roots

Move it into QtPublicCMakeHelpers.cmake so it is available also when
configuring qtbase and the Qt6Config.cmake file is not yet loaded.

Pick-to: 6.4
Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I88127fe0439ae26af1d125eb584244d315574a48
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2022-09-13 17:23:55 +02:00
parent 59f0f25f71
commit 828e402a19
2 changed files with 17 additions and 17 deletions

View File

@ -38,23 +38,6 @@ elseif(APPLE AND CMAKE_SYSTEM_NAME STREQUAL "iOS")
list(APPEND CMAKE_MODULE_PATH "${__qt_internal_cmake_ios_support_files_path}")
endif()
# 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)
set(result "")
foreach(path IN LISTS prefix_paths)
if(path MATCHES "/lib/cmake$")
string(APPEND path "/../..")
endif()
get_filename_component(path "${path}" ABSOLUTE)
list(APPEND result "${path}")
endforeach()
set("${out_var}" "${result}" PARENT_SCOPE)
endfunction()
__qt_internal_prefix_paths_to_roots(_qt_additional_host_packages_root_paths
"${_qt_additional_host_packages_prefix_paths}")
# Public helpers available to all Qt packages.
include("${CMAKE_CURRENT_LIST_DIR}/QtFeature.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicAppleHelpers.cmake")
@ -78,6 +61,9 @@ __qt_internal_collect_additional_prefix_paths(_qt_additional_packages_prefix_pat
__qt_internal_collect_additional_prefix_paths(_qt_additional_host_packages_prefix_paths
QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH)
__qt_internal_prefix_paths_to_roots(_qt_additional_host_packages_root_paths
"${_qt_additional_host_packages_prefix_paths}")
if(NOT DEFINED QT_CMAKE_EXPORT_NAMESPACE)
set(QT_CMAKE_EXPORT_NAMESPACE @QT_CMAKE_EXPORT_NAMESPACE@)
endif()

View File

@ -77,3 +77,17 @@ function(__qt_internal_collect_additional_prefix_paths out_var prefixes_var)
set("${out_var}" "${additional_packages_prefix_paths}" PARENT_SCOPE)
endfunction()
# 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)
set(result "")
foreach(path IN LISTS prefix_paths)
if(path MATCHES "/lib/cmake$")
string(APPEND path "/../..")
endif()
get_filename_component(path "${path}" ABSOLUTE)
list(APPEND result "${path}")
endforeach()
set("${out_var}" "${result}" PARENT_SCOPE)
endfunction()