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. Pick-to: 6.4 Change-Id: I772a0cca35d5c03cd688c3f1de34984484444105 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
91efee1848
commit
59f0f25f71
@ -38,58 +38,6 @@ elseif(APPLE AND CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
|||||||
list(APPEND CMAKE_MODULE_PATH "${__qt_internal_cmake_ios_support_files_path}")
|
list(APPEND CMAKE_MODULE_PATH "${__qt_internal_cmake_ios_support_files_path}")
|
||||||
endif()
|
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
|
# Take a list of prefix paths ending with "/lib/cmake", and return a list of absolute paths with
|
||||||
# "/lib/cmake" removed.
|
# "/lib/cmake" removed.
|
||||||
function(__qt_internal_prefix_paths_to_roots out_var prefix_paths)
|
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}/QtPublicToolHelpers.cmake")
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/QtPublicCMakeHelpers.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)
|
if(NOT DEFINED QT_CMAKE_EXPORT_NAMESPACE)
|
||||||
set(QT_CMAKE_EXPORT_NAMESPACE @QT_CMAKE_EXPORT_NAMESPACE@)
|
set(QT_CMAKE_EXPORT_NAMESPACE @QT_CMAKE_EXPORT_NAMESPACE@)
|
||||||
endif()
|
endif()
|
||||||
|
@ -35,3 +35,45 @@ function(_qt_internal_check_depfile_support out_var)
|
|||||||
endif()
|
endif()
|
||||||
set(${out_var} "${${out_var}}" PARENT_SCOPE)
|
set(${out_var} "${${out_var}}" PARENT_SCOPE)
|
||||||
endfunction()
|
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()
|
||||||
|
Loading…
Reference in New Issue
Block a user