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 <alexey.edelev@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Alexandru Croitor 2025-09-15 14:35:35 +02:00
parent 0e45b15f10
commit 1e5a63f7a3
2 changed files with 11 additions and 5 deletions

View File

@ -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)
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.

View File

@ -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})