CMake: Fix syncqt IMPORTED_LOCATION path for multi-config builds
When building examples as ExternalProjects as part of a multi-config qtbase build, syncqt can not be located with the following error: CMake Error at Qt6CoreToolsAdditionalTargetInfo.cmake:10 (message): Unable to add configure time executable Qt6::syncqt qtbase/libexec/syncqt doesn't exist Call Stack (most recent call first): qtbase/lib/cmake/Qt6CoreTools/Qt6CoreToolsConfig.cmake:44 (include) qtbase/cmake/QtPublicDependencyHelpers.cmake:65 (find_package) qtbase/lib/cmake/Qt6Core/Qt6CoreDependencies.cmake:34 (_qt_internal_find_tool_dependencies) qtbase/lib/cmake/Qt6Core/Qt6CoreConfig.cmake:42 (include) qtbase/lib/cmake/Qt6/Qt6Config.cmake:165 (find_package) CMakeLists.txt:13 (find_package) The Qt6CoreToolsAdditionalTargetInfo.cmake file is used both for install(EXPORT) Config files as well as export(EXPORT) Config files, and in the latter case, the path that syncqt is looked up in is not correct because syncqt is not yet installed. In addition to checking whether syncqt exists in the install path, also check if it exists in the build dir. Ideally the additional path would be stored in a separate file that is not installed, but the current code infrastructure does not provide such a feature. Because we store a relative path instead of an absolute path, the build path does not leak, so the situation is bearable. Task-number: QTBUG-90820 Task-number: QTBUG-96232 Change-Id: I16ad5c280751e050bc9b039ebd38ec9a66a6554c Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit cc537d927b23a34296767fec8d3885a95f714255) Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
a33732ab74
commit
a94fef3e04
@ -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
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user