qt5base-lts/cmake/QtModuleToolsVersionlessTargets.cmake.in
Alexandru Croitor 04d895681a CMake: Fix creation of versionless targets for tools
We can't use qt_internal_export_modern_cmake_config_targets_file for
executables like tools, because it's not possible to use
INTERFACE_LINK_LIBRARIES with executables like you can with libraries.
We also can't create aliases to non-global imported targets.

Instead create new imported executable targets, fish out the imported
location, and assign it to the versionless targets.

Task-number: QTBUG-74137
Task-number: QTBUG-80477
Task-number: QTBUG-75984
Change-Id: I6a3c9c67ef4699c72a6c9a627c63158dfd6557f8
Reviewed-by: Leander Beernaert <leander.beernaert@qt.io>
Reviewed-by: Qt CMake Build Bot
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-12-06 11:11:16 +00:00

24 lines
957 B
CMake

foreach(__qt_tool @tool_targets_non_prefixed@)
if(NOT TARGET Qt::${__qt_tool} AND TARGET Qt6::${__qt_tool})
add_executable(Qt::${__qt_tool} IMPORTED)
# Check all the usual imported location properties to find one that contains a path.
foreach(__qt_imported_location_config
IMPORTED_LOCATION
IMPORTED_LOCATION_RELEASE
IMPORTED_LOCATION_RELWITHDEBINFO
IMPORTED_LOCATION_MINSIZEREL
IMPORTED_LOCATION_DEBUG)
get_target_property(__qt_imported_location
Qt6::${__qt_tool} ${__qt_imported_location_config})
if(__qt_imported_location AND EXISTS "${__qt_imported_location}")
break()
endif()
endforeach()
set_target_properties(Qt::${__qt_tool}
PROPERTIES IMPORTED_LOCATION "${__qt_imported_location}")
endif()
endforeach()