xref: /btstack/port/windows-h4-zephyr/CMakeLists.txt (revision caeaa206eb51459f9342b4042b1af2ec395bf0ac)
1*caeaa206SMatthias Ringwaldcmake_minimum_required (VERSION 3.12)
2cb97e8fbSMatthias Ringwald
3cb97e8fbSMatthias Ringwaldproject(BTstack-windows-h4-zephyr)
4cb97e8fbSMatthias Ringwald
5dce6d7b3SMatthias RingwaldSET(BTSTACK_ROOT ${CMAKE_SOURCE_DIR}/../..)
6dce6d7b3SMatthias Ringwald
7cb97e8fbSMatthias Ringwald# extra compiler warnings
8cb97e8fbSMatthias Ringwaldif ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*")
9cb97e8fbSMatthias Ringwald	# using Clang
10cb97e8fbSMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-variable -Wswitch-default -Werror")
11cb97e8fbSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
12cb97e8fbSMatthias Ringwald	# using GCC
13cb97e8fbSMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror")
14cb97e8fbSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
15cb97e8fbSMatthias Ringwald	# using Intel C++
16cb97e8fbSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
17cb97e8fbSMatthias Ringwald	# using Visual Studio C++
18cb97e8fbSMatthias Ringwaldendif()
19cb97e8fbSMatthias Ringwald
2002bddf72SMatthias Ringwald# to generate .h from .gatt files
2102bddf72SMatthias Ringwaldfind_package (Python REQUIRED COMPONENTS Interpreter)
22cb97e8fbSMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR})
23cb97e8fbSMatthias Ringwald
24cb97e8fbSMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile
25cb97e8fbSMatthias Ringwaldinclude_directories(.)
26cb97e8fbSMatthias Ringwald
27cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc)
28cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include)
29cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/md5)
30cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player)
31cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod)
32cb97e8fbSMatthias Ringwaldinclude_directories(../../3rd-party/rijndael)
33cb97e8fbSMatthias Ringwaldinclude_directories(../../src)
34cb97e8fbSMatthias Ringwaldinclude_directories(../../chipset/zephyr)
35cb97e8fbSMatthias Ringwaldinclude_directories(../../platform/embedded)
36cb97e8fbSMatthias Ringwaldinclude_directories(../../platform/windows)
37cb97e8fbSMatthias Ringwald
38cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_SRC       "../../src/*.c")
39cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_BLE       "../../src/ble/*.c")
40cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_GATT      "../../src/ble/gatt-service/*.c")
41cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_UECC      "../../3rd-party/micro-ecc/uECC.c")
42cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_HXCMOD    "../../3rd-party/hxcmod-player/*.c"  "../../3rd-party/hxcmod-player/mods/*.c")
43cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL  "../../3rd-party/rijndael/rijndael.c")
44cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_WINDOWS   "../../platform/windows/*.c")
45cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR    "../../chipset/zephyr/*.c")
46cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c")
47cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_PORT      "*.c")
48cb97e8fbSMatthias Ringwald
49cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c")
50cb97e8fbSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE   ${SOURCES_BLE_OFF})
51cb97e8fbSMatthias Ringwald
52cb97e8fbSMatthias Ringwaldfile(GLOB SOURCES_WINDOWS_OFF "../../platform/windows/hci_transport_h2_winusb.c")
53cb97e8fbSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_WINDOWS   ${SOURCES_WINDOWS_OFF})
54cb97e8fbSMatthias Ringwald
55cb97e8fbSMatthias Ringwald
56cb97e8fbSMatthias Ringwaldset(SOURCES
57cb97e8fbSMatthias Ringwald	${SOURCES_BLE}
58cb97e8fbSMatthias Ringwald	${SOURCES_GATT}
59cb97e8fbSMatthias Ringwald	${SOURCES_HXCMOD}
60cb97e8fbSMatthias Ringwald	${SOURCES_PORT}
61cb97e8fbSMatthias Ringwald	${SOURCES_RIJNDAEL}
62cb97e8fbSMatthias Ringwald	${SOURCES_SRC}
63cb97e8fbSMatthias Ringwald	${SOURCES_UECC}
64cb97e8fbSMatthias Ringwald	${SOURCES_ZEPHYR}
65cb97e8fbSMatthias Ringwald	${SOURCES_WINDOWS}
66cb97e8fbSMatthias Ringwald)
67cb97e8fbSMatthias Ringwaldlist(SORT SOURCES)
68cb97e8fbSMatthias Ringwald
69cb97e8fbSMatthias Ringwald# create static lib
70cb97e8fbSMatthias Ringwaldadd_library(btstack STATIC ${SOURCES})
71cb97e8fbSMatthias Ringwald
7257f681c0SMatthias Ringwald# pkgconfig
73*caeaa206SMatthias Ringwaldfind_package(PkgConfig)
7457f681c0SMatthias Ringwald
7557f681c0SMatthias Ringwald# portaudio
7657f681c0SMatthias Ringwaldif (PkgConfig_FOUND)
77*caeaa206SMatthias Ringwald	pkg_check_modules(PORTAUDIO portaudio-2.0)
7857f681c0SMatthias Ringwald	if(PORTAUDIO_FOUND)
7957f681c0SMatthias Ringwald		message("HAVE_PORTAUDIO")
8057f681c0SMatthias Ringwald		include_directories(${PORTAUDIO_INCLUDE_DIRS})
8157f681c0SMatthias Ringwald		link_directories(${PORTAUDIO_LIBRARY_DIRS})
8257f681c0SMatthias Ringwald		link_libraries(${PORTAUDIO_LIBRARIES})
83*caeaa206SMatthias Ringwald		add_compile_definitions(HAVE_PORTAUDIO)
8457f681c0SMatthias Ringwald	endif()
8557f681c0SMatthias Ringwaldendif()
8657f681c0SMatthias Ringwald
87cb97e8fbSMatthias Ringwald# get list of examples, skipping mesh_node_demo
88cb97e8fbSMatthias Ringwaldinclude(../../example/CMakeLists.txt)
89cb97e8fbSMatthias Ringwaldset (EXAMPLES ${EXAMPLES_LE_ONLY} ${EXAMPLES_GENERAL})
90cb97e8fbSMatthias Ringwaldlist(REMOVE_ITEM EXAMPLES "mesh_node_demo")
91cb97e8fbSMatthias Ringwald
92cb97e8fbSMatthias Ringwald# create targets
93cb97e8fbSMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES})
94cb97e8fbSMatthias Ringwald	# get c file
951e0ee29bSMatthias Ringwald	set (SOURCES_EXAMPLE ${BTSTACK_ROOT}/example/${EXAMPLE}.c)
96cb97e8fbSMatthias Ringwald
97cb97e8fbSMatthias Ringwald	# add GATT DB creation
98cb97e8fbSMatthias Ringwald	if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} )
99cb97e8fbSMatthias Ringwald		message("example ${EXAMPLE} -- with GATT DB")
100cb97e8fbSMatthias Ringwald	  	add_custom_command(
101cb97e8fbSMatthias Ringwald		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
10202bddf72SMatthias Ringwald			DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt
10302bddf72SMatthias Ringwald			COMMAND ${Python_EXECUTABLE}
10402bddf72SMatthias Ringwald			ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
105cb97e8fbSMatthias Ringwald		)
106bbce5facSMatthias Ringwald		list(APPEND SOURCES_EXAMPLE ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
107cb97e8fbSMatthias Ringwald	else()
108cb97e8fbSMatthias Ringwald		message("example ${EXAMPLE}")
109cb97e8fbSMatthias Ringwald	endif()
1101e0ee29bSMatthias Ringwald	add_executable(${EXAMPLE} ${SOURCES_EXAMPLE})
111cb97e8fbSMatthias Ringwald	target_link_libraries(${EXAMPLE} btstack)
112cb97e8fbSMatthias Ringwaldendforeach(EXAMPLE)
113