CMake: Fix getting target property from Tools-only packages

A call to find_package(Qt6 COMPONENTS LinguistTools) would fail with
CMake Error at Qt6Config.cmake:212 (get_target_property):
  get_target_property() called with non-existent target
  "Qt6::LinguistTools".

Tools packages don't have a module, guard the get_target_property
call.

Amends a9c18e5df240ce4a8bdc4dd3e7b8d5289227d2d9

Change-Id: Idb70b427d0762ed64c2ef77133a2ae56f310483d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
Alexandru Croitor 2025-02-17 10:17:43 +01:00
parent fcb2058631
commit 37e85c0ff3

View File

@ -156,13 +156,16 @@ foreach(module ${__qt_umbrella_find_components})
_qt_internal_save_find_package_context_for_debugging(@INSTALL_CMAKE_NAMESPACE@${module})
if(@INSTALL_CMAKE_NAMESPACE@${module}_FOUND)
get_target_property(__qt_${module}_is_private @INSTALL_CMAKE_NAMESPACE@::${module}
_qt_is_private_module
)
if(__qt_${module}_is_private)
_qt_internal_show_private_module_warning(${module})
# Tools packages don't usually provide a qt module, so there's no target.
if(TARGET @INSTALL_CMAKE_NAMESPACE@::${module})
get_target_property(__qt_${module}_is_private @INSTALL_CMAKE_NAMESPACE@::${module}
_qt_is_private_module
)
if(__qt_${module}_is_private)
_qt_internal_show_private_module_warning(${module})
endif()
unset(__qt_${module}_is_private)
endif()
unset(__qt_${module}_is_private)
else()
find_package(@INSTALL_CMAKE_NAMESPACE@${module}
${@INSTALL_CMAKE_NAMESPACE@_FIND_VERSION}