C
Qt Quick Ultralite Automotive Cluster Demo
cmake_minimum_required (VERSION 3.15)
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 AND NOT IAR)
add_compile_options(-Wno-c++11-compat)
endif()
include(src/3rdparty/etl/CMakeLists.txt)
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)
qul_add_target(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
)
set_property(TARGET automotive APPEND PROPERTY QUL_FONTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fonts)
if (OS MATCHES "FreeRTOS")
# Use heap_5 policy and custom FreeRTOSConfig.h
set_property(TARGET automotive PROPERTY FREERTOS_HEAP_POLICY "heap_5")
target_include_directories(automotive PRIVATE ${TARGET_PLATFORM_DIR})
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
${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)
target_include_directories(automotive PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
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/white-line-right.png
images/setup.png
images/play.png
images/ready.png
images/top-line.png
images/gauge-gauge-frame.png
images/oil-temp.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/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
PerformanceMetrics.qml
PerformanceMetricItem.qml
NormalMode.qml
NormalModeContentItem.qml
SportMode.qml
MediaPlayer.qml
Phone.qml
CarStatus.qml
LaneAssist.qml
LaneAssistWhiteLine.qml
Navi.qml
Menu.qml
BaseGauge.qml
Gauge.qml
MiddleGauge.qml
SportGauge.qml
TempGauge.qml
GuideArrow.qml
GuideArrowItem.qml
SpeedWarningIndicator.qml
LinearGauge.qml
TellTales.qml
TellTalesIndicator.qml
DriveModeSelector.qml
)
qul_add_qml_module(automotive_module
URI Automotive
QML_FILES
imports/Automotive/NormalModeModel.qml
imports/Automotive/SportModeModel.qml
imports/Automotive/MainModel.qml
imports/Automotive/PhoneModel.qml
imports/Automotive/MediaPlayerModel.qml
imports/Automotive/Style.qml
imports/Automotive/TellTalesModel.qml
imports/Automotive/SettingsMenuModel.qml
imports/Automotive/MathAPI.qml
imports/Automotive/NaviModel.qml
${UNIT_SYSTEM}/Units.qml
${UNIT_SYSTEM}/SpeedLimitValues.qml
${UNIT_SYSTEM}/SpeedLimitImage.qml
region/${DEMO_REGION}/Region.qml
SOURCES
src/connectivityservice.cpp
HEADERS
src/connectivityservice.h
OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/modules # avoid Automotive/ and automotive in the same dir
)
qul_add_resource(automotive_module
FILES
images/arrow-0.png
images/arrow-45.png
images/arrow-90.png
images/arrow-round.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
)
target_include_directories(automotive_module PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
target_link_libraries(automotive automotive_etl automotive_module)
app_target_setup_os(automotive)