C

Qt Quick Ultralite static_library Example

cmake_minimum_required (VERSION 3.15)

project(static_library_example VERSION 0.0.1 LANGUAGES C CXX ASM)
if (NOT TARGET Qul::Core)
    find_package(Qul)
endif()

if(QUL_OS STREQUAL "FreeRTOS")
    message(STATUS "Static library example is disabled for FreeRTOS based platforms")
    return()
endif()

set(EXAMPLE_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})

# Add configuration of Qt4MCU_GUI target for prebuild step
add_subdirectory(lib/Qt_for_MCU)

add_executable(static_library_example
        src/main.cpp
)

# If QUL GUI library has IPO enabled then we need also enable it for our target
get_target_property(QUL_LIB_IPO_CONFIG Qt4MCU_GUI INTERPROCEDURAL_OPTIMIZATION)
set_target_properties(static_library_example PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${QUL_LIB_IPO_CONFIG})

target_include_directories(static_library_example
    PRIVATE
        # Add include folder from QtForMCU installation folder
        ${Qul_DIR}/include
        # Add folder containing qul_run.h header file
        ${CMAKE_CURRENT_BINARY_DIR}/lib/Qt_for_MCU
        # Add folder containing sensorAPI.h header file
        ${CMAKE_CURRENT_SOURCE_DIR}/include
)

target_link_libraries(static_library_example
    PRIVATE
        # Static library containing UI and interfaces
        Qt4MCU_GUI
        # Static library with Qt QuickUltralite Core
        Qul::Core
        # Static library with Qt QuickUltralite Platform abstraction.
        # Should be replaced by custom implementation adapted to target board
        Qul::Platform
        # All additional Qul libraries used by QtForMCU GUI needs to be also
        # linked with application
        Qul::Controls
        # Satisfy cyclic dependency between Qt4MCU_GUI and Qul::Core
        # libraries (Qul::Core depends on symbols autogenerated
        # in Qt4MCU_GUI build process)
        Qul::Core
        Qt4MCU_GUI
)

target_link_libraries(static_library_example PRIVATE Qul::PlatformDefaultLinkerScript)

if(CMAKE_CROSSCOMPILING)
    set(CMAKE_EXECUTABLE_SUFFIX ".elf")
endif()