Avoid using PACKAGE_PREFIX_PATH for configure-time executables

PACKAGE_PREFIX_PATH is not defined in cmake versions 3.29.x.
We should avoid referring the internal CMake variables.
Use the calculated reverse relative path to the prefix path
instead.

Fixes: QTBUG-124186
Pick-to: 6.5 6.6 6.7
Change-Id: Iefae132e61a3f8e8f5525c0abd6a2d41631c2fb0
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Alexey Edelev 2024-04-08 14:49:39 +02:00
parent 6760bae2fa
commit 2d19f09b57

View File

@ -830,17 +830,30 @@ endif()
get_target_property(configure_time_target_install_location ${target}
IMPORTED_LOCATION)
else()
if(IS_ABSOLUTE "${arg_CONFIG_INSTALL_DIR}")
file(RELATIVE_PATH reverse_relative_prefix_path
"${arg_CONFIG_INSTALL_DIR}" "${CMAKE_INSTALL_PREFIX}")
else()
file(RELATIVE_PATH reverse_relative_prefix_path
"${CMAKE_INSTALL_PREFIX}/${arg_CONFIG_INSTALL_DIR}"
"${CMAKE_INSTALL_PREFIX}")
endif()
get_target_property(configure_time_target_build_location ${target}
_qt_internal_configure_time_target_build_location)
set(configure_time_target_build_location
"$\{PACKAGE_PREFIX_DIR}/${configure_time_target_build_location}")
string(TOUPPER "${QT_CMAKE_EXPORT_NAMESPACE}_INSTALL_PREFIX" install_prefix_var)
string(JOIN "" configure_time_target_build_location
"$\{CMAKE_CURRENT_LIST_DIR}/"
"${reverse_relative_prefix_path}"
"${configure_time_target_build_location}")
get_target_property(configure_time_target_install_location ${target}
_qt_internal_configure_time_target_install_location)
set(configure_time_target_install_location
"$\{PACKAGE_PREFIX_DIR}/${configure_time_target_install_location}")
string(JOIN "" configure_time_target_install_location
"$\{CMAKE_CURRENT_LIST_DIR}/"
"${reverse_relative_prefix_path}"
"${configure_time_target_install_location}")
endif()
if(configure_time_target_install_location)
string(APPEND content "