aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-09-27 14:12:25 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-09-28 15:39:26 +0000
commit8f5eb66a0f4d203b0ebaf449c32505810b845d1b (patch)
treea0c1cd5dda6ecead10df10d6e5572dd7e678f13c
parent71df9aba407feb076da40032221bded13191855b (diff)
CMake: Fix warning about ShaderTools not being found when building examples
When building examples in-tree in a prefix build, we set QT_NO_CREATE_TARGETS to TRUE and that causes find_package(QtFoo) calls in example projects not to define targets. If the targets were not found previously as part of the find_package calls in qtdeclarative/CMakeLists.txt, this generates warnings like CMake Warning at lib/cmake/Qt6/Qt6Config.cmake:176 (find_package): Found package configuration file: lib/cmake/Qt6ShaderTools/Qt6ShaderToolsConfig.cmake but it set Qt6ShaderTools_FOUND to FALSE so package "Qt6ShaderTools" is considered to be NOT FOUND. Reason given by package: Target "Qt6::ShaderTools" was not found. Possibly due to QT_NO_CREATE_TARGETS being set to TRUE and thus lib/cmake/Qt6ShaderTools/Qt6ShaderToolsTargets.cmake was not included to define the target. To avoid the warnings, search for the target ShaderTools package as an optional component. Amends 0d517b553bb8e94262d54439d3e16086896c1b7d Fixes: QTBUG-96358 Change-Id: I50c2f1516ca26c099559001e74b7e25c625be6e6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit 828cbe57a1690c843f4e3de258d465160e599f95) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--CMakeLists.txt5
1 files changed, 5 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 186d0a29f9..9996810794 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -39,6 +39,11 @@ if(NOT "${QT_HOST_PATH}" STREQUAL "")
set(CMAKE_FIND_ROOT_PATH ${_qt_backup_qtdeclarative_CMAKE_FIND_ROOT_PATH})
endif()
+# Optionally look for the target ShaderTools package to avoid warnings
+# when configuring the project to build examples in-tree in a prefix Qt build.
+# See QTBUG-96358 for details.
+find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS ShaderTools)
+
# special case begin
# export QT6_ADD_QML_MODULE to this project
include(src/qml/Qt6QmlMacros.cmake)