summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-02-21 15:36:09 +0100
committerAlexandru Croitor <alexandru.croitor@qt.io>2022-03-10 15:38:43 +0100
commit71556f51d88199f1f5258a560d588df4d9aed7ca (patch)
tree26fe444a90eb0a8c99ad99e8b55288801ff789a1 /CMakeLists.txt
parent2503453da04181a350e2a2833fe0fdcd6e6141c4 (diff)
downloadqtsvg-71556f51d88199f1f5258a560d588df4d9aed7ca.tar.gz
CMake: Fix finding bundled svg with an in-tree examples build
When Qt is configure with -qt-zlib (like our Windows configs in CI) we create a QtZlibPrivate target and install it. QtSvg depends on this targets. When building examples in-tree (not as external projects) find_package(Qt6Svg) in the example projects will call find_dependency(Qt6Zlib). Currently that will fail with Found package configuration file: lib/cmake/Qt6ZlibPrivate/Qt6ZlibPrivateConfig.cmake but it set Qt6ZlibPrivate_FOUND to FALSE so package "Qt6ZlibPrivate" is considered to be NOT FOUND. Reason given by package: Target "Qt6::ZlibPrivate" was not found. Possibly due to QT_NO_CREATE_TARGETS being set to TRUE It's true, we set QT_NO_CREATE_TARGETS to FALSE when configuring examples, to prevent duplicate target creation. But the Zlib target was not created, because we didn't find_package it explicitly before configuring examples. Work around it by explicitly looking for the package before examples are built. Pick-to: 6.2 6.3 Change-Id: If5c474d62a2939bc32373b2e92d3151f377f51bc Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt9
1 files changed, 9 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c30196..d18be90 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,4 +12,13 @@ project(QtSvg
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core) # special case
find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS Gui Widgets Xml) # special case
+
+# Needed for examples to configure properly when not using ExternalProject and when
+# Qt is configured with a bundled zlib.
+# Otherwise Qt6SvgDependencies will claim Qt6ZlibPrivate_FOUND is FALSE because we
+# set QT_NO_CREATE_TARGETS to TRUE when building examples in-tree.
+if(NOT QT_FEATURE_system_zlib)
+ find_package(Qt6 ${PROJECT_VERSION} QUIET CONFIG OPTIONAL_COMPONENTS ZlibPrivate)
+endif()
+
qt_build_repo()