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