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