xref: /btstack/port/posix-h4-zephyr/CMakeLists.txt (revision caeaa206eb51459f9342b4042b1af2ec395bf0ac)
1*caeaa206SMatthias Ringwaldcmake_minimum_required (VERSION 3.12)
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
8dce6d7b3SMatthias RingwaldSET(BTSTACK_ROOT ${CMAKE_SOURCE_DIR}/../..)
9dce6d7b3SMatthias Ringwald
1005e00d57SMatthias Ringwald
1105e00d57SMatthias Ringwald# extra compiler warnings
1205e00d57SMatthias Ringwaldif ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*")
1305e00d57SMatthias Ringwald	# using Clang
1405e00d57SMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-variable -Wswitch-default -Werror")
1505e00d57SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
1605e00d57SMatthias Ringwald	# using GCC
1705e00d57SMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror")
1805e00d57SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
1905e00d57SMatthias Ringwald	# using Intel C++
2005e00d57SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
2105e00d57SMatthias Ringwald	# using Visual Studio C++
2205e00d57SMatthias Ringwaldendif()
2305e00d57SMatthias Ringwald
2402bddf72SMatthias Ringwald# to generate .h from .gatt files
2502bddf72SMatthias Ringwaldfind_package (Python REQUIRED COMPONENTS Interpreter)
2605e00d57SMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR})
2705e00d57SMatthias Ringwald
2805e00d57SMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile
2905e00d57SMatthias Ringwaldinclude_directories(.)
3005e00d57SMatthias Ringwald
3105e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc)
3205e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include)
3305e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/md5)
3405e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player)
3505e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod)
3605e00d57SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael)
3705e00d57SMatthias Ringwaldinclude_directories(../../src)
3805e00d57SMatthias Ringwaldinclude_directories(../../chipset/zephyr)
3905e00d57SMatthias Ringwaldinclude_directories(../../platform/embedded)
4005e00d57SMatthias Ringwaldinclude_directories(../../platform/posix)
4105e00d57SMatthias Ringwald
4205e00d57SMatthias Ringwaldfile(GLOB SOURCES_SRC       "../../src/*.c")
4305e00d57SMatthias Ringwaldfile(GLOB SOURCES_BLE       "../../src/ble/*.c")
4405e00d57SMatthias Ringwaldfile(GLOB SOURCES_GATT      "../../src/ble/gatt-service/*.c")
4505e00d57SMatthias Ringwaldfile(GLOB SOURCES_MESH      "../../src/mesh/*.c")
4605e00d57SMatthias Ringwaldfile(GLOB SOURCES_UECC      "../../3rd-party/micro-ecc/uECC.c")
4705e00d57SMatthias Ringwaldfile(GLOB SOURCES_HXCMOD    "../../3rd-party/hxcmod-player/*.c"  "../../3rd-party/hxcmod-player/mods/*.c")
4805e00d57SMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL  "../../3rd-party/rijndael/rijndael.c")
4905e00d57SMatthias Ringwaldfile(GLOB SOURCES_POSIX     "../../platform/posix/*.c")
5005e00d57SMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR    "../../chipset/zephyr/*.c")
5105e00d57SMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c")
5205e00d57SMatthias Ringwaldfile(GLOB SOURCES_PORT      "*.c")
5305e00d57SMatthias Ringwald
5405e00d57SMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c")
5505e00d57SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE   ${SOURCES_BLE_OFF})
5605e00d57SMatthias Ringwald
5705e00d57SMatthias Ringwaldfile(GLOB SOURCES_POSIX_OFF "../../platform/posix/le_device_db_fs.c" "../../platform/posix/btstack_link_key_db_fs.c")
5805e00d57SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_POSIX ${SOURCES_POSIX_OFF})
5905e00d57SMatthias Ringwald
6005e00d57SMatthias Ringwaldset(SOURCES
6105e00d57SMatthias Ringwald	${SOURCES_BLE}
6205e00d57SMatthias Ringwald	${SOURCES_GATT}
6305e00d57SMatthias Ringwald	${SOURCES_HXCMOD}
6405e00d57SMatthias Ringwald	${SOURCES_LC3_GOOGLE}
6505e00d57SMatthias Ringwald	${SOURCES_MESH}
6605e00d57SMatthias Ringwald	${SOURCES_PORT}
6705e00d57SMatthias Ringwald	${SOURCES_POSIX}
6805e00d57SMatthias Ringwald	${SOURCES_RIJNDAEL}
6905e00d57SMatthias Ringwald	${SOURCES_SRC}
7005e00d57SMatthias Ringwald	${SOURCES_UECC}
7105e00d57SMatthias Ringwald	${SOURCES_ZEPHYR}
7205e00d57SMatthias Ringwald)
7305e00d57SMatthias Ringwaldlist(SORT SOURCES)
7405e00d57SMatthias Ringwald
7505e00d57SMatthias Ringwald# create static lib
7605e00d57SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES})
7705e00d57SMatthias Ringwald
7857f681c0SMatthias Ringwald# pkgconfig
79*caeaa206SMatthias Ringwaldfind_package(PkgConfig)
8057f681c0SMatthias Ringwald
8157f681c0SMatthias Ringwald# portaudio
8257f681c0SMatthias Ringwaldif (PkgConfig_FOUND)
83*caeaa206SMatthias Ringwald	pkg_check_modules(PORTAUDIO portaudio-2.0)
8457f681c0SMatthias Ringwald	if(PORTAUDIO_FOUND)
8557f681c0SMatthias Ringwald		message("HAVE_PORTAUDIO")
8657f681c0SMatthias Ringwald		include_directories(${PORTAUDIO_INCLUDE_DIRS})
8757f681c0SMatthias Ringwald		link_directories(${PORTAUDIO_LIBRARY_DIRS})
8857f681c0SMatthias Ringwald		link_libraries(${PORTAUDIO_LIBRARIES})
89*caeaa206SMatthias Ringwald		add_compile_definitions(HAVE_PORTAUDIO)
9057f681c0SMatthias Ringwald	endif()
9157f681c0SMatthias Ringwaldendif()
9257f681c0SMatthias Ringwald
9357f681c0SMatthias Ringwald# pthread
9457f681c0SMatthias Ringwaldfind_package(Threads)
9557f681c0SMatthias Ringwaldlink_libraries(${CMAKE_THREAD_LIBS_INIT})
9657f681c0SMatthias Ringwald
9705e00d57SMatthias Ringwald# get list of examples
9805e00d57SMatthias Ringwaldinclude(../../example/CMakeLists.txt)
9905e00d57SMatthias Ringwaldset (EXAMPLES ${EXAMPLES_LE_ONLY} ${EXAMPLES_GENERAL})
10005e00d57SMatthias Ringwald
10105e00d57SMatthias Ringwald# create targets
10205e00d57SMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES})
10305e00d57SMatthias Ringwald	# get c file
1041e0ee29bSMatthias Ringwald	set (SOURCES_EXAMPLE ${BTSTACK_ROOT}/example/${EXAMPLE}.c)
10505e00d57SMatthias Ringwald
10605e00d57SMatthias Ringwald	# add GATT DB creation
10705e00d57SMatthias Ringwald	if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} )
10805e00d57SMatthias Ringwald		message("example ${EXAMPLE} -- with GATT DB")
10905e00d57SMatthias Ringwald	  	add_custom_command(
11005e00d57SMatthias Ringwald		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
11102bddf72SMatthias Ringwald			DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt
11202bddf72SMatthias Ringwald			COMMAND ${Python_EXECUTABLE}
11302bddf72SMatthias Ringwald			ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
11405e00d57SMatthias Ringwald		)
115bbce5facSMatthias Ringwald		list(APPEND SOURCES_EXAMPLE ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
11605e00d57SMatthias Ringwald	else()
11705e00d57SMatthias Ringwald		message("example ${EXAMPLE}")
11805e00d57SMatthias Ringwald	endif()
1191e0ee29bSMatthias Ringwald	add_executable(${EXAMPLE} ${SOURCES_EXAMPLE})
12005e00d57SMatthias Ringwald	target_link_libraries(${EXAMPLE} btstack)
12105e00d57SMatthias Ringwaldendforeach(EXAMPLE)
122