xref: /btstack/port/posix-h4/CMakeLists.txt (revision 8b6f0b06f217772ac951dd39e5fdd5e40378da3d)
1cmake_minimum_required (VERSION 3.18)
2
3project(BTstack-posix-h4)
4
5SET(BTSTACK_ROOT ${CMAKE_SOURCE_DIR}/../..)
6
7# extra compiler warnings
8if ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*")
9	# using Clang
10	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-variable -Wswitch-default -Werror")
11elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
12	# using GCC
13	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror")
14elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
15	# using Intel C++
16elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
17	# using Visual Studio C++
18endif()
19
20
21# to generate .h from .gatt files
22find_package (Python REQUIRED COMPONENTS Interpreter)
23include_directories(${CMAKE_CURRENT_BINARY_DIR})
24
25# local dir for btstack_config.h after build dir to avoid using .h from Makefile
26include_directories(.)
27
28
29include_directories(${BTSTACK_ROOT}/3rd-party/micro-ecc)
30include_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/include)
31include_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/include)
32include_directories(${BTSTACK_ROOT}/3rd-party/lc3-google/include)
33include_directories(${BTSTACK_ROOT}/3rd-party/md5)
34include_directories(${BTSTACK_ROOT}/3rd-party/hxcmod-player)
35include_directories(${BTSTACK_ROOT}/3rd-party/hxcmod-player/mod)
36include_directories(${BTSTACK_ROOT}/3rd-party/lwip/core/src/include)
37include_directories(${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server)
38include_directories(${BTSTACK_ROOT}/3rd-party/rijndael)
39include_directories(${BTSTACK_ROOT}/3rd-party/yxml)
40include_directories(${BTSTACK_ROOT}/3rd-party/tinydir)
41include_directories(${BTSTACK_ROOT}/src)
42include_directories(${BTSTACK_ROOT}/chipset/bcm)
43include_directories(${BTSTACK_ROOT}/chipset/csr)
44include_directories(${BTSTACK_ROOT}/chipset/cc256x)
45include_directories(${BTSTACK_ROOT}/chipset/em9301)
46include_directories(${BTSTACK_ROOT}/chipset/realtek)
47include_directories(${BTSTACK_ROOT}/chipset/tc3566x)
48include_directories(${BTSTACK_ROOT}/chipset/stlc2500d)
49include_directories(${BTSTACK_ROOT}/chipset/zephyr)
50include_directories(${BTSTACK_ROOT}/platform/embedded)
51include_directories(${BTSTACK_ROOT}/platform/lwip)
52include_directories(${BTSTACK_ROOT}/platform/lwip/port)
53include_directories(${BTSTACK_ROOT}/platform/posix)
54
55file(GLOB SOURCES_SRC       "${BTSTACK_ROOT}/src/*.c" "${BTSTACK_ROOT}/example/sco_demo_util.c")
56file(GLOB SOURCES_BLE       "${BTSTACK_ROOT}/src/ble/*.c")
57file(GLOB SOURCES_BLUEDROID "${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/srce/*.c" "${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/srce/*.c")
58file(GLOB SOURCES_CLASSIC   "${BTSTACK_ROOT}/src/classic/*.c")
59file(GLOB SOURCES_MESH      "${BTSTACK_ROOT}/src/mesh/*.c")
60file(GLOB SOURCES_GATT      "${BTSTACK_ROOT}/src/ble/gatt-service/*.c")
61file(GLOB SOURCES_UECC      "${BTSTACK_ROOT}/3rd-party/micro-ecc/uECC.c")
62file(GLOB SOURCES_HXCMOD    "${BTSTACK_ROOT}/3rd-party/hxcmod-player/*.c"  "${BTSTACK_ROOT}/3rd-party/hxcmod-player/mods/*.c")
63file(GLOB SOURCES_MD5       "${BTSTACK_ROOT}/3rd-party/md5/md5.c")
64file(GLOB SOURCES_RIJNDAEL  "${BTSTACK_ROOT}/3rd-party/rijndael/rijndael.c")
65file(GLOB SOURCES_YXML      "${BTSTACK_ROOT}/3rd-party/yxml/yxml.c")
66file(GLOB SOURCES_POSIX     "${BTSTACK_ROOT}/platform/posix/*.c")
67file(GLOB SOURCES_BCM       "${BTSTACK_ROOT}/chipset/bcm/*.c")
68file(GLOB SOURCES_CSR       "${BTSTACK_ROOT}/chipset/csr/*.c")
69file(GLOB SOURCES_EM9301    "${BTSTACK_ROOT}/chipset/em9301/*.c")
70file(GLOB SOURCES_STLC2500D "${BTSTACK_ROOT}/chipset/stlc2500d/*.c")
71file(GLOB SOURCES_TC2566X   "${BTSTACK_ROOT}/chipset/tc3566x/*.c")
72file(GLOB SOURCES_REALTEK   "${BTSTACK_ROOT}/chipset/realtek/*.c")
73file(GLOB SOURCES_ZEPHYR    "${BTSTACK_ROOT}/chipset/zephyr/*.c")
74file(GLOB SOURCES_LC3_GOOGLE "${BTSTACK_ROOT}/3rd-party/lc3-google/src/*.c")
75file(GLOB SOURCES_PORT      "*.c")
76
77set(LWIP_CORE_SRC
78		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/def.c
79		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/inet_chksum.c
80		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/init.c
81		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ip.c
82		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/mem.c
83		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/memp.c
84		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/netif.c
85		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/pbuf.c
86		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp.c
87		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_in.c
88		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_out.c
89		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/timeouts.c
90		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/udp.c
91		)
92set (LWIP_IPV4_SRC
93		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/acd.c
94		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/dhcp.c
95		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/etharp.c
96		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/icmp.c
97		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4.c
98		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_addr.c
99		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_frag.c
100		)
101set (LWIP_NETIF_SRC
102		${BTSTACK_ROOT}/3rd-party/lwip/core/src/netif/ethernet.c
103		)
104set (LWIP_HTTPD
105		${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/altcp_proxyconnect.c
106		${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/fs.c
107		${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/httpd.c
108		)
109set (LWIP_DHCPD
110		${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server/dhserver.c
111		)
112set (LWIP_PORT
113		${BTSTACK_ROOT}/platform/lwip/port/sys_arch.c
114		${BTSTACK_ROOT}//platform/lwip/bnep_lwip.c
115		)
116set (SOURCES_LWIP ${LWIP_CORE_SRC} ${LWIP_IPV4_SRC} ${LWIP_NETIF_SRC} ${LWIP_HTTPD} ${LWIP_DHCPD} ${LWIP_PORT})
117
118file(GLOB SOURCES_BLE_OFF "${BTSTACK_ROOT}/src/ble/le_device_db_memory.c")
119list(REMOVE_ITEM SOURCES_BLE   ${SOURCES_BLE_OFF})
120
121file(GLOB SOURCES_POSIX_OFF "${BTSTACK_ROOT}/platform/posix/le_device_db_fs.c")
122list(REMOVE_ITEM SOURCES_POSIX   ${SOURCES_POSIX_OFF})
123
124set(SOURCES
125		${SOURCES_BLE}
126		${SOURCES_BCM}
127		${SOURCES_BLUEDROID}
128		${SOURCES_CLASSIC}
129		${SOURCES_CSR}
130		${SOURCES_EM9301}
131		${SOURCES_GATT}
132		${SOURCES_HXCMOD}
133		${SOURCES_HXCMOD}
134		${SOURCES_LIBUSB}
135		${SOURCES_MD5}
136		${SOURCES_MESH}
137		${SOURCES_PORT}
138		${SOURCES_REALTEK}
139		${SOURCES_RIJNDAEL}
140		${SOURCES_SRC}
141		${SOURCES_CSR}
142		${SOURCES_STLC2500D}
143		${SOURCES_TC2566X}
144		${SOURCES_UECC}
145		${SOURCES_POSIX}
146		${SOURCES_YXML}
147		${SOURCES_ZEPHYR}
148)
149list(SORT SOURCES)
150
151# create static lib
152add_library(btstack STATIC ${SOURCES})
153
154# pkgconfig
155find_package(PkgConfig QUIET)
156
157# portaudio
158if (PkgConfig_FOUND)
159	pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0)
160	if(PORTAUDIO_FOUND)
161		message("HAVE_PORTAUDIO")
162		include_directories(${PORTAUDIO_INCLUDE_DIRS})
163		link_directories(${PORTAUDIO_LIBRARY_DIRS})
164		link_libraries(${PORTAUDIO_LIBRARIES})
165		# CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO)
166		SET(CMAKE_C_FLAGS  "-DHAVE_PORTAUDIO")
167	endif()
168endif()
169
170
171# Add CC256x Support and specify init script
172set (CC256X_INIT_SCRIPT bluetooth_init_cc2564C_1.5.c)
173include(${BTSTACK_ROOT}/chipset/cc256x/cc256x.cmake)
174
175# Add BCM Support and download PatchRAM files
176include(${BTSTACK_ROOT}/chipset/bcm/bcm.cmake)
177
178# get list of examples, skipping mesh_node_demo
179include(../../example/CMakeLists.txt)
180set (EXAMPLES ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY}  ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE})
181list(REMOVE_DUPLICATES EXAMPLES)
182list(REMOVE_ITEM EXAMPLES "mesh_node_demo")
183
184# create targets
185foreach(EXAMPLE ${EXAMPLES})
186	# get c file
187	set (SOURCES_EXAMPLE ${BTSTACK_ROOT}/example/${EXAMPLE}.c)
188
189	# add GATT DB creation
190	if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} )
191		message("example ${EXAMPLE} -- with GATT DB")
192	  	add_custom_command(
193		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
194			DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt
195			COMMAND ${Python_EXECUTABLE}
196			ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
197		)
198		list(APPEND SOURCES_EXAMPLE ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
199	else()
200		message("example ${EXAMPLE}")
201	endif()
202	add_executable(${EXAMPLE} ${SOURCES_EXAMPLE})
203	target_link_libraries(${EXAMPLE} btstack)
204endforeach(EXAMPLE)
205