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