From 2d19f09b577f72290328d90ba85145362676ea92 Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Mon, 8 Apr 2024 14:49:39 +0200 Subject: [PATCH] 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 Reviewed-by: Fabian Kosmale --- cmake/QtTargetHelpers.cmake | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake index 8cc09fe83db..e669047ff12 100644 --- a/cmake/QtTargetHelpers.cmake +++ b/cmake/QtTargetHelpers.cmake @@ -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 "