C

Qt Quick Ultralite 温度控制器演示

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")
    string(TOUPPER ${CMAKE_BUILD_TYPE} build_type)
    if(build_type STREQUAL "RELEASE" OR build_type STREQUAL "DEBUG")
        message(WARNING "For Release or Debug builds, thermo demo binary may not fit in internal flash of EK-RA6M3G board. Sections QulResourceDataExtFlash and QulFontResourceDataExtFlash can be used to move image or font data into the external flash memory.")
    endif()

    qul_add_target(thermo_small
        src/os/${QUL_OS_LOWERCASE}/main.cpp
        QML_PROJECT
        qmlproject/thermo_ek-ra6m3g.qmlproject
        SELECTORS small normal
    )

    qul_add_target(thermo_small_benchmark
        src/os/${QUL_OS_LOWERCASE}/main.cpp
        QML_PROJECT
        qmlproject/thermo_ek-ra6m3g.qmlproject
        SELECTORS small benchmark
    )
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 normal
        )
        qul_add_target(thermo_small_benchmark
             src/os/${QUL_OS_LOWERCASE}/main.cpp
             QML_PROJECT
             qmlproject/thermo_stm32.qmlproject
             SELECTORS small benchmark
        )
    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 normal
    )

    qul_add_target(thermo_small_benchmark
        src/os/${QUL_OS_LOWERCASE}/main.cpp
        QML_PROJECT
        qmlproject/thermo_mimxrt1064.qmlproject
        SELECTORS small benchmark
    )
else()
    qul_add_target(thermo_small
        src/os/${QUL_OS_LOWERCASE}/main.cpp
        QML_PROJECT
        qmlproject/thermo.qmlproject
        SELECTORS small normal
        )

    qul_add_target(thermo_small_benchmark
        src/os/${QUL_OS_LOWERCASE}/main.cpp
        QML_PROJECT
        qmlproject/thermo.qmlproject
        SELECTORS small benchmark
        )
endif()

if(QUL_PLATFORM STREQUAL "ek-ra6m3g-freertos")
    # default FreeRTOS heap size 250k
    qul_override_freertos_heap_size(thermo_small "250 * 1024")
    qul_override_freertos_heap_size(thermo_small_benchmark "250 * 1024")
endif()

if (QUL_PLATFORM STREQUAL "mimxrt1050-evk-freertos" OR QUL_PLATFORM STREQUAL "mimxrt1064-evk-freertos")
    # default FreeRTOS heap size 2304k
    qul_override_freertos_heap_size(thermo_small "2304 * 1024")
    qul_override_freertos_heap_size(thermo_small_benchmark "2304 * 1024")
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})
    target_compile_definitions(thermo_small_benchmark PRIVATE APP_TEXT_CACHE_SIZE=${text_cache_size})
endif()

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

if(TARGET thermo_small_benchmark)
    qul_get_module_target(benchmark_module_target thermo_small_benchmark mode/+benchmark/benchmark_module.qmlproject)
    target_sources(${benchmark_module_target} PRIVATE mode/+benchmark/simulation/flickControl.cpp)

    app_target_setup_os(thermo_small_benchmark)
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 normal)

        qul_add_target(thermo_big_benchmark
            src/os/${QUL_OS_LOWERCASE}/main.cpp
            QML_PROJECT
            qmlproject/thermo.qmlproject
            SELECTORS big benchmark)
    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 normal)

        qul_add_target(thermo_big_benchmark
            src/os/${QUL_OS_LOWERCASE}/main.cpp
            QML_PROJECT
            qmlproject/thermo_stm32.qmlproject
            SELECTORS big benchmark)
    endif()

    qul_get_module_target(benchmark_module_target thermo_big_benchmark mode/+benchmark/benchmark_module.qmlproject)
    target_sources(${benchmark_module_target} PRIVATE mode/+benchmark/simulation/flickControl.cpp)

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

    if(QUL_PLATFORM MATCHES "^stm32f7")
        math(EXPR text_cache_size "120 * 1024")
        target_compile_definitions(thermo_big PRIVATE APP_TEXT_CACHE_SIZE=${text_cache_size})
        target_compile_definitions(thermo_big_benchmark 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
            qul_override_freertos_heap_size(thermo_big "230 * 1024 + ${text_cache_size}")
            qul_override_freertos_heap_size(thermo_big_benchmark "230 * 1024 + ${text_cache_size}")
        endif()
    endif()

    app_target_setup_os(thermo_big)
    app_target_setup_os(thermo_big_benchmark)

endif()