C

Qt Quick Ultralite styling Example

# Copyright (C) 2026 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial
cmake_minimum_required(VERSION 3.21.1)

project(styling VERSION 0.0.1 LANGUAGES C CXX ASM)

find_package(QulApp)

# The same styling.qml is built twice, once against the default QtQuick.Controls
# style and once against the custom one. The style is chosen by the
# QUL_CONTROLS_STYLE property, which qmltocpp applies while compiling the
# module's QML, so each variant needs its own module. They share the URI, and
# OUTPUT_DIRECTORY keeps the generated files apart.

# Default style version
if(QUL_PLATFORM MATCHES "autosar")
    qul_add_library(styling_default)
else()
    qul_add_executable(styling_default)
endif()

qul_add_qml_module(styling_default
    URI StylingApp
    OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/default
    QML_FILES styling.qml
    NO_SBOM
)

target_link_libraries(styling_default PRIVATE Qul::Controls)

app_target_setup_os(styling_default)
app_target_default_entrypoint(styling_default styling MODULE StylingApp)

# Custom style version
add_subdirectory(CustomControls)

if(QUL_PLATFORM MATCHES "autosar")
    qul_add_library(styling_custom)
else()
    qul_add_executable(styling_custom)
endif()

qul_add_qml_module(styling_custom
    URI StylingApp
    OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/custom
    QML_FILES styling.qml
    NO_SBOM
)

set_target_properties(styling_custom PROPERTIES QUL_CONTROLS_STYLE CustomControls)
target_link_libraries(styling_custom PRIVATE styling_custom_style)

app_target_setup_os(styling_custom)
app_target_default_entrypoint(styling_custom styling MODULE StylingApp)