qt5base-lts/cmake/QtModuleToolsVersionlessTargets.cmake.in
Alexandru Croitor bc80067266 CMake: Create global imported versionless tool targets
Versioned tool targets are always promoted to global targets.
Versionless ones were not promoted to global targets.

This was an oversight which caused issues with conditions like
if(TARGET Qt::Tool) in top-level builds.

Fixes: QTBUG-93839
Change-Id: I5176899b5d0d80bfd0b350bc9c4b3fa5b53c0777
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-06-01 16:29:15 +02:00

24 lines
964 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 GLOBAL)
# 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()