aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-09-27 14:12:25 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-09-28 08:14:21 +0200
commit828cbe57a1690c843f4e3de258d465160e599f95 (patch)
treee976838c80a85f8ebe30c294686d7a07fa43815f /CMakeLists.txt
parent29946505a35f9f52ddc4f3e09e40c52efefad93d (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 Pick-to: 6.2 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>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt5
1 files changed, 5 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b43ebd075d..1f1eeffb03 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,6 +35,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)