ARM-software / Arm-2D

2D Graphic Library optimized for Cortex-M processors
Apache License 2.0
298 stars 66 forks source link

More documentation for building with cmake #42

Open christophe0606 opened 1 year ago

christophe0606 commented 1 year ago

There is a new cmake build but more information is needed.

An example CMakeLists.txt could look like this one (not yet tested):


# Because we are adding sub directories that are not subfolder of the project
cmake_policy(SET CMP0079 NEW)

project(arm2d_demo_examples C CXX ASM)

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

# For GCC. Change if you use different compiler.
add_compile_options(
    -g
    -ffunction-sections 
    -fdata-sections
    -Ofast)

add_link_options(-flto)

add_executable(arm2d_demo  main.c ...)

# If you include Arm2D headers from any CPP file you need to at least
# disable those warnings 
# (but there will be other warnings)
set_source_files_properties(anycppfile.cpp PROPERTIES COMPILE_FLAGS -Wno-subobject-linkage)

# Add platform sources
# This must be copied from Arm-2D project template folder and customized
target_sources(arm2d_demo PUBLIC platform/arm_2d_disp_adapter_0.c)

#When building on host (for instance Mac) you may want to add this
#target_compile_definitions(arm2d_demo PRIVATE _THREAD_SAFE SDL_DISABLE_ARM_NEON_H)

# Add CMSIS-DSP project
# Set to ON when building on host (Mac for instance). OFF for embedded
option(HOST "" OFF)
add_subdirectory(${CMSISDSP}/Source bin_dsp)

# Add Arm2D project
# Define the options before adding the project

# Set to ON when building on host (Mac for instance). To OFF for embedded.
option(ARM2D_HOST "" OFF)

option(ARM2D_CONTROLS "" ON)
option(ARM2D_HELPER "" ON)
option(ARM2D_LCD_PRINTF "" ON)
option(ARM2D_BENCHMARK_GENERIC "" OFF)
option(ARM2D_BENCHMARK_WATCHPANEL "" OFF)
option(ARM2D_ALPHA_BLENDING "" ON)
option(ARM2D_TRANSFORM "" ON)

add_subdirectory(${ARM2D} arm2d_demo_bin)

# Some Arm2D headers must be copied into platform and customized
# Those headers can be found in the Arm-2D template folder
target_include_directories(ARM2D PUBLIC platform)

# Link libs ARM2D depends on CMSISDSP
# and the app depends on Arm2D 
# CMSISDSP -> Arm-2D
target_link_libraries(ARM2D PUBLIC CMSISDSP)
# Arm-2D -> Your app
target_link_libraries(arm2d_demo PUBLIC ARM2D)

# Include SDL if building on host
#target_include_directories(arm2d_demo PUBLIC ${SDL2_INCLUDE_DIR})
#target_link_directories(arm2d_demo PUBLIC ${SDL2_LIBRARY})
# Link SDL
#target_link_libraries(arm2d_demo PUBLIC SDL2main SDL2)

# If SDL used, you'll need support file in the Platform folder. 
# It can be found in Arm-2D example folders