C

Qt Quick Ultralite Automotive Cluster Demo

cmake_minimum_required (VERSION 3.13)

project(automotive VERSION 0.0.1 LANGUAGES C CXX ASM)
if (NOT TARGET Qul::QuickUltralite)
    find_package(Qul)
    get_target_property(includes Qul::QuickUltralite INTERFACE_INCLUDE_DIRECTORIES)
endif()

if(NOT GREENHILLS AND NOT MSVC)
    add_compile_options(-Wno-c++11-compat)
endif()
include(src/3rdparty/etl/CMakeLists.txt)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(QUL_FONTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/fonts,${QUL_FONTS_DIR}")

option(ENABLE_CANBUS "Enable CAN Bus" OFF)
message(STATUS "Enable CAN Bus: ${ENABLE_CANBUS}")

if (ENABLE_CANBUS)
    set(QUL_USE_DEFAULT_RH850_STARTUP_FILE OFF CACHE BOOL "Disable default startup file when CAN support is enabled")
endif()

set(UNIT_SYSTEM "metric" CACHE STRING "Automotive Demo Unit System")
if (NOT DEMO_REGION)
    if (UNIT_SYSTEM STREQUAL "imperial")
        set(DEMO_REGION "usa")
    else()
        set(DEMO_REGION "de")
    endif()
else()
    set(DEMO_REGION ${DEMO_REGION})
endif()
message(STATUS "DEMO_REGION: ${DEMO_REGION}")

string(TOLOWER ${QUL_PLATFORM} QUL_PLATFORM_LOWERCASE)
string(TOLOWER ${OS} OS_LOWERCASE)

add_executable(automotive
    src/platform/${OS_LOWERCASE}/main.cpp
    src/simulationcontroller.cpp
    src/simulation/states.cpp
    src/simulation/drivetrain.cpp
    src/simulation/speedlimits.cpp
    src/simulation/drivestates.cpp
    src/simulation/lights.cpp
    src/connectivityservice.cpp
)

if (OS MATCHES "FreeRTOS")
    # Use heap_5 policy and custom FreeRTOSConfig.h
    set_property(TARGET automotive PROPERTY FREERTOS_HEAP_POLICY "heap_5")
    set_property(TARGET automotive PROPERTY FREERTOS_CONFIG_DIR "src/platform/freertos/${QUL_PLATFORM_LOWERCASE}")
endif()

if (ENABLE_CANBUS)
    add_subdirectory(src/canbus)
    target_compile_definitions(automotive PUBLIC ENABLE_CANBUS)
endif()

add_subdirectory(src/hmi_input)
qul_target_generate_interfaces(automotive OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    ${CMAKE_CURRENT_SOURCE_DIR}/src/hmi_input/hmi_input.h
    ${CMAKE_CURRENT_SOURCE_DIR}/src/hmi_input/hmi_input_event.h
    ${CMAKE_CURRENT_SOURCE_DIR}/src/simulationcontroller.h
    ${CMAKE_CURRENT_SOURCE_DIR}/src/connectivityservice.h)
target_include_directories(automotive PUBLIC
                           includes
                           ${CMAKE_CURRENT_BINARY_DIR}
                           ${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_include_directories(automotive PRIVATE
                           ${CMAKE_CURRENT_SOURCE_DIR}/${UNIT_SYSTEM}
                           ${CMAKE_CURRENT_SOURCE_DIR}/region/${DEMO_REGION}
)

target_link_libraries(automotive Qul::QuickUltralite automotive_etl)
app_target_setup_os(automotive)

set_source_files_properties(
    images/needle-standard-sport.png
    images/highlight-big-sport.png
    images/highlight-normal.png
    images/needle-normal.png
    PROPERTIES QUL_OPTIMIZE_FOR_ROTATION ON)

qul_add_resource(automotive
    FILES
        images/fuel.png
        images/highlight-big-sport.png
        images/high-beams.png
        images/beam.png
        images/white-line-left.png
        images/media-player.png
        images/sport.png
        images/battery.png
        images/pseudo-mask-vertical.png
        images/bg-mask.png
        images/arrow-0.png
        images/white-line-right.png
        images/setup.png
        images/arrow-45.png
        images/play.png
        images/ready.png
        images/top-line.png
        images/arrow-90.png
        images/gauge-gauge-frame.png
        images/oil-temp.png
        images/arrow-round.png
        images/needle-normal.png
        images/airbag.png
        images/turn_right.png
        images/needle-standard-sport.png
        images/leaf.png
        images/gauge-gauge-frame-sport-side.png
        images/red-border-right.png
        images/gauge-gauge-frame-sport-center.png
        images/highlight-normal.png
        images/navi.png
        images/gauge-normal.png
        images/phone.png
        images/red-border-left.png
        images/clock.png
        images/car-highlights.png
        images/assets-phone-list-pseudo-mask.png
        images/road.png
        images/highlight-standard-sport.png
        images/parked.png
        images/speed-limit-warning.png
        images/turn_left.png
        images/photos/beatriz.png
        images/photos/aryn.png
        images/photos/hirini.png
        images/photos/caspar.png
        images/photos/joslin.png
        images/speed-limit-warnings/55mph.png
        images/speed-limit-warnings/70.png
        images/speed-limit-warnings/50.png
        images/speed-limit-warnings/140.png
        images/speed-limit-warnings/90.png
        images/speed-limit-warnings/30.png
        images/speed-limit-warnings/20mph.png
        images/speed-limit-warnings/45mph.png
        images/speed-limit-warnings/35mph.png
        images/speed-limit-warnings/85mph.png
        images/albums/ak.png
        images/albums/thievery-corp.png
        images/albums/phazz.png
        images/albums/tycho.png
        images/albums/juno.png
)

qul_target_qml_sources(automotive
    automotive.qml
    PhoneModel.qml
    NormalModeModel.qml
    SportModeModel.qml
    MainModel.qml
    PerformanceMetrics.qml
    PerformanceMetricItem.qml
    NormalMode.qml
    NormalModeContentItem.qml
    SportMode.qml
    MediaPlayer.qml
    MediaPlayerModel.qml
    Phone.qml
    CarStatus.qml
    LaneAssist.qml
    LaneAssistWhiteLine.qml
    Navi.qml
    NaviModel.qml
    Menu.qml
    BaseGauge.qml
    Gauge.qml
    MiddleGauge.qml
    SportGauge.qml
    TempGauge.qml
    GuideArrow.qml
    GuideArrowItem.qml
    SpeedWarningIndicator.qml
    LinearGauge.qml
    Style.qml
    TellTales.qml
    TellTalesModel.qml
    TellTalesIndicator.qml
    SettingsMenuModel.qml
    DriveModeSelector.qml
    MathAPI.qml
    ${UNIT_SYSTEM}/SpeedLimitValues.qml
    ${UNIT_SYSTEM}/SpeedLimitImage.qml
    ${UNIT_SYSTEM}/Units.qml
    region/${DEMO_REGION}/Region.qml
)