xref: /btstack/port/posix-h4-zephyr/CMakeLists.txt (revision 02bddf72ded804ec650dff99a15cca6ff8460083)
105e00d57SMatthias Ringwaldcmake_minimum_required (VERSION 3.5)
205e00d57SMatthias Ringwald
305e00d57SMatthias RingwaldSET(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk)
405e00d57SMatthias RingwaldSET(CMAKE_EXPORT_COMPILE_COMMANDS ON)
505e00d57SMatthias Ringwald
605e00d57SMatthias Ringwaldproject(BTstack-posix-h4-zephyr)
705e00d57SMatthias Ringwald
805e00d57SMatthias Ringwald# pkgconfig
905e00d57SMatthias Ringwaldfind_package(PkgConfig REQUIRED)
1005e00d57SMatthias Ringwald
1105e00d57SMatthias Ringwald# portaudio
1205e00d57SMatthias Ringwaldpkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0)
1305e00d57SMatthias Ringwaldif(PORTAUDIO_FOUND)
1405e00d57SMatthias Ringwald	message("HAVE_PORTAUDIO")
1505e00d57SMatthias Ringwald	include_directories(${PORTAUDIO_INCLUDE_DIRS})
1605e00d57SMatthias Ringwald	link_directories(${PORTAUDIO_LIBRARY_DIRS})
1705e00d57SMatthias Ringwald	link_libraries(${PORTAUDIO_LIBRARIES})
1805e00d57SMatthias Ringwald	# CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO)
1905e00d57SMatthias Ringwald	SET(CMAKE_C_FLAGS  "-DHAVE_PORTAUDIO")
2005e00d57SMatthias Ringwaldendif()
2105e00d57SMatthias Ringwald
2205e00d57SMatthias Ringwald# pthread
2305e00d57SMatthias Ringwaldfind_package(Threads)
2405e00d57SMatthias Ringwaldlink_libraries(${CMAKE_THREAD_LIBS_INIT})
2505e00d57SMatthias Ringwald
2605e00d57SMatthias Ringwald# extra compiler warnings
2705e00d57SMatthias Ringwaldif ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*")
2805e00d57SMatthias Ringwald	# using Clang
2905e00d57SMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-variable -Wswitch-default -Werror")
3005e00d57SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
3105e00d57SMatthias Ringwald	# using GCC
3205e00d57SMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror")
3305e00d57SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
3405e00d57SMatthias Ringwald	# using Intel C++
3505e00d57SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
3605e00d57SMatthias Ringwald	# using Visual Studio C++
3705e00d57SMatthias Ringwaldendif()
3805e00d57SMatthias Ringwald
39*02bddf72SMatthias Ringwald# to generate .h from .gatt files
40*02bddf72SMatthias Ringwaldfind_package (Python REQUIRED COMPONENTS Interpreter)
4105e00d57SMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR})
4205e00d57SMatthias Ringwald
4305e00d57SMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile
4405e00d57SMatthias Ringwaldinclude_directories(.)
4505e00d57SMatthias Ringwald
4605e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc)
4705e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include)
4805e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/md5)
4905e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player)
5005e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod)
5105e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael)
5205e00d57SMatthias Ringwaldinclude_directories(../../src)
5305e00d57SMatthias Ringwaldinclude_directories(../../chipset/zephyr)
5405e00d57SMatthias Ringwaldinclude_directories(../../platform/embedded)
5505e00d57SMatthias Ringwaldinclude_directories(../../platform/posix)
5605e00d57SMatthias Ringwald
5705e00d57SMatthias Ringwaldfile(GLOB SOURCES_SRC       "../../src/*.c")
5805e00d57SMatthias Ringwaldfile(GLOB SOURCES_BLE       "../../src/ble/*.c")
5905e00d57SMatthias Ringwaldfile(GLOB SOURCES_GATT      "../../src/ble/gatt-service/*.c")
6005e00d57SMatthias Ringwaldfile(GLOB SOURCES_MESH      "../../src/mesh/*.c")
6105e00d57SMatthias Ringwaldfile(GLOB SOURCES_UECC      "../../3rd-party/micro-ecc/uECC.c")
6205e00d57SMatthias Ringwaldfile(GLOB SOURCES_HXCMOD    "../../3rd-party/hxcmod-player/*.c"  "../../3rd-party/hxcmod-player/mods/*.c")
6305e00d57SMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL  "../../3rd-party/rijndael/rijndael.c")
6405e00d57SMatthias Ringwaldfile(GLOB SOURCES_POSIX     "../../platform/posix/*.c")
6505e00d57SMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR    "../../chipset/zephyr/*.c")
6605e00d57SMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c")
6705e00d57SMatthias Ringwaldfile(GLOB SOURCES_PORT      "*.c")
6805e00d57SMatthias Ringwald
6905e00d57SMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c")
7005e00d57SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE   ${SOURCES_BLE_OFF})
7105e00d57SMatthias Ringwald
7205e00d57SMatthias Ringwaldfile(GLOB SOURCES_POSIX_OFF "../../platform/posix/le_device_db_fs.c" "../../platform/posix/btstack_link_key_db_fs.c")
7305e00d57SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF})
7405e00d57SMatthias Ringwald
7505e00d57SMatthias Ringwaldset(SOURCES
7605e00d57SMatthias Ringwald	${SOURCES_BLE}
7705e00d57SMatthias Ringwald	${SOURCES_GATT}
7805e00d57SMatthias Ringwald	${SOURCES_HXCMOD}
7905e00d57SMatthias Ringwald	${SOURCES_LC3_GOOGLE}
8005e00d57SMatthias Ringwald	${SOURCES_MESH}
8105e00d57SMatthias Ringwald	${SOURCES_PORT}
8205e00d57SMatthias Ringwald	${SOURCES_POSIX}
8305e00d57SMatthias Ringwald	${SOURCES_RIJNDAEL}
8405e00d57SMatthias Ringwald	${SOURCES_SRC}
8505e00d57SMatthias Ringwald	${SOURCES_UECC}
8605e00d57SMatthias Ringwald	${SOURCES_ZEPHYR}
8705e00d57SMatthias Ringwald)
8805e00d57SMatthias Ringwaldlist(SORT SOURCES)
8905e00d57SMatthias Ringwald
9005e00d57SMatthias Ringwald# create static lib
9105e00d57SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES})
9205e00d57SMatthias Ringwald
9305e00d57SMatthias Ringwald# get list of examples
9405e00d57SMatthias Ringwaldinclude(../../example/CMakeLists.txt)
9505e00d57SMatthias Ringwaldset (EXAMPLES ${EXAMPLES_LE_ONLY} ${EXAMPLES_GENERAL})
9605e00d57SMatthias Ringwald
9705e00d57SMatthias Ringwald# create targets
9805e00d57SMatthias Ringwaldset (EXAMPLES_C)
9905e00d57SMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES})
10005e00d57SMatthias Ringwald	# get c file
10105e00d57SMatthias Ringwald	file(GLOB EXAMPLE_FILE "../../example/${EXAMPLE}.c")
10205e00d57SMatthias Ringwald
10305e00d57SMatthias Ringwald	# add GATT DB creation
10405e00d57SMatthias Ringwald	if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} )
10505e00d57SMatthias Ringwald		message("example ${EXAMPLE} -- with GATT DB")
10605e00d57SMatthias Ringwald		add_custom_command(
10705e00d57SMatthias Ringwald		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
108*02bddf72SMatthias Ringwald			DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt
109*02bddf72SMatthias Ringwald			COMMAND ${Python_EXECUTABLE}
110*02bddf72SMatthias Ringwald			ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
11105e00d57SMatthias Ringwald		)
11205e00d57SMatthias Ringwald		list(APPEND SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
11305e00d57SMatthias Ringwald	else()
11405e00d57SMatthias Ringwald		message("example ${EXAMPLE}")
11505e00d57SMatthias Ringwald	endif()
11605e00d57SMatthias Ringwald	add_executable(${EXAMPLE} ${EXAMPLE_FILE} )
11705e00d57SMatthias Ringwald	target_link_libraries(${EXAMPLE} btstack)
11805e00d57SMatthias Ringwaldendforeach(EXAMPLE)
119