C
Qt Quick Ultralite map example
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() # On Linux / 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") set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${TILES_BASE_DIR}") set(DEST_DIR "${CMAKE_CURRENT_BINARY_DIR}/${TILES_BASE_DIR}") file(COPY ${SOURCE_DIR} DESTINATION ${DEST_DIR}) qul_add_target(map QML_PROJECT mcu_map.qmlproject os/baremetal/main.cpp ) 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 ../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}/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) endif()