CMake: Better detect imported tool locations

On some systems IMPORTED_LOCATION isn't set, but configuration-specific
locations like IMPORTED_LOCATION_RELEASE are. In these cases, fall back to
the location of the release build if the default isn't found.

Fixes the build on Arch Linux.

Change-Id: Iff87a8356302a260b2ac5f959f835d1cdf8a5c65
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Aaron Barany
2022-02-04 17:11:00 -08:00
parent f132b09c4b
commit ccad4fa924
+4
View File
@@ -83,6 +83,10 @@ foreach(tool qmake lrelease lupdate moc rcc qhelpgenerator)
if (TARGET Qt6::${tool} AND NOT TARGET Qt5::${tool})
add_executable(Qt5::${tool} IMPORTED GLOBAL)
get_target_property(imported_location Qt6::${tool} IMPORTED_LOCATION)
# handle separate tools for each configuration
if (NOT imported_location)
get_target_property(imported_location Qt6::${tool} IMPORTED_LOCATION_RELEASE)
endif()
set_target_properties(Qt5::${tool} PROPERTIES IMPORTED_LOCATION "${imported_location}")
endif()
endforeach()