From 1e5a63f7a3a548344dca11d1ce736e2803131d2d Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 15 Sep 2025 14:35:35 +0200 Subject: [PATCH] CMake: Guard examples that use Svg in a qt build without Svg Otherwise one gets errors like the following in standalone examples build: CMake Error at tools/svgtoqml/Qt6SvgToQmlMacros.cmake:65 (add_custom_command): Error evaluating generator expression: $ No target "Qt6::svgtoqml" Because the examples now use the new qt_target_qml_from_svg() function, which will try to reference a non-existent svgtoqml tool target. Change-Id: I16b10c4fa31bd73d0d95bbad371cde54f17c236a Reviewed-by: Alexey Edelev Reviewed-by: Eskil Abrahamsen Blomfeldt --- examples/quick/CMakeLists.txt | 4 +++- examples/quick/quickshapes/CMakeLists.txt | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/examples/quick/CMakeLists.txt b/examples/quick/CMakeLists.txt index 8ab3ef3360..1e7adc5d66 100644 --- a/examples/quick/CMakeLists.txt +++ b/examples/quick/CMakeLists.txt @@ -40,7 +40,9 @@ if(TARGET Qt6::QuickWidgets AND TARGET Qt6::Widgets AND (QT_FEATURE_opengl OR QT endif() add_subdirectory(quickshapes) qt_internal_add_example(advancedtext) -qt_internal_add_example(vectorimage) +if(TARGET Qt6::Svg) + qt_internal_add_example(vectorimage) +endif() # qt_examples_build_end() misses at least some of these due to some # source subdirectories being added multiple times. See QTBUG-96159. diff --git a/examples/quick/quickshapes/CMakeLists.txt b/examples/quick/quickshapes/CMakeLists.txt index e739c3dc89..c65bee6799 100644 --- a/examples/quick/quickshapes/CMakeLists.txt +++ b/examples/quick/quickshapes/CMakeLists.txt @@ -1,12 +1,16 @@ # Copyright (C) 2024 The Qt Company Ltd. # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -qt_internal_add_example(shapes) -qt_internal_add_example(weatherforecast) - # qt_examples_build_end() misses at least some of these due to some # source subdirectories being added multiple times. See QTBUG-96159. -set(reused_dir_targets shapes_shared weatherforecast_shared) +set(reused_dir_targets shapes_shared) + +qt_internal_add_example(shapes) + +if(TARGET Qt6::Svg) + list(APPEND reused_dir_targets weatherforecast_shared) + qt_internal_add_example(weatherforecast) +endif() foreach(target IN LISTS reused_dir_targets) if(TARGET ${target})