xref: /btstack/port/windows-h4-zephyr/CMakeLists.txt (revision 57f681c0f6daf7a74c0508286bfbd7ba6590c7c9)
1cb97e8fbSMatthias Ringwaldcmake_minimum_required (VERSION 3.5)
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
72*57f681c0SMatthias Ringwald# pkgconfig
73*57f681c0SMatthias Ringwaldfind_package(PkgConfig QUIET)
74*57f681c0SMatthias Ringwald
75*57f681c0SMatthias Ringwald# portaudio
76*57f681c0SMatthias Ringwaldif (PkgConfig_FOUND)
77*57f681c0SMatthias Ringwald	pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0)
78*57f681c0SMatthias Ringwald	if(PORTAUDIO_FOUND)
79*57f681c0SMatthias Ringwald		message("HAVE_PORTAUDIO")
80*57f681c0SMatthias Ringwald		include_directories(${PORTAUDIO_INCLUDE_DIRS})
81*57f681c0SMatthias Ringwald		link_directories(${PORTAUDIO_LIBRARY_DIRS})
82*57f681c0SMatthias Ringwald		link_libraries(${PORTAUDIO_LIBRARIES})
83*57f681c0SMatthias Ringwald		# CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO)
84*57f681c0SMatthias Ringwald		SET(CMAKE_C_FLAGS  "-DHAVE_PORTAUDIO")
85*57f681c0SMatthias Ringwald	endif()
86*57f681c0SMatthias Ringwaldendif()
87*57f681c0SMatthias Ringwald
88*57f681c0SMatthias Ringwald
89cb97e8fbSMatthias Ringwald# get list of examples, skipping mesh_node_demo
90cb97e8fbSMatthias Ringwaldinclude(../../example/CMakeLists.txt)
91cb97e8fbSMatthias Ringwaldset (EXAMPLES ${EXAMPLES_LE_ONLY} ${EXAMPLES_GENERAL})
92cb97e8fbSMatthias Ringwaldlist(REMOVE_ITEM EXAMPLES "mesh_node_demo")
93cb97e8fbSMatthias Ringwald
94cb97e8fbSMatthias Ringwald# create targets
95cb97e8fbSMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES})
96cb97e8fbSMatthias Ringwald	# get c file
971e0ee29bSMatthias Ringwald	set (SOURCES_EXAMPLE ${BTSTACK_ROOT}/example/${EXAMPLE}.c)
98cb97e8fbSMatthias Ringwald
99cb97e8fbSMatthias Ringwald	# add GATT DB creation
100cb97e8fbSMatthias Ringwald	if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} )
101cb97e8fbSMatthias Ringwald		message("example ${EXAMPLE} -- with GATT DB")
102cb97e8fbSMatthias Ringwald	  	add_custom_command(
103cb97e8fbSMatthias Ringwald		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
10402bddf72SMatthias Ringwald			DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt
10502bddf72SMatthias Ringwald			COMMAND ${Python_EXECUTABLE}
10602bddf72SMatthias Ringwald			ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
107cb97e8fbSMatthias Ringwald		)
108bbce5facSMatthias Ringwald		list(APPEND SOURCES_EXAMPLE ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
109cb97e8fbSMatthias Ringwald	else()
110cb97e8fbSMatthias Ringwald		message("example ${EXAMPLE}")
111cb97e8fbSMatthias Ringwald	endif()
1121e0ee29bSMatthias Ringwald	add_executable(${EXAMPLE} ${SOURCES_EXAMPLE})
113cb97e8fbSMatthias Ringwald	target_link_libraries(${EXAMPLE} btstack)
114cb97e8fbSMatthias Ringwaldendforeach(EXAMPLE)
115