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 1d4c4400537537656997d3f000df6e9bdc5e720c

Fixes: QTBUG-137146
Change-Id: Idb70b427d0762ed64c2ef77133a2ae56f310483d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 37e85c0ff3ee1f01d94942c35c0b13fe34fa4c7e)
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2025-02-17 10:17:43 +01:00 committed by Joerg Bornemann
parent 2ec1667e7a
commit 00b28640a2

View File

@ -166,13 +166,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}