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