xref: /btstack/port/stm32-l451-miromico-sx1280/CMakeLists.txt (revision 2fd737d36a1de5d778cacc671d4b4d8c4f3fed82)
1*2fd737d3SMatthias Ringwald#THIS FILE IS AUTO GENERATED FROM THE TEMPLATE! DO NOT CHANGE!
2*2fd737d3SMatthias RingwaldSET(CMAKE_SYSTEM_NAME Generic)
3*2fd737d3SMatthias RingwaldSET(CMAKE_SYSTEM_VERSION 1)
4*2fd737d3SMatthias Ringwaldcmake_minimum_required(VERSION 3.7)
5*2fd737d3SMatthias Ringwald
6*2fd737d3SMatthias Ringwald# specify cross compilers and tools
7*2fd737d3SMatthias RingwaldSET(CMAKE_C_COMPILER_WORKS 1)
8*2fd737d3SMatthias RingwaldSET(CMAKE_C_COMPILER arm-none-eabi-gcc)
9*2fd737d3SMatthias RingwaldSET(CMAKE_CXX_COMPILER_WORKS 1)
10*2fd737d3SMatthias RingwaldSET(CMAKE_CXX_COMPILER arm-none-eabi-g++)
11*2fd737d3SMatthias Ringwaldset(CMAKE_ASM_COMPILER  arm-none-eabi-gcc)
12*2fd737d3SMatthias Ringwaldset(CMAKE_AR arm-none-eabi-ar)
13*2fd737d3SMatthias Ringwaldset(CMAKE_OBJCOPY arm-none-eabi-objcopy)
14*2fd737d3SMatthias Ringwaldset(CMAKE_OBJDUMP arm-none-eabi-objdump)
15*2fd737d3SMatthias Ringwaldset(SIZE arm-none-eabi-size)
16*2fd737d3SMatthias Ringwald
17*2fd737d3SMatthias RingwaldSET(LINKER_SCRIPT ${CMAKE_SOURCE_DIR}/STM32L451REIx_FLASH.ld)
18*2fd737d3SMatthias Ringwald
19*2fd737d3SMatthias Ringwald#Uncomment for hardware floating point
20*2fd737d3SMatthias Ringwald#SET(FPU_FLAGS "-mfloat-abi=hard -mfpu=fpv4-sp-d16")
21*2fd737d3SMatthias Ringwald#add_definitions(-DARM_MATH_CM4 -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1)
22*2fd737d3SMatthias Ringwald
23*2fd737d3SMatthias Ringwald#Uncomment for software floating point
24*2fd737d3SMatthias Ringwald#SET(FPU_FLAGS "-mfloat-abi=soft")
25*2fd737d3SMatthias Ringwald
26*2fd737d3SMatthias RingwaldSET(COMMON_FLAGS
27*2fd737d3SMatthias Ringwald    "-mcpu=cortex-m4 ${FPU_FLAGS} -mthumb -mthumb-interwork -ffunction-sections -fdata-sections \
28*2fd737d3SMatthias Ringwald    -g -fno-common -fmessage-length=0 -specs=nosys.specs -specs=nano.specs")
29*2fd737d3SMatthias Ringwald
30*2fd737d3SMatthias RingwaldSET(CMAKE_CXX_FLAGS_INIT "${COMMON_FLAGS} -std=c++11")
31*2fd737d3SMatthias RingwaldSET(CMAKE_C_FLAGS_INIT "${COMMON_FLAGS} -std=gnu99")
32*2fd737d3SMatthias RingwaldSET(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,-gc-sections,--print-memory-usage -T ${LINKER_SCRIPT}")
33*2fd737d3SMatthias Ringwald
34*2fd737d3SMatthias RingwaldPROJECT(sx1280-ble C CXX ASM)
35*2fd737d3SMatthias Ringwaldset(CMAKE_CXX_STANDARD 11)
36*2fd737d3SMatthias Ringwald
37*2fd737d3SMatthias Ringwald#add_definitions(-DARM_MATH_CM4 -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -D__FPU_PRESENT=1)
38*2fd737d3SMatthias Ringwaldadd_definitions(-DUSE_HAL_DRIVER -DSTM32L451xx)
39*2fd737d3SMatthias Ringwald
40*2fd737d3SMatthias Ringwaldfile(GLOB_RECURSE SOURCES "startup/*.*" "Drivers/*.*" "Src/*.*" "port/*.*")
41*2fd737d3SMatthias Ringwald
42*2fd737d3SMatthias Ringwaldinclude_directories(Inc Drivers/STM32L4xx_HAL_Driver/Inc Drivers/STM32L4xx_HAL_Driver/Inc/Legacy Drivers/CMSIS/Device/ST/STM32L4xx/Include Drivers/CMSIS/Include)
43*2fd737d3SMatthias Ringwald
44*2fd737d3SMatthias Ringwaldadd_executable(${PROJECT_NAME}.elf ${SOURCES} ${LINKER_SCRIPT})
45*2fd737d3SMatthias Ringwald
46*2fd737d3SMatthias Ringwaldset(CMAKE_EXE_LINKER_FLAGS
47*2fd737d3SMatthias Ringwald    "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Map=${PROJECT_BINARY_DIR}/${PROJECT_NAME}.map")
48*2fd737d3SMatthias Ringwald
49*2fd737d3SMatthias Ringwaldset(HEX_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.hex)
50*2fd737d3SMatthias Ringwaldset(BIN_FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}.bin)
51*2fd737d3SMatthias Ringwald
52*2fd737d3SMatthias Ringwaldadd_custom_command(TARGET ${PROJECT_NAME}.elf POST_BUILD
53*2fd737d3SMatthias Ringwald        COMMAND ${CMAKE_OBJCOPY} -Oihex $<TARGET_FILE:${PROJECT_NAME}.elf> ${HEX_FILE}
54*2fd737d3SMatthias Ringwald        COMMAND ${CMAKE_OBJCOPY} -Obinary $<TARGET_FILE:${PROJECT_NAME}.elf> ${BIN_FILE}
55*2fd737d3SMatthias Ringwald        COMMENT "Building ${HEX_FILE}
56*2fd737d3SMatthias RingwaldBuilding ${BIN_FILE}")
57