xref: /btstack/port/renesas-ek-ra6m4a-da14531/CMakeLists.txt (revision e186370f42635e4700fddfb7652fadc86b4357c7)
1c3086949SMatthias Ringwald# CMakeLists.txt for BTstack EK-RA6M4 + DA14531 port
2c3086949SMatthias Ringwald
3c3086949SMatthias Ringwaldcmake_minimum_required (VERSION 3.5)
4c3086949SMatthias Ringwald
5c3086949SMatthias RingwaldSET(CMAKE_EXPORT_COMPILE_COMMANDS ON)
6c3086949SMatthias Ringwald
7c3086949SMatthias Ringwald# select arm-non-eabi toolchain
8c3086949SMatthias Ringwaldinclude (cmake/arm-none-eabi.cmake)
9c3086949SMatthias Ringwald
10c3086949SMatthias Ringwald# Project
11c3086949SMatthias Ringwaldproject(BTstack-ra6m4-da14531)
12c3086949SMatthias Ringwald
13c3086949SMatthias Ringwald# BTstack root
14c3086949SMatthias RingwaldSET(BTSTACK_ROOT ${CMAKE_SOURCE_DIR}/../..)
15c3086949SMatthias Ringwald
16c3086949SMatthias Ringwald# Linker script
17c3086949SMatthias Ringwaldset(LINKER_SCRIPT "fsp.ld")
18c3086949SMatthias Ringwald
19c3086949SMatthias Ringwald# CPU OPTIONS
20c3086949SMatthias Ringwaldset(CPU_OPTIONS
21c3086949SMatthias Ringwald    -mcpu=cortex-m33
22c3086949SMatthias Ringwald    -mthumb
23c3086949SMatthias Ringwald    -mfloat-abi=hard
24c3086949SMatthias Ringwald	-mfpu=fpv5-sp-d16
25c3086949SMatthias Ringwald    -g
26c3086949SMatthias Ringwald)
27c3086949SMatthias Ringwald
28c3086949SMatthias Ringwald# Other Compile options from e2-studio debug/Makefile
29c3086949SMatthias Ringwaldadd_compile_options(
30c3086949SMatthias Ringwald    ${CPU_OPTIONS}
31c3086949SMatthias Ringwald    -Og
32c3086949SMatthias Ringwald    -g
33c3086949SMatthias Ringwald    -fmessage-length=0
34c3086949SMatthias Ringwald    -fsigned-char
35c3086949SMatthias Ringwald    -ffunction-sections
36c3086949SMatthias Ringwald    -fdata-sections
37c3086949SMatthias Ringwald    # -Wunused
38c3086949SMatthias Ringwald    -Wuninitialized
39c3086949SMatthias Ringwald    -Wall
40c3086949SMatthias Ringwald    -Wextra
41c3086949SMatthias Ringwald    -Wmissing-declarations
42c3086949SMatthias Ringwald    # -Wconversion
43c3086949SMatthias Ringwald    -Wpointer-arith
44c3086949SMatthias Ringwald    -Wshadow
45c3086949SMatthias Ringwald    -Wlogical-op
46c3086949SMatthias Ringwald    -Waggregate-return
47c3086949SMatthias Ringwald    -Wfloat-equal
48c3086949SMatthias Ringwald    --specs=nano.specs
49c3086949SMatthias Ringwald    --specs=rdimon.specs
50c3086949SMatthias Ringwald)
51c3086949SMatthias Ringwald
52c3086949SMatthias Ringwald# E2 project headers and sources
53c3086949SMatthias Ringwaldinclude_directories(
54c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/arm/CMSIS_5/CMSIS/Core/Include/
55c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/inc
56c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/inc/api
57c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/inc/instances/
58c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra_cfg/fsp_cfg
59c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra_cfg/fsp_cfg/bsp
60c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra_gen
61c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/port
62c3086949SMatthias Ringwald)
63c3086949SMatthias Ringwald
64c3086949SMatthias Ringwaldset (E2_SOURCES
65c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/board/ra6m4_ek/board_init.c
66c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/board/ra6m4_ek/board_leds.c
67c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/startup.c
68c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/bsp/cmsis/Device/RENESAS/Source/system.c
69c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/bsp/mcu/all/bsp_clocks.c
70c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/bsp/mcu/all/bsp_common.c
71c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/bsp/mcu/all/bsp_delay.c
72c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/bsp/mcu/all/bsp_group_irq.c
73c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/bsp/mcu/all/bsp_guard.c
74c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/bsp/mcu/all/bsp_io.c
75c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/bsp/mcu/all/bsp_irq.c
76c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/bsp/mcu/all/bsp_register_protection.c
77c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/bsp/mcu/all/bsp_rom_registers.c
78c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/bsp/mcu/all/bsp_sbrk.c
79c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/bsp/mcu/all/bsp_security.c
80c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/r_dtc/r_dtc.c
81c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/r_flash_hp/r_flash_hp.c
82c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/r_gpt/r_gpt.c
83c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/r_ioport/r_ioport.c
84c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra/fsp/src/r_sci_uart/r_sci_uart.c
85c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra_gen/common_data.c
86c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra_gen/hal_data.c
87c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra_gen/main.c
88c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra_gen/pin_data.c
89c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/e2-project/ra_gen/vector_data.c
90c3086949SMatthias Ringwald)
91c3086949SMatthias Ringwald
92c3086949SMatthias Ringwald# BTstack headers and includes
93c3086949SMatthias Ringwald
94c3086949SMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile
95c3086949SMatthias Ringwaldinclude_directories(
96c3086949SMatthias Ringwald	${BTSTACK_ROOT}/3rd-party/micro-ecc
97c3086949SMatthias Ringwald	${BTSTACK_ROOT}/3rd-party/segger-rtt
98c3086949SMatthias Ringwald	${BTSTACK_ROOT}/3rd-party/hxcmod-player
99c3086949SMatthias Ringwald	${BTSTACK_ROOT}/3rd-party/hxcmod-player/mod
100c3086949SMatthias Ringwald	${BTSTACK_ROOT}/3rd-party/rijndael
101c3086949SMatthias Ringwald	${BTSTACK_ROOT}/src
102c3086949SMatthias Ringwald	${BTSTACK_ROOT}/platform/embedded
103c3086949SMatthias Ringwald	.
104c3086949SMatthias Ringwald)
105c3086949SMatthias Ringwald
106c3086949SMatthias Ringwald# to generate .h from .gatt files
107c3086949SMatthias Ringwaldfind_package (Python REQUIRED COMPONENTS Interpreter)
108c3086949SMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR})
109c3086949SMatthias Ringwald
110c3086949SMatthias Ringwaldfile(GLOB SOURCES_SRC        "${BTSTACK_ROOT}/src/*.c")
111c3086949SMatthias Ringwaldfile(GLOB SOURCES_BLE        "${BTSTACK_ROOT}/src/ble/*.c")
112c3086949SMatthias Ringwaldfile(GLOB SOURCES_GATT       "${BTSTACK_ROOT}/src/ble/gatt-service/*.c")
113c3086949SMatthias Ringwaldfile(GLOB SOURCES_SEGGER_RTT "${BTSTACK_ROOT}/3rd-party/segger-rtt/*.c")
114c3086949SMatthias Ringwaldfile(GLOB SOURCES_UECC       "${BTSTACK_ROOT}/3rd-party/micro-ecc/uECC.c")
115c3086949SMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL   "${BTSTACK_ROOT}/3rd-party/rijndael/rijndael.c")
116c3086949SMatthias Ringwaldfile(GLOB SOURCES_EMBEDDED   "${BTSTACK_ROOT}/platform/embedded/*.c")
117c3086949SMatthias Ringwald
118c3086949SMatthias Ringwaldfile(GLOB SOURCES_EMBEDDED_OFF ${BTSTACK_ROOT}/platform/embedded/btstack_em9304_spi_embedded.c)
119c3086949SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_EMBEDDED ${SOURCES_EMBEDDED_OFF})
120c3086949SMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF    ${BTSTACK_ROOT}/src/ble/le_device_db_memory.c ${BTSTACK_ROOT}/src/ble/att_db_util.c)
121c3086949SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_BLE_OFF})
122c3086949SMatthias Ringwaldfile(GLOB SOURCES_SRC_OFF    ${BTSTACK_ROOT}/src/btstack_lc3_google.c ${BTSTACK_ROOT}/btstack_tlv_none.c)
123c3086949SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_SRC ${SOURCES_SRC_OFF})
124c3086949SMatthias Ringwald
125c3086949SMatthias Ringwaldset(BTSTACK_SOURCES
126c3086949SMatthias Ringwald	${SOURCES_RIJNDAEL}
127c3086949SMatthias Ringwald	${SOURCES_EMBEDDED}
128c3086949SMatthias Ringwald	${SOURCES_SRC}
129c3086949SMatthias Ringwald	${SOURCES_BLE}
130c3086949SMatthias Ringwald	${SOURCES_GATT}
131c3086949SMatthias Ringwald	${SOURCES_UECC}
132c3086949SMatthias Ringwald	${SOURCES_SEGGER_RTT}
133c3086949SMatthias Ringwald)
134c3086949SMatthias Ringwald
135c3086949SMatthias Ringwaldset (SOURCES
136c3086949SMatthias Ringwald	${BTSTACK_SOURCES}
137c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/port/hal_entry.c
138c3086949SMatthias Ringwald	${CMAKE_SOURCE_DIR}/port/hal_flash_bank_fsp.c
139c3086949SMatthias Ringwald)
140c3086949SMatthias Ringwald
141c3086949SMatthias Ringwald# create static lib
142c3086949SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES})
143c3086949SMatthias Ringwald
1442a44f278SMatthias Ringwald# create target with gatt file, use "NONE"
1452a44f278SMatthias Ringwaldfunction(create_target EXAMPLE EXAMPLE_PATH GATT_PATH)
1462a44f278SMatthias Ringwald	if (${GATT_PATH} STREQUAL "NONE")
1472a44f278SMatthias Ringwald		message("example ${EXAMPLE}")
1482a44f278SMatthias Ringwald	else()
149c3086949SMatthias Ringwald		message("example ${EXAMPLE} -- with GATT DB")
150c3086949SMatthias Ringwald		add_custom_command(
151c3086949SMatthias Ringwald				OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
1522a44f278SMatthias Ringwald				DEPENDS ${GATT_PATH}
153c3086949SMatthias Ringwald				COMMAND ${Python_EXECUTABLE}
1542a44f278SMatthias Ringwald				ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${GATT_PATH} ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
155c3086949SMatthias Ringwald		)
156c3086949SMatthias Ringwald		list(APPEND SOURCES_EXAMPLE ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
157c3086949SMatthias Ringwald	endif()
158c3086949SMatthias Ringwald
1592a44f278SMatthias Ringwald	# create ozone project
160c3086949SMatthias Ringwald	configure_file(ozone.jdebug.in ${EXAMPLE}.jdebug)
161c3086949SMatthias Ringwald
162c3086949SMatthias Ringwald	add_executable(${EXAMPLE}
163c3086949SMatthias Ringwald			${E2_SOURCES}
164c3086949SMatthias Ringwald			${SOURCES_EXAMPLE}
165c3086949SMatthias Ringwald			)
166c3086949SMatthias Ringwald
167c3086949SMatthias Ringwald	target_link_libraries(${EXAMPLE}
168c3086949SMatthias Ringwald			${CPU_OPTIONS}
169c3086949SMatthias Ringwald			-L"${CMAKE_SOURCE_DIR}/e2-project/script"
170c3086949SMatthias Ringwald			-L"${CMAKE_SOURCE_DIR}"
171c3086949SMatthias Ringwald			-T${LINKER_SCRIPT}
172c3086949SMatthias Ringwald			-nostartfiles
173c3086949SMatthias Ringwald			m
174c3086949SMatthias Ringwald			-nostdlib
175c3086949SMatthias Ringwald			btstack
176c3086949SMatthias Ringwald			)
177c3086949SMatthias Ringwald
178c3086949SMatthias Ringwald	set_property(TARGET ${EXAMPLE} PROPERTY LINK_DEPENDS ${CMAKE_SOURCE_DIR}/memory_regions.ld)
179c3086949SMatthias Ringwald	set_property(TARGET ${EXAMPLE} PROPERTY LINK_DEPENDS ${CMAKE_SOURCE_DIR}/e2-project/script/${LINKER_SCRIPT})
1802a44f278SMatthias Ringwald
1812a44f278SMatthias Ringwaldendfunction()
1822a44f278SMatthias Ringwald
1832a44f278SMatthias Ringwald# get list of examples, skipping some
1842a44f278SMatthias Ringwaldinclude(${BTSTACK_ROOT}/example/CMakeLists.txt)
1852a44f278SMatthias Ringwaldset (EXAMPLES ${EXAMPLES_GENERAL} ${EXAMPLES_LE_ONLY})
1862a44f278SMatthias Ringwaldlist(REMOVE_DUPLICATES EXAMPLES)
1872a44f278SMatthias Ringwaldlist(REMOVE_ITEM EXAMPLES mesh_node_demo mod_player sinus_player audio_duplex)
1882a44f278SMatthias Ringwald
1892a44f278SMatthias Ringwald# create examples
1902a44f278SMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES})
1912a44f278SMatthias Ringwald	# select c file
1922a44f278SMatthias Ringwald	set (SOURCES_EXAMPLE ${BTSTACK_ROOT}/example/${EXAMPLE}.c)
1932a44f278SMatthias Ringwald
1942a44f278SMatthias Ringwald	# select GATT DB if it exists
1952a44f278SMatthias Ringwald	if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} )
1962a44f278SMatthias Ringwald		set(GATT_PATH ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt)
1972a44f278SMatthias Ringwald	else()
1982a44f278SMatthias Ringwald		set(GATT_PATH "NONE")
1992a44f278SMatthias Ringwald	endif()
2002a44f278SMatthias Ringwald
2012a44f278SMatthias Ringwald	# create example
2022a44f278SMatthias Ringwald	create_target(${EXAMPLE} ${SOURCES_EXAMPLE} "NONE")
203c3086949SMatthias Ringwaldendforeach()
204c3086949SMatthias Ringwald
205*e186370fSMatthias Ringwald# create gatt_rgb example
206*e186370fSMatthias Ringwaldcreate_target(gatt_rgb ${CMAKE_SOURCE_DIR}/example/gatt_rgb.c ${CMAKE_SOURCE_DIR}/example/gatt_rgb.gatt)
207c3086949SMatthias Ringwald
208c3086949SMatthias Ringwald
209