xref: /btstack/port/windows-winusb-intel/CMakeLists.txt (revision e3ba22907f903f11cd12321c31e7936b8dd1157e)
1cmake_minimum_required (VERSION 3.5)
2
3project(BTstack-windows-winusb-intel)
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# Generate .h from .gatt files
37find_package (Python COMPONENTS Interpreter)
38include_directories(${CMAKE_CURRENT_BINARY_DIR})
39message ("Python: ${Python_EXECUTABLE}")
40
41# local dir for btstack_config.h after build dir to avoid using .h from Makefile
42include_directories(.)
43
44include_directories(../../3rd-party/bluedroid/decoder/include)
45include_directories(../../3rd-party/bluedroid/encoder/include)
46include_directories(../../3rd-party/micro-ecc)
47include_directories(../../3rd-party/lc3-google/include)
48include_directories(../../3rd-party/md5)
49include_directories(../../3rd-party/hxcmod-player)
50include_directories(../../3rd-party/hxcmod-player/mod)
51include_directories(../../3rd-party/rijndael)
52include_directories(../../3rd-party/yxml)
53include_directories(../../src)
54include_directories(../../chipset/csr)
55include_directories(../../chipset/intel)
56include_directories(../../chipset/zephyr)
57include_directories(../../platform/embedded)
58include_directories(../../platform/posix)
59include_directories(../../platform/windows)
60
61file(GLOB SOURCES_SRC       "../../src/*.c" "../../example/sco_demo_util.c" "../../platform/posix/wav_util.c")
62file(GLOB SOURCES_BLUEDROID "../../3rd-party/bluedroid/encoder/srce/*.c" "../../3rd-party/bluedroid/decoder/srce/*.c")
63file(GLOB SOURCES_CLASSIC   "../../src/classic/*.c")
64file(GLOB SOURCES_BLE       "../../src/ble/*.c")
65file(GLOB SOURCES_GATT      "../../src/ble/gatt-service/*.c")
66file(GLOB SOURCES_UECC      "../../3rd-party/micro-ecc/uECC.c")
67file(GLOB SOURCES_HXCMOD    "../../3rd-party/hxcmod-player/*.c"  "../../3rd-party/hxcmod-player/mods/*.c")
68file(GLOB SOURCES_MD5       "../../3rd-party/md5/md5.c")
69file(GLOB SOURCES_RIJNDAEL  "../../3rd-party/rijndael/rijndael.c")
70file(GLOB SOURCES_WINDOWS   "../../platform/windows/*.c")
71file(GLOB SOURCES_CSR       "../../chipset/csr/*.c")
72file(GLOB SOURCES_INTEL     "../../chipset/intel/*.c")
73file(GLOB SOURCES_ZEPHYR    "../../chipset/zephyr/*.c")
74file(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c")
75file(GLOB SOURCES_PORT      "*.c")
76file(GLOB SOURCES_YXML      "../../3rd-party/yxml/yxml.c")
77
78file(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c")
79list(REMOVE_ITEM SOURCES_BLE   ${SOURCES_BLE_OFF})
80
81
82set(SOURCES
83	${SOURCES_BLE}
84	${SOURCES_BLUEDROID}
85	${SOURCES_CLASSIC}
86	${SOURCES_GATT}
87	${SOURCES_HXCMOD}
88	${SOURCES_MD5}
89	${SOURCES_PORT}
90	${SOURCES_RIJNDAEL}
91	${SOURCES_SRC}
92	${SOURCES_UECC}
93	${SOURCES_WINDOWS}
94	${SOURCES_YXML}
95	${SOURCES_CSR}
96	${SOURCES_INTEL}
97	${SOURCES_ZEPHYR}
98)
99list(SORT SOURCES)
100
101# create static lib
102add_library(btstack STATIC ${SOURCES})
103
104# get list of examples, skipping mesh_node_demo
105include(../../example/CMakeLists.txt)
106set (EXAMPLES ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY}  ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE})
107list(REMOVE_DUPLICATES EXAMPLES)
108list(REMOVE_ITEM EXAMPLES "mesh_node_demo")
109
110# create targets
111foreach(EXAMPLE ${EXAMPLES})
112	# get c file
113	set (SOURCES_EXAMPLE ${BTSTACK_ROOT}/example/${EXAMPLE}.c)
114
115	# add GATT DB creation
116	if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} )
117		message("example ${EXAMPLE} -- with GATT DB")
118	  	add_custom_command(
119		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
120			DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt
121			COMMAND ${Python_EXECUTABLE}
122			ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
123		)
124		list(APPEND SOURCES_EXAMPLE ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
125	else()
126		message("example ${EXAMPLE}")
127	endif()
128	add_executable(${EXAMPLE} ${SOURCES_EXAMPLE})
129	target_link_libraries(${EXAMPLE} btstack setupapi winusb)
130endforeach(EXAMPLE)
131