C

Qt Quick Ultralite Thermostat Demo

cmake_minimum_required (VERSION 3.21.1)

project(thermo VERSION 0.0.1 LANGUAGES C CXX ASM)
if (NOT TARGET Qul::Core)
    find_package(Qul)
endif()

if(QUL_PLATFORM MATCHES "^ek-ra6m3g")
    qul_add_target(thermo_small
        src/os/${QUL_OS_LOWERCASE}/main.cpp
        QML_PROJECT
        qmlproject/thermo_ek-ra6m3g.qmlproject
        SELECTORS small
    )
elseif(QUL_PLATFORM MATCHES "^stm32")
    if (NOT QUL_PLATFORM MATCHES "^stm32f7" AND NOT QUL_PLATFORM MATCHES "^stm32f4")
        qul_add_target(thermo_small
             src/os/${QUL_OS_LOWERCASE}/main.cpp
             QML_PROJECT
             qmlproject/thermo_stm32.qmlproject
             SELECTORS small
        )
    endif()
elseif (QUL_PLATFORM STREQUAL "mimxrt1064-evk-baremetal" OR QUL_PLATFORM STREQUAL "mimxrt1064-evk-freertos")
    qul_add_target(thermo_small
        src/os/${QUL_OS_LOWERCASE}/main.cpp
        QML_PROJECT
        qmlproject/thermo_mimxrt1064.qmlproject
        SELECTORS small
    )
else()
    qul_add_target(thermo_small
        src/os/${QUL_OS_LOWERCASE}/main.cpp
        QML_PROJECT
        qmlproject/thermo.qmlproject
        SELECTORS small
        )
endif()

if(QUL_PLATFORM STREQUAL "ek-ra6m3g-freertos")
    # default FreeRTOS heap size 220k
    math(EXPR heap_size "250 * 1024")
    add_compile_definitions(configTOTAL_HEAP_SIZE=${heap_size})
endif()

if (QUL_PLATFORM STREQUAL "mimxrt1050-evk-freertos" OR QUL_PLATFORM STREQUAL "mimxrt1064-evk-freertos")
    # default FreeRTOS heap size 256k
    math(EXPR heap_size "2304 * 1024")
    add_compile_definitions(configTOTAL_HEAP_SIZE=${heap_size})
endif()

if(QUL_PLATFORM MATCHES "^stm32h7")
    math(EXPR text_cache_size "32 * 1024")
    target_compile_definitions(thermo_small PRIVATE APP_TEXT_CACHE_SIZE=${text_cache_size})
endif()

if(TARGET thermo_small)
    app_target_setup_os(thermo_small)
endif()

# FIXME: the if below should be changed to
# if (NOT "thermo_big" IN_LIST QUL_PLATFORM_EXCLUDED_DEMOS)
# Assets currently too big for devices (except stm32s)
if(QUL_PLATFORM STREQUAL "qt" OR QUL_PLATFORM MATCHES "^stm32f7" OR QUL_PLATFORM MATCHES "^stm32f4")
    if(QUL_PLATFORM STREQUAL "qt")
        qul_add_target(thermo_big
            src/os/${QUL_OS_LOWERCASE}/main.cpp
            QML_PROJECT
            qmlproject/thermo.qmlproject
            SELECTORS big)
    elseif(QUL_PLATFORM MATCHES "^stm32f7" OR QUL_PLATFORM MATCHES "^stm32f4")
        qul_add_target(thermo_big
            src/os/${QUL_OS_LOWERCASE}/main.cpp
            QML_PROJECT
            qmlproject/thermo_stm32.qmlproject
            SELECTORS big)
    endif()

    if(QUL_PLATFORM MATCHES "^stm32f4")
        math(EXPR text_cache_size "48 * 1024")
        target_compile_definitions(thermo_big PRIVATE APP_TEXT_CACHE_SIZE=${text_cache_size})
    endif()

    if(QUL_PLATFORM MATCHES "^stm32f7")
        math(EXPR text_cache_size "64 * 1024")
        target_compile_definitions(thermo_big PRIVATE APP_TEXT_CACHE_SIZE=${text_cache_size})
        if (QUL_OS STREQUAL "FreeRTOS")
            # 200 kB is the default heap size for STM32F769i, but we need to add
            # space for the text cache as well and the dynamic QML loader
            math(EXPR heap_size "210 * 1024 + ${text_cache_size}")
            add_compile_definitions(configTOTAL_HEAP_SIZE=${heap_size})
        endif()
    endif()

    app_target_setup_os(thermo_big)
endif()