xref: /btstack/port/posix-h4-zephyr/CMakeLists.txt (revision 05e00d57a803935a28289c5173fa7d280a6655e4)
1*05e00d57SMatthias Ringwaldcmake_minimum_required (VERSION 3.5)
2*05e00d57SMatthias Ringwald
3*05e00d57SMatthias RingwaldSET(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk)
4*05e00d57SMatthias RingwaldSET(CMAKE_EXPORT_COMPILE_COMMANDS ON)
5*05e00d57SMatthias Ringwald
6*05e00d57SMatthias Ringwaldproject(BTstack-posix-h4-zephyr)
7*05e00d57SMatthias Ringwald
8*05e00d57SMatthias Ringwald# pkgconfig
9*05e00d57SMatthias Ringwaldfind_package(PkgConfig REQUIRED)
10*05e00d57SMatthias Ringwald
11*05e00d57SMatthias Ringwald# portaudio
12*05e00d57SMatthias Ringwaldpkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0)
13*05e00d57SMatthias Ringwaldif(PORTAUDIO_FOUND)
14*05e00d57SMatthias Ringwald	message("HAVE_PORTAUDIO")
15*05e00d57SMatthias Ringwald	include_directories(${PORTAUDIO_INCLUDE_DIRS})
16*05e00d57SMatthias Ringwald	link_directories(${PORTAUDIO_LIBRARY_DIRS})
17*05e00d57SMatthias Ringwald	link_libraries(${PORTAUDIO_LIBRARIES})
18*05e00d57SMatthias Ringwald	# CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO)
19*05e00d57SMatthias Ringwald	SET(CMAKE_C_FLAGS  "-DHAVE_PORTAUDIO")
20*05e00d57SMatthias Ringwaldendif()
21*05e00d57SMatthias Ringwald
22*05e00d57SMatthias Ringwald# pthread
23*05e00d57SMatthias Ringwaldfind_package(Threads)
24*05e00d57SMatthias Ringwaldlink_libraries(${CMAKE_THREAD_LIBS_INIT})
25*05e00d57SMatthias Ringwald
26*05e00d57SMatthias Ringwald# extra compiler warnings
27*05e00d57SMatthias Ringwaldif ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*")
28*05e00d57SMatthias Ringwald	# using Clang
29*05e00d57SMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-variable -Wswitch-default -Werror")
30*05e00d57SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
31*05e00d57SMatthias Ringwald	# using GCC
32*05e00d57SMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror")
33*05e00d57SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
34*05e00d57SMatthias Ringwald	# using Intel C++
35*05e00d57SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
36*05e00d57SMatthias Ringwald	# using Visual Studio C++
37*05e00d57SMatthias Ringwaldendif()
38*05e00d57SMatthias Ringwald
39*05e00d57SMatthias Ringwald# to find generated .h from .gatt files
40*05e00d57SMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR})
41*05e00d57SMatthias Ringwald
42*05e00d57SMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile
43*05e00d57SMatthias Ringwaldinclude_directories(.)
44*05e00d57SMatthias Ringwald
45*05e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc)
46*05e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include)
47*05e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/md5)
48*05e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player)
49*05e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod)
50*05e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael)
51*05e00d57SMatthias Ringwaldinclude_directories(../../src)
52*05e00d57SMatthias Ringwaldinclude_directories(../../chipset/zephyr)
53*05e00d57SMatthias Ringwaldinclude_directories(../../platform/embedded)
54*05e00d57SMatthias Ringwaldinclude_directories(../../platform/posix)
55*05e00d57SMatthias Ringwald
56*05e00d57SMatthias Ringwaldfile(GLOB SOURCES_SRC       "../../src/*.c")
57*05e00d57SMatthias Ringwaldfile(GLOB SOURCES_BLE       "../../src/ble/*.c")
58*05e00d57SMatthias Ringwaldfile(GLOB SOURCES_GATT      "../../src/ble/gatt-service/*.c")
59*05e00d57SMatthias Ringwaldfile(GLOB SOURCES_MESH      "../../src/mesh/*.c")
60*05e00d57SMatthias Ringwaldfile(GLOB SOURCES_UECC      "../../3rd-party/micro-ecc/uECC.c")
61*05e00d57SMatthias Ringwaldfile(GLOB SOURCES_HXCMOD    "../../3rd-party/hxcmod-player/*.c"  "../../3rd-party/hxcmod-player/mods/*.c")
62*05e00d57SMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL  "../../3rd-party/rijndael/rijndael.c")
63*05e00d57SMatthias Ringwaldfile(GLOB SOURCES_POSIX     "../../platform/posix/*.c")
64*05e00d57SMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR    "../../chipset/zephyr/*.c")
65*05e00d57SMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c")
66*05e00d57SMatthias Ringwaldfile(GLOB SOURCES_PORT      "*.c")
67*05e00d57SMatthias Ringwald
68*05e00d57SMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c")
69*05e00d57SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE   ${SOURCES_BLE_OFF})
70*05e00d57SMatthias Ringwald
71*05e00d57SMatthias Ringwaldfile(GLOB SOURCES_POSIX_OFF "../../platform/posix/le_device_db_fs.c" "../../platform/posix/btstack_link_key_db_fs.c")
72*05e00d57SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF})
73*05e00d57SMatthias Ringwald
74*05e00d57SMatthias Ringwaldset(SOURCES
75*05e00d57SMatthias Ringwald	${SOURCES_BLE}
76*05e00d57SMatthias Ringwald	${SOURCES_GATT}
77*05e00d57SMatthias Ringwald	${SOURCES_HXCMOD}
78*05e00d57SMatthias Ringwald	${SOURCES_LC3_GOOGLE}
79*05e00d57SMatthias Ringwald	${SOURCES_MESH}
80*05e00d57SMatthias Ringwald	${SOURCES_PORT}
81*05e00d57SMatthias Ringwald	${SOURCES_POSIX}
82*05e00d57SMatthias Ringwald	${SOURCES_RIJNDAEL}
83*05e00d57SMatthias Ringwald	${SOURCES_SRC}
84*05e00d57SMatthias Ringwald	${SOURCES_UECC}
85*05e00d57SMatthias Ringwald	${SOURCES_ZEPHYR}
86*05e00d57SMatthias Ringwald)
87*05e00d57SMatthias Ringwaldlist(SORT SOURCES)
88*05e00d57SMatthias Ringwald
89*05e00d57SMatthias Ringwald# create static lib
90*05e00d57SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES})
91*05e00d57SMatthias Ringwald
92*05e00d57SMatthias Ringwald# get list of examples
93*05e00d57SMatthias Ringwaldinclude(../../example/CMakeLists.txt)
94*05e00d57SMatthias Ringwaldset (EXAMPLES ${EXAMPLES_LE_ONLY} ${EXAMPLES_GENERAL})
95*05e00d57SMatthias Ringwald
96*05e00d57SMatthias Ringwald# create targets
97*05e00d57SMatthias Ringwaldset (EXAMPLES_C)
98*05e00d57SMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES})
99*05e00d57SMatthias Ringwald	# get c file
100*05e00d57SMatthias Ringwald	file(GLOB EXAMPLE_FILE "../../example/${EXAMPLE}.c")
101*05e00d57SMatthias Ringwald
102*05e00d57SMatthias Ringwald	# add GATT DB creation
103*05e00d57SMatthias Ringwald	if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} )
104*05e00d57SMatthias Ringwald		message("example ${EXAMPLE} -- with GATT DB")
105*05e00d57SMatthias Ringwald		add_custom_command(
106*05e00d57SMatthias Ringwald		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
107*05e00d57SMatthias Ringwald			DEPENDS ${CMAKE_SOURCE_DIR}/../../example/${EXAMPLE}.gatt
108*05e00d57SMatthias Ringwald			COMMAND ${CMAKE_SOURCE_DIR}/../../tool/compile_gatt.py
109*05e00d57SMatthias Ringwald			ARGS ${CMAKE_SOURCE_DIR}/../../example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
110*05e00d57SMatthias Ringwald		)
111*05e00d57SMatthias Ringwald		list(APPEND SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
112*05e00d57SMatthias Ringwald	else()
113*05e00d57SMatthias Ringwald		message("example ${EXAMPLE}")
114*05e00d57SMatthias Ringwald	endif()
115*05e00d57SMatthias Ringwald	add_executable(${EXAMPLE} ${EXAMPLE_FILE} )
116*05e00d57SMatthias Ringwald	target_link_libraries(${EXAMPLE} btstack)
117*05e00d57SMatthias Ringwaldendforeach(EXAMPLE)
118