From 2bf54da75ae77ca4f660dc23ef9c917e5eb86a9d Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Fri, 6 Jan 2023 10:23:51 +0100 Subject: [PATCH] Use the existing imported location for syncqt in developer builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In developer builds we don't install tools, so syncqt executable is located in its RUNTIME_OUTPUT_DIRECTORY but not by install path. This works fine in general case, but in multi-config builds the RUNTIME_OUTPUT_DIRECTORY path doesn't match the install path. So syncqt target points to wrong location in this case. It makes sense to use the existing IMPORTED_LOCATION of syncqt executable directly if Qt is not supposed to be installed. Also check if the syncqt executable exists at the expected location before creating the imported target. Pick-to: 6.5 Fixes: QTBUG-109864 Change-Id: I0de647b2a73169a0d48bd88edeb7ff00975fa774 Reviewed-by: Jörg Bornemann --- cmake/QtTargetHelpers.cmake | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake index c4e424a9df4..c5ced2738c2 100644 --- a/cmake/QtTargetHelpers.cmake +++ b/cmake/QtTargetHelpers.cmake @@ -568,17 +568,32 @@ endif() get_target_property(is_configure_time_target ${target} _qt_internal_configure_time_target) if(is_configure_time_target) - get_target_property(configure_time_target_install_location ${target} - _qt_internal_configure_time_target_install_location) + # For Multi-config developer builds we should simply reuse IMPORTED_LOCATION of the + # target. + if(NOT QT_WILL_INSTALL AND QT_FEATURE_debug_and_release) + get_target_property(configure_time_target_install_location ${target} + IMPORTED_LOCATION) + else() + 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}") + endif() if(configure_time_target_install_location) string(APPEND content " # Import configure-time executable ${full_target} if(NOT TARGET ${full_target}) + set(_qt_imported_location \"${configure_time_target_install_location}\") + if(NOT EXISTS \"$\{_qt_imported_location}\") + message(FATAL_ERROR \"Unable to add configure time executable ${full_target}\" + \" $\{_qt_imported_location} doesn't exists\") + endif() add_executable(${full_target} IMPORTED) set_property(TARGET ${full_target} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${default_cfg}) set_target_properties(${full_target} PROPERTIES IMPORTED_LOCATION_${uc_default_cfg} - \"$\{PACKAGE_PREFIX_DIR}/${configure_time_target_install_location}\") + \"$\{_qt_imported_location}\") set_property(TARGET ${full_target} PROPERTY IMPORTED_GLOBAL TRUE) + unset(_qt_imported_location) endif() \n") endif()