diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-08-02 15:02:23 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2021-08-02 17:40:49 +0200 |
commit | 09cb08ec4cfdb5f370348ed4b91bb2bf0d30a106 (patch) | |
tree | 82aae253584a150836cb9424b2f37be719c2b33c | |
parent | 1f063ba92660de8de04a153fed246d452279b4b0 (diff) |
CMake: Fix Sql dependency to be found when building in-tree examples
When building examples in-tree and not as external projects, the build
system sets QT_NO_CREATE_TARGETS to true.
This means that each find_package() call in an example project assumes
that the Qt target to be found already exists in scope, because the
target must have been found while looking for dependencies for building
the repo itself.
This assumption is not correct, because an example might require extra
Qt dependencies which are not needed for building the repo itself.
Because QT_NO_CREATE_TARGETS causes the QtXyzTargets.cmake file not be
included as part of a find_package() call, the package is considered
not found and it generates a very confusing message.
Work around the issue by specifying Sql to be an optional dependency
when building the repository. This will not be needed once all
repositories have migrated to building examples with ExternalProject
instead.
Fixes: QTBUG-95532
Change-Id: Ied54bc55a5846fe235a833170db733e2998afb9e
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
-rw-r--r-- | CMakeLists.txt | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d448d5b..27f24e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,11 @@ project(quickcalendar find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core QuickControls2 QuickTemplates2) +find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS + # Needed when building examples in-tree + Sql +) + if(NOT TARGET Qt::QuickControls2) message(NOTICE "Skipping the build as the condition \"TARGET Qt::QuickControls2\" is not met.") return() |