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