C
Qt Quick Ultralite map example
# Copyright (C) 2025 The Qt Company Ltd.
# SPDX-License-Identifier: LicenseRef-Qt-Commercial
cmake_minimum_required (VERSION 3.21.1)
project(map VERSION 0.0.1 LANGUAGES C CXX ASM)
if (NOT TARGET Qul::Core)
find_package(Qul)
endif()
if (QUL_PLATFORM STREQUAL "qt")
find_package(Qt6 6.2 COMPONENTS Gui QUIET)
if(NOT Qt6Gui_FOUND)
set(DEFAULT_QT6_VERSION 6.2.4)
if(WIN32)
set(DEFAULT_QT6_PATH C:\\Qt\\${DEFAULT_QT6_VERSION}\\msvc2019_64)
else()
set(DEFAULT_QT6_PATH $HOME/Qt/${DEFAULT_QT6_VERSION}/gcc_64)
endif()
message(FATAL_ERROR "Qt6 is required to build the map example. "
"Use -DCMAKE_PREFIX_PATH=${DEFAULT_QT6_PATH} or similar to specify the location of Qt6, "
"depending on which Qt version is used and where it is installed. "
"Alternatively, check the documentation for this example for more detailed instructions."
)
endif()
qul_add_target(map
QML_PROJECT mcu_map.qmlproject
os/baremetal/main.cpp
)
# On desktop the files by default need to be available next
# to the built binary on the filesystem
set(TILES_BASE_DIR "offline_tiles_provider/tiles/")
set(PLACEHOLDER_TILE "${TILES_BASE_DIR}placeholder-tile.jpeg")
add_custom_command(
TARGET map POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo
"Copying map tiles to $<TARGET_FILE_DIR:map>/${TILES_BASE_DIR}"
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/${TILES_BASE_DIR}
$<TARGET_FILE_DIR:map>/${TILES_BASE_DIR}
COMMENT "Copying map tiles to build directory"
)
target_compile_definitions(map PRIVATE
TILES_BASE_DIR="${TILES_BASE_DIR}"
PLACEHOLDER_TILE="${PLACEHOLDER_TILE}"
MAX_CACHE_SIZE=100
)
target_link_libraries(map PRIVATE Qt6::Gui)
target_include_directories(map PRIVATE
../fileloading/posix/
../imagedecoder/desktop/
)
target_sources(map PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/desktop/board_config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/offline_tiles_provider/offlinetilefetcher.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dummy_position_source/dummypositionsource.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dummy_position_source/dummypositiondata.cpp
../imagedecoder/desktop/desktopimagedecoder.cpp
../fileloading/posix/posixfilesystem.cpp
)
target_compile_features(map PRIVATE cxx_std_17)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(map PRIVATE -Wno-maybe-uninitialized) # desktopimagedecoder.cpp:129ff read into a byte array.
endif()
elseif(QUL_PLATFORM MATCHES "^stm32u5")
# user sets it to the location of tiles images on an external storage
set(TILES_BASE_DIR "tiles/")
set(PLACEHOLDER_TILE "${TILES_BASE_DIR}placeholder-tile.jpeg")
if (QUL_PLATFORM_ENABLE_EMMC)
set(STM32XX "stm32u5")
qul_add_target(map
QML_PROJECT mcu_map.qmlproject
os/${QUL_OS_LOWERCASE}/main.cpp
)
target_compile_definitions(map PRIVATE
TILES_BASE_DIR="${TILES_BASE_DIR}"
PLACEHOLDER_TILE="${PLACEHOLDER_TILE}"
MAX_CACHE_SIZE=40
USE_JPEG_DECODER=1
#USE_DMA_BASED_JPEG_DECODING
SUPPORT_FILESYSTEM
FF_FS_READONLY
)
target_sources(map PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/offline_tiles_provider/offlinetilefetcher.cpp
${CMAKE_CURRENT_SOURCE_DIR}/stm/${STM32XX}/board_config.cpp
${QUL_BOARD_SDK_DIR}/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_dma_ex.c
${QUL_BOARD_SDK_DIR}/Drivers/STM32U5xx_HAL_Driver/Src/stm32u5xx_hal_jpeg.c
../fileloading/3rdparty/FatFs/src/diskio.c
../fileloading/3rdparty/FatFs/src/ff.c
../fileloading/3rdparty/FatFs/src/ff_gen_drv.c
../fileloading/3rdparty/FatFs/src/option/unicode.c
../imagedecoder/3rdparty/stm/Utilities/JPEG/jpeg_utils.c
../imagedecoder/common/jpeg.cpp
../imagedecoder/stm/${STM32XX}/buffer_config.cpp
../imagedecoder/stm/${STM32XX}/stm32u5xx_hal_msp.c
../imagedecoder/stm/stmimagedecoder.cpp
)
target_include_directories(map PRIVATE
${QUL_PLATFORM_BOARDS_DIR}/st/stm32u5x9-discovery-common
../fileloading/
../fileloading/3rdparty/FatFs/src/
../imagedecoder/stm/${STM32XX}
../imagedecoder/stm
${QUL_BOARD_SDK_DIR}/Utilities/JPEG
)
target_link_libraries(map PRIVATE Qul::PlatformBSPConfig)
else ()
message(WARNING "For the image decoder to load from a filesystem, "
"QUL_PLATFORM_ENABLE_EMMC needs to be enabled. "
"Without eMMC, you have to change the QML project to not load "
"the images from external storage")
endif()
if(NOT IAR)
target_compile_options(map PRIVATE -Wno-unused-parameter)
endif()
elseif(QUL_PLATFORM MATCHES "^stm32f769i")
set(STM32XX "stm32f7")
qul_add_target(map
QML_PROJECT mcu_map.qmlproject
os/baremetal/main.cpp
)
# user sets it to the location of tiles images on an external storage
set(TILES_BASE_DIR "tiles/")
set(PLACEHOLDER_TILE "${TILES_BASE_DIR}placeholder-tile.jpeg")
target_compile_definitions(map PRIVATE
TILES_BASE_DIR="${TILES_BASE_DIR}"
PLACEHOLDER_TILE="${PLACEHOLDER_TILE}"
MAX_CACHE_SIZE=40
)
target_include_directories(map PRIVATE
../fileloading/3rdparty/FatFs/src
../fileloading/fatfs
../imagedecoder/stm/${STM32XX}
../imagedecoder/stm
${QUL_BOARD_SDK_DIR}/Utilities/JPEG
)
target_sources(map PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/offline_tiles_provider/offlinetilefetcher.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dummy_position_source/dummypositionsource.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dummy_position_source/dummypositiondata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/stm/${STM32XX}/board_config.cpp
)
# file system sources
target_sources(map PRIVATE
../fileloading/3rdparty/FatFs/src/diskio.c
../fileloading/3rdparty/FatFs/src/ff.c
../fileloading/3rdparty/FatFs/src/ff_gen_drv.c
../fileloading/3rdparty/FatFs/src/sd_diskio.c
../fileloading/3rdparty/FatFs/src/option/unicode.c
${QUL_BOARD_SDK_DIR}/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_sdmmc.c
${QUL_BOARD_SDK_DIR}/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_sd.c
${QUL_BOARD_SDK_DIR}/Drivers/BSP/STM32F769I-Discovery/stm32f769i_discovery_sd.c
)
# jpeg decoder sources
target_sources(map PRIVATE
${QUL_BOARD_SDK_DIR}/Drivers/STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_jpeg.c
../imagedecoder/stm/${STM32XX}/stm32f7xx_hal_msp.c
../imagedecoder/stm/${STM32XX}/buffer_config.cpp
../imagedecoder/stm/stmimagedecoder.cpp
../imagedecoder/common/jpeg.cpp
../imagedecoder/3rdparty/stm/Utilities/JPEG/jpeg_utils.c
)
target_compile_definitions(map PRIVATE
FF_FS_READONLY
DISABLE_SD_INIT
USE_JPEG_DECODER=1
USE_DMA_BASED_JPEG_DECODING
PLATFORM_OS=baremetal
)
target_link_libraries(map PRIVATE Qul::PlatformBSPConfig)
if(NOT IAR)
target_compile_options(map PRIVATE -Wno-unused-parameter)
endif()
app_target_setup_os(map)
elseif(QUL_PLATFORM MATCHES "^tviic2d" AND NOT ARMGCC)
if(QUL_PLATFORM MATCHES "^tviic2d4m")
set(VARIANT "4m")
elseif(QUL_PLATFORM MATCHES "^tviic2d6m")
set(VARIANT "6m")
# In CI we test with the 500-BGA variant with graphics driver TVII_GRAPHICS_DRIVER_DIR_1_1_0_4M6M
# (infineon-traveo-t2g-cyt4dn-baremetal-500-bga-windows-ghs-arm)
# and to be able to build the imagedecoder backend an SDL upgrade is required.
if(QUL_TVIIC2D6M_BOARD_REVISION STREQUAL "500-BGA")
return()
endif()
else()
return()
endif()
qul_add_target(map
QML_PROJECT mcu_map_t2g_${VARIANT}.qmlproject
SELECTORS t2g ${VARIANT}
)
target_sources(map PRIVATE
os/baremetal/main.cpp
)
# user sets it to the location of tiles images on an external storage
set(TILES_BASE_DIR "tiles/")
set(PLACEHOLDER_TILE "${TILES_BASE_DIR}placeholder-tile.jpeg")
target_compile_definitions(map PRIVATE
TILES_BASE_DIR="${TILES_BASE_DIR}"
PLACEHOLDER_TILE="${PLACEHOLDER_TILE}"
MAX_CACHE_SIZE=40
)
target_sources(map PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/offline_tiles_provider/offlinetilefetcher.cpp
${CMAKE_CURRENT_SOURCE_DIR}/t2g-traveo/board_config.cpp
)
if(QUL_PLATFORM MATCHES "^tviic2d6m[^-]*-baremetal")
set(TRAVEO_T2G_IMAGEDECODER_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../imagedecoder/traveo-t2g")
include("${TRAVEO_T2G_IMAGEDECODER_SOURCE_DIR}/tvii_jpeg_driver_lib.cmake") # will provide `TVII_JPEG_DRIVER_LIB`.
target_sources(map PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../imagedecoder/traveo-t2g/traveot2gimagedecoder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../imagedecoder/traveo-t2g/tvii_jpeg.c
${CMAKE_CURRENT_SOURCE_DIR}/../imagedecoder/common/jpeg.cpp
)
target_compile_definitions(map PRIVATE T2G_JPEG_SUPPORT_ENABLED)
list(APPEND CMAKE_MODULE_PATH ${QUL_PLATFORM_TARGET_DIR}/../common/cmake/modules)
# Old path needed for platform compatibility checks after UL-5159 (renamed folder from tvii-shared to common)
list(APPEND CMAKE_MODULE_PATH ${QUL_PLATFORM_TARGET_DIR}/../tvii-shared/cmake/modules)
find_package(TVII-SDK REQUIRED COMPONENTS basic_graphics util freetype)
target_include_directories(map PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/../imagedecoder/traveo-t2g/
${TVII_JPEG_DRIVER_DIR}/Source/jpgdec/include
${TVII_SDK_INCLUDE_DIRS}
)
target_link_libraries(map PRIVATE Qul::PlatformBSPConfig ${TVII_JPEG_DRIVER_LIB})
if(GREENHILLS)
target_link_libraries(map PRIVATE -T ${CMAKE_CURRENT_SOURCE_DIR}/../imagedecoder/traveo-t2g/JPEGDEC_register_map.ld)
endif()
if(IAR)
target_compile_options(map PRIVATE --diag_suppress=Pe940) # Pe940 missing return statement at end of non-void function (graphics driver 1.2.1)
endif()
endif()
app_target_setup_os(map)
endif()