summaryrefslogtreecommitdiffstats
path: root/cmake/QtPublicWalkLibsHelpers.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/QtPublicWalkLibsHelpers.cmake')
-rw-r--r--cmake/QtPublicWalkLibsHelpers.cmake27
1 files changed, 22 insertions, 5 deletions
diff --git a/cmake/QtPublicWalkLibsHelpers.cmake b/cmake/QtPublicWalkLibsHelpers.cmake
index bf9262992b..f79b70c710 100644
--- a/cmake/QtPublicWalkLibsHelpers.cmake
+++ b/cmake/QtPublicWalkLibsHelpers.cmake
@@ -1,5 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
# Add libraries to variable ${out_libs_var} in a way that duplicates
# are added at the end. This ensures the library order needed for the
@@ -189,7 +189,7 @@ function(__qt_internal_walk_libs
# namespace. Which one is preferred doesn't really matter. This code exists to
# avoid ending up with both, Qt::Foo and Foo in our dependencies.
set(namespaceless_lib_target "${CMAKE_MATCH_1}")
- if(TARGET namespaceless_lib_target)
+ if(TARGET "${namespaceless_lib_target}")
set(lib_target ${namespaceless_lib_target})
endif()
endif()
@@ -277,6 +277,18 @@ ${target}, but not declared.")
set(${rcc_objects_out_var} ${rcc_objects} PARENT_SCOPE)
endfunction()
+function(__qt_internal_print_missing_dependency_target_warning target dep)
+ if(QT_SILENCE_MISSING_DEPENDENCY_TARGET_WARNING)
+ return()
+ endif()
+ message(WARNING
+ "When trying to collect dependencies of target '${target}', "
+ "the non-existent target '${dep}' was encountered. "
+ "This can likely be fixed by moving the find_package call that pulls in "
+ "'${dep}' to the scope of directory '${CMAKE_CURRENT_LIST_DIR}' or higher. "
+ "This warning can be silenced by setting QT_SILENCE_MISSING_DEPENDENCY_TARGET_WARNING to "
+ "ON.")
+endfunction()
# Given ${target}, collect all its private dependencies that are CMake targets.
#
@@ -303,9 +315,14 @@ function(__qt_internal_collect_all_target_dependencies target out_var)
"qt_private_link_library_targets"
"collect_targets")
- if(lib_walked_targets)
- list(APPEND dep_targets ${lib_walked_targets})
- endif()
+ foreach(lib_target IN LISTS lib_walked_targets)
+ if(NOT TARGET "${lib_target}")
+ __qt_internal_print_missing_dependency_target_warning(${target}
+ ${lib_target})
+ continue()
+ endif()
+ list(APPEND dep_targets ${lib_target})
+ endforeach()
endif()
endforeach()
endif()