C

Telltales: Rendering Safety-Critical UI

cmake_minimum_required(VERSION 3.16)
project(telltales LANGUAGES CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(CMAKE_AUTOMOC OFF)
set(CMAKE_AUTORCC OFF)

if(NOT DEFINED INSTALL_EXAMPLESDIR)
  set(INSTALL_EXAMPLESDIR "examples")
endif()

find_package(Qt6 REQUIRED COMPONENTS Core Quick SafeRenderer SafeRendererTools SafePlatformAdaptation)

set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}")

set (safeqmls
    ${CMAKE_CURRENT_LIST_DIR}/../qtcluster/qml/dash_hybrid/DashboardForm.ui.qml
    ${CMAKE_CURRENT_LIST_DIR}/../qtcluster/qml/dash_sports/DashboardSportForm.ui.qml
)

# Resource files are passed to qtsafelayouttool
set(resource_files
    ${CMAKE_CURRENT_LIST_DIR}/../qtcluster/hybridimages.qrc
    ${CMAKE_CURRENT_LIST_DIR}/../qtcluster/hybridqml.qrc
    ${CMAKE_CURRENT_LIST_DIR}/../qtcluster/images.qrc
    ${CMAKE_CURRENT_LIST_DIR}/../qtcluster/iso-icons.qrc
    ${CMAKE_CURRENT_LIST_DIR}/../qtcluster/qtcluster.qrc
    ${CMAKE_CURRENT_LIST_DIR}/../qtcluster/sportsimages.qrc
    ${CMAKE_CURRENT_LIST_DIR}/../qtcluster/sportsqml.qrc
)

set(sources
    main.cpp
)

#resource.bin is loaded by qtsafelayouttool to find the resource data asset.
qt6_add_binary_resources(resources_telltales ${resource_files} DESTINATION resource.bin)
qsr_add_safelayout(generatelayout_telltales SAFE_QMLS ${safeqmls}
                                  OUTPUT_PATH ${CMAKE_CURRENT_LIST_DIR}/layoutData
                                  SAFE_LAYOUT_FONTS "${CMAKE_CURRENT_LIST_DIR}/../qtcluster/fonts"
                                  SAFE_RESOURCE "${CMAKE_CURRENT_LIST_DIR}/safeasset.qrc"
                                  INPUT_RESOURCES resource.bin)
qsr_add_resource(buildresource_telltales sources "${CMAKE_CURRENT_LIST_DIR}/safeasset.qrc")

add_executable(telltales WIN32 MACOSX_BUNDLE
    ${sources}
)

add_dependencies(telltales generatelayout_telltales)

if(NOT CMAKE_CROSSCOMPILING)
    target_compile_definitions(telltales PUBLIC
        HOST_BUILD
    )

    target_link_libraries(telltales PUBLIC
        Qt::Quick
        Qt::Widgets
        Qt::Qml
    )
endif()

target_link_libraries(telltales PUBLIC
    Qt::SafeRenderer
    Qt::SafePlatformAdaptation
)

install(TARGETS telltales
    RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
    BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
    LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)