Consider INSTALL_LIBDIR when calculating various cmake paths
Task-number: QTBUG-123039 Change-Id: I111cd612afe64a4f8456ab05d6ff3caf828c4712 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
13d6d25c1a
commit
967732f7f7
@ -55,6 +55,10 @@ foreach(__qt_public_file_to_include IN LISTS __qt_public_files_to_include)
|
|||||||
include("${__qt_public_file_to_include}")
|
include("${__qt_public_file_to_include}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
if(NOT DEFINED QT_CMAKE_EXPORT_NAMESPACE)
|
||||||
|
set(QT_CMAKE_EXPORT_NAMESPACE @QT_CMAKE_EXPORT_NAMESPACE@)
|
||||||
|
endif()
|
||||||
|
|
||||||
set(QT_ADDITIONAL_PACKAGES_PREFIX_PATH "" CACHE STRING
|
set(QT_ADDITIONAL_PACKAGES_PREFIX_PATH "" CACHE STRING
|
||||||
"Additional directories where find(Qt6 ...) components are searched")
|
"Additional directories where find(Qt6 ...) components are searched")
|
||||||
set(QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH "" CACHE STRING
|
set(QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH "" CACHE STRING
|
||||||
@ -68,10 +72,6 @@ __qt_internal_collect_additional_prefix_paths(_qt_additional_host_packages_prefi
|
|||||||
__qt_internal_prefix_paths_to_roots(_qt_additional_host_packages_root_paths
|
__qt_internal_prefix_paths_to_roots(_qt_additional_host_packages_root_paths
|
||||||
"${_qt_additional_host_packages_prefix_paths}")
|
"${_qt_additional_host_packages_prefix_paths}")
|
||||||
|
|
||||||
if(NOT DEFINED QT_CMAKE_EXPORT_NAMESPACE)
|
|
||||||
set(QT_CMAKE_EXPORT_NAMESPACE @QT_CMAKE_EXPORT_NAMESPACE@)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
__qt_internal_collect_additional_module_paths()
|
__qt_internal_collect_additional_module_paths()
|
||||||
|
|
||||||
# Propagate sanitizer flags to both internal Qt builds and user projects.
|
# Propagate sanitizer flags to both internal Qt builds and user projects.
|
||||||
|
@ -143,10 +143,7 @@ function(qt_internal_add_headersclean_target module_target module_headers)
|
|||||||
# If additional package prefixes are provided, we consider they can contain frameworks
|
# If additional package prefixes are provided, we consider they can contain frameworks
|
||||||
# as well.
|
# as well.
|
||||||
foreach(prefix IN LISTS _qt_additional_packages_prefix_paths)
|
foreach(prefix IN LISTS _qt_additional_packages_prefix_paths)
|
||||||
if(prefix MATCHES "/lib/cmake$") # Cut CMake files path
|
__qt_internal_reverse_prefix_path_from_cmake_dir(path "${path}")
|
||||||
string(APPEND prefix "/../..")
|
|
||||||
endif()
|
|
||||||
get_filename_component(prefix "${prefix}" ABSOLUTE)
|
|
||||||
|
|
||||||
set(libdir "${prefix}/${INSTALL_LIBDIR}")
|
set(libdir "${prefix}/${INSTALL_LIBDIR}")
|
||||||
if(EXISTS "${libdir}")
|
if(EXISTS "${libdir}")
|
||||||
|
@ -39,6 +39,65 @@ function(_qt_internal_check_depfile_support out_var)
|
|||||||
set(${out_var} "${${out_var}}" PARENT_SCOPE)
|
set(${out_var} "${${out_var}}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
# Checks if the path points to the cmake directory, like lib/cmake.
|
||||||
|
function(__qt_internal_check_path_points_to_cmake_dir result path)
|
||||||
|
string(TOUPPER "${QT_CMAKE_EXPORT_NAMESPACE}" export_namespace_upper)
|
||||||
|
if((INSTALL_LIBDIR AND path MATCHES "/${INSTALL_LIBDIR}/cmake$") OR
|
||||||
|
(${export_namespace_upper}_INSTALL_LIBS AND
|
||||||
|
path MATCHES "/${${export_namespace_upper}_INSTALL_LIBS}/cmake$") OR
|
||||||
|
path MATCHES "/lib/cmake$"
|
||||||
|
)
|
||||||
|
set(${result} TRUE PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${result} FALSE PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Creates a reverse path to prefix from possible cmake directories. Returns the unchanged path
|
||||||
|
# if it doesn't point to cmake directory.
|
||||||
|
function(__qt_internal_reverse_prefix_path_from_cmake_dir result cmake_path)
|
||||||
|
string(TOUPPER "${QT_CMAKE_EXPORT_NAMESPACE}" export_namespace_upper)
|
||||||
|
if(INSTALL_LIBDIR AND cmake_path MATCHES "(.+)/${INSTALL_LIBDIR}/cmake$")
|
||||||
|
if(CMAKE_MATCH_1)
|
||||||
|
set(${result} "${CMAKE_MATCH_1}" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
elseif(${export_namespace_upper}_INSTALL_LIBS AND
|
||||||
|
cmake_path MATCHES "(.+)/${${export_namespace_upper}_INSTALL_LIBS}/cmake$")
|
||||||
|
if(CMAKE_MATCH_1)
|
||||||
|
set(${result} "${CMAKE_MATCH_1}" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
elseif(result MATCHES "(.+)/lib/cmake$")
|
||||||
|
if(CMAKE_MATCH_1)
|
||||||
|
set(${result} "${CMAKE_MATCH_1}" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(${result} "${cmake_path}" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Returns the possible cmake directories based on prefix_path.
|
||||||
|
function(__qt_internal_get_possible_cmake_dirs out_paths prefix_path)
|
||||||
|
set(${out_paths} "")
|
||||||
|
|
||||||
|
if(EXISTS "${prefix_path}/lib/cmake")
|
||||||
|
list(APPEND ${out_paths} "${prefix_path}/lib/cmake")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
string(TOUPPER "${QT_CMAKE_EXPORT_NAMESPACE}" export_namespace_upper)
|
||||||
|
set(next_path "${prefix_path}/${${export_namespace_upper}_INSTALL_LIBS}/cmake")
|
||||||
|
if(${export_namespace_upper}_INSTALL_LIBS AND EXISTS "${next_path}")
|
||||||
|
list(APPEND ${out_paths} "${next_path}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(next_path "${prefix_path}/${INSTALL_LIBDIR}/cmake")
|
||||||
|
if(INSTALL_LIBDIR AND EXISTS "${next_path}")
|
||||||
|
list(APPEND ${out_paths} "${next_path}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(REMOVE_DUPLICATES ${out_paths})
|
||||||
|
set(${out_paths} "${${out_paths}}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# Collect additional package prefix paths to look for Qt packages, both from command line and the
|
# 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
|
# env variable ${prefixes_var}. The result is stored in ${out_var} and is a list of paths ending
|
||||||
# with "/lib/cmake".
|
# with "/lib/cmake".
|
||||||
@ -72,10 +131,13 @@ function(__qt_internal_collect_additional_prefix_paths out_var prefixes_var)
|
|||||||
# NO_DEFAULT_PATH, and thus CMAKE_PREFIX_PATH values are discarded.
|
# 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
|
# CMAKE_FIND_ROOT_PATH values are not discarded and togegher with the PATHS option, it
|
||||||
# ensures packages from additional prefixes are found.
|
# ensures packages from additional prefixes are found.
|
||||||
if(NOT additional_path MATCHES "/lib/cmake$")
|
__qt_internal_check_path_points_to_cmake_dir(is_path_to_cmake "${additional_path}")
|
||||||
string(APPEND additional_path "/lib/cmake")
|
if(is_path_to_cmake)
|
||||||
|
list(APPEND additional_packages_prefix_paths "${additional_path}")
|
||||||
|
else()
|
||||||
|
__qt_internal_get_possible_cmake_dirs(additional_cmake_dirs "${additional_path}")
|
||||||
|
list(APPEND additional_packages_prefix_paths ${additional_cmake_dirs})
|
||||||
endif()
|
endif()
|
||||||
list(APPEND additional_packages_prefix_paths "${additional_path}")
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
set("${out_var}" "${additional_packages_prefix_paths}" PARENT_SCOPE)
|
set("${out_var}" "${additional_packages_prefix_paths}" PARENT_SCOPE)
|
||||||
@ -87,10 +149,14 @@ function(__qt_internal_collect_additional_module_paths)
|
|||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
foreach(prefix_path IN LISTS QT_ADDITIONAL_PACKAGES_PREFIX_PATH)
|
foreach(prefix_path IN LISTS QT_ADDITIONAL_PACKAGES_PREFIX_PATH)
|
||||||
list(APPEND CMAKE_MODULE_PATH "${prefix_path}/${QT_CMAKE_EXPORT_NAMESPACE}")
|
__qt_internal_check_path_points_to_cmake_dir(is_path_to_cmake "${prefix_path}")
|
||||||
# TODO: Need to consider the INSTALL_LIBDIR value when collecting CMAKE_MODULE_PATH.
|
if(is_path_to_cmake)
|
||||||
# See QTBUG-123039.
|
list(APPEND CMAKE_MODULE_PATH "${prefix_path}/${QT_CMAKE_EXPORT_NAMESPACE}")
|
||||||
list(APPEND CMAKE_MODULE_PATH "${prefix_path}/lib/cmake/${QT_CMAKE_EXPORT_NAMESPACE}")
|
else()
|
||||||
|
__qt_internal_get_possible_cmake_dirs(additional_cmake_dirs "${additional_path}")
|
||||||
|
list(TRANSFORM additional_cmake_dirs APPEND "/${QT_CMAKE_EXPORT_NAMESPACE}")
|
||||||
|
list(APPEND CMAKE_MODULE_PATH ${additional_cmake_dirs})
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
list(REMOVE_DUPLICATES CMAKE_MODULE_PATH)
|
list(REMOVE_DUPLICATES CMAKE_MODULE_PATH)
|
||||||
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE)
|
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE)
|
||||||
@ -102,10 +168,7 @@ endfunction()
|
|||||||
function(__qt_internal_prefix_paths_to_roots out_var prefix_paths)
|
function(__qt_internal_prefix_paths_to_roots out_var prefix_paths)
|
||||||
set(result "")
|
set(result "")
|
||||||
foreach(path IN LISTS prefix_paths)
|
foreach(path IN LISTS prefix_paths)
|
||||||
if(path MATCHES "/lib/cmake$")
|
__qt_internal_reverse_prefix_path_from_cmake_dir(path "${path}")
|
||||||
string(APPEND path "/../..")
|
|
||||||
endif()
|
|
||||||
get_filename_component(path "${path}" ABSOLUTE)
|
|
||||||
list(APPEND result "${path}")
|
list(APPEND result "${path}")
|
||||||
endforeach()
|
endforeach()
|
||||||
set("${out_var}" "${result}" PARENT_SCOPE)
|
set("${out_var}" "${result}" PARENT_SCOPE)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user