diff --git a/cmake/QtExecutableHelpers.cmake b/cmake/QtExecutableHelpers.cmake index 736fea724ee..f4380291f70 100644 --- a/cmake/QtExecutableHelpers.cmake +++ b/cmake/QtExecutableHelpers.cmake @@ -390,9 +390,15 @@ function(qt_internal_add_configure_time_executable target) if(arg_INSTALL_DIRECTORY) set(install_dir "${arg_INSTALL_DIRECTORY}") endif() + + set(output_directory_relative "${install_dir}") set(output_directory "${QT_BUILD_DIR}/${install_dir}") + + set(target_binary_path_relative + "${output_directory_relative}/${configuration_path}${target_binary}") set(target_binary_path "${output_directory}/${configuration_path}${target_binary}") + get_filename_component(target_binary_path "${target_binary_path}" ABSOLUTE) if(NOT DEFINED arg_SOURCES) @@ -521,7 +527,9 @@ function(qt_internal_add_configure_time_executable target) add_executable(${QT_CMAKE_EXPORT_NAMESPACE}::${target} ALIAS ${target}) set_target_properties(${target} PROPERTIES _qt_internal_configure_time_target TRUE - IMPORTED_LOCATION "${target_binary_path}") + _qt_internal_configure_time_target_build_location "${target_binary_path_relative}" + IMPORTED_LOCATION "${target_binary_path}" + ) if(NOT arg_NO_INSTALL) set_target_properties(${target} PROPERTIES diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake index 71ffde93c0f..631df93dc22 100644 --- a/cmake/QtTargetHelpers.cmake +++ b/cmake/QtTargetHelpers.cmake @@ -823,11 +823,19 @@ endif() # 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) + set(configure_time_target_build_location "") get_target_property(configure_time_target_install_location ${target} IMPORTED_LOCATION) else() + 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}") + 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() @@ -835,7 +843,13 @@ endif() string(APPEND content " # Import configure-time executable ${full_target} if(NOT TARGET ${full_target}) - set(_qt_imported_location \"${configure_time_target_install_location}\") + set(_qt_imported_build_location \"${configure_time_target_build_location}\") + set(_qt_imported_install_location \"${configure_time_target_install_location}\") + set(_qt_imported_location \"\${_qt_imported_install_location}\") + if(NOT EXISTS \"$\{_qt_imported_location}\" + AND NOT \"$\{_qt_imported_build_location}\" STREQUAL \"\") + set(_qt_imported_location \"\${_qt_imported_build_location}\") + endif() if(NOT EXISTS \"$\{_qt_imported_location}\") message(FATAL_ERROR \"Unable to add configure time executable ${full_target}\" \" $\{_qt_imported_location} doesn't exists\") @@ -846,6 +860,8 @@ if(NOT TARGET ${full_target}) \"$\{_qt_imported_location}\") set_property(TARGET ${full_target} PROPERTY IMPORTED_GLOBAL TRUE) unset(_qt_imported_location) + unset(_qt_imported_build_location) + unset(_qt_imported_install_location) endif() \n") endif()