xref: /btstack/port/windows-winusb-intel/CMakeLists.txt (revision caeaa206eb51459f9342b4042b1af2ec395bf0ac)
1*caeaa206SMatthias Ringwaldcmake_minimum_required (VERSION 3.12)
2b260a82eSMatthias Ringwald
3b260a82eSMatthias Ringwaldproject(BTstack-windows-winusb-intel)
4b260a82eSMatthias Ringwald
5b260a82eSMatthias RingwaldSET(BTSTACK_ROOT ${CMAKE_SOURCE_DIR}/../..)
6b260a82eSMatthias Ringwald
7b260a82eSMatthias Ringwald# extra compiler warnings
8b260a82eSMatthias Ringwaldif ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*")
9b260a82eSMatthias Ringwald	# using Clang
10b260a82eSMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-variable -Wswitch-default -Werror")
11b260a82eSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
12b260a82eSMatthias Ringwald	# using GCC
13b260a82eSMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror")
14b260a82eSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
15b260a82eSMatthias Ringwald	# using Intel C++
16b260a82eSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
17b260a82eSMatthias Ringwald	# using Visual Studio C++
18b260a82eSMatthias Ringwaldendif()
19b260a82eSMatthias Ringwald
2042c5c558SMatthias Ringwald
21b260a82eSMatthias Ringwald# Generate .h from .gatt files
22b260a82eSMatthias Ringwaldfind_package (Python COMPONENTS Interpreter)
23b260a82eSMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR})
24b260a82eSMatthias Ringwaldmessage ("Python: ${Python_EXECUTABLE}")
25b260a82eSMatthias Ringwald
26b260a82eSMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile
27b260a82eSMatthias Ringwaldinclude_directories(.)
28b260a82eSMatthias Ringwald
29b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/decoder/include)
30b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/encoder/include)
31b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc)
32b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include)
33b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/md5)
34b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player)
35b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod)
36b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/rijndael)
37b260a82eSMatthias Ringwaldinclude_directories(../../3rd-party/yxml)
38b260a82eSMatthias Ringwaldinclude_directories(../../src)
39b260a82eSMatthias Ringwaldinclude_directories(../../chipset/csr)
40b260a82eSMatthias Ringwaldinclude_directories(../../chipset/intel)
41b260a82eSMatthias Ringwaldinclude_directories(../../chipset/zephyr)
42b260a82eSMatthias Ringwaldinclude_directories(../../platform/embedded)
43b260a82eSMatthias Ringwaldinclude_directories(../../platform/posix)
44b260a82eSMatthias Ringwaldinclude_directories(../../platform/windows)
45b260a82eSMatthias Ringwald
46b260a82eSMatthias Ringwaldfile(GLOB SOURCES_SRC       "../../src/*.c" "../../example/sco_demo_util.c" "../../platform/posix/wav_util.c")
47b260a82eSMatthias Ringwaldfile(GLOB SOURCES_BLUEDROID "../../3rd-party/bluedroid/encoder/srce/*.c" "../../3rd-party/bluedroid/decoder/srce/*.c")
48b260a82eSMatthias Ringwaldfile(GLOB SOURCES_CLASSIC   "../../src/classic/*.c")
49b260a82eSMatthias Ringwaldfile(GLOB SOURCES_BLE       "../../src/ble/*.c")
50b260a82eSMatthias Ringwaldfile(GLOB SOURCES_GATT      "../../src/ble/gatt-service/*.c")
51b260a82eSMatthias Ringwaldfile(GLOB SOURCES_UECC      "../../3rd-party/micro-ecc/uECC.c")
52b260a82eSMatthias Ringwaldfile(GLOB SOURCES_HXCMOD    "../../3rd-party/hxcmod-player/*.c"  "../../3rd-party/hxcmod-player/mods/*.c")
53b260a82eSMatthias Ringwaldfile(GLOB SOURCES_MD5       "../../3rd-party/md5/md5.c")
54b260a82eSMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL  "../../3rd-party/rijndael/rijndael.c")
55b260a82eSMatthias Ringwaldfile(GLOB SOURCES_WINDOWS   "../../platform/windows/*.c")
56b260a82eSMatthias Ringwaldfile(GLOB SOURCES_CSR       "../../chipset/csr/*.c")
57b260a82eSMatthias Ringwaldfile(GLOB SOURCES_INTEL     "../../chipset/intel/*.c")
58b260a82eSMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR    "../../chipset/zephyr/*.c")
59b260a82eSMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c")
60b260a82eSMatthias Ringwaldfile(GLOB SOURCES_PORT      "*.c")
61b260a82eSMatthias Ringwaldfile(GLOB SOURCES_YXML      "../../3rd-party/yxml/yxml.c")
62b260a82eSMatthias Ringwald
63b260a82eSMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c")
64b260a82eSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE   ${SOURCES_BLE_OFF})
65b260a82eSMatthias Ringwald
66b260a82eSMatthias Ringwald
67b260a82eSMatthias Ringwaldset(SOURCES
68b260a82eSMatthias Ringwald	${SOURCES_BLE}
69b260a82eSMatthias Ringwald	${SOURCES_BLUEDROID}
70b260a82eSMatthias Ringwald	${SOURCES_CLASSIC}
71b260a82eSMatthias Ringwald	${SOURCES_GATT}
72b260a82eSMatthias Ringwald	${SOURCES_HXCMOD}
73b260a82eSMatthias Ringwald	${SOURCES_MD5}
74b260a82eSMatthias Ringwald	${SOURCES_PORT}
75b260a82eSMatthias Ringwald	${SOURCES_RIJNDAEL}
76b260a82eSMatthias Ringwald	${SOURCES_SRC}
77b260a82eSMatthias Ringwald	${SOURCES_UECC}
78b260a82eSMatthias Ringwald	${SOURCES_WINDOWS}
79b260a82eSMatthias Ringwald	${SOURCES_YXML}
80b260a82eSMatthias Ringwald	${SOURCES_CSR}
81b260a82eSMatthias Ringwald	${SOURCES_INTEL}
82b260a82eSMatthias Ringwald	${SOURCES_ZEPHYR}
83b260a82eSMatthias Ringwald)
84b260a82eSMatthias Ringwaldlist(SORT SOURCES)
85b260a82eSMatthias Ringwald
86b260a82eSMatthias Ringwald# create static lib
87b260a82eSMatthias Ringwaldadd_library(btstack STATIC ${SOURCES})
88b260a82eSMatthias Ringwald
8957f681c0SMatthias Ringwald# pkgconfig
9057f681c0SMatthias Ringwaldfind_package(PkgConfig QUIET)
9157f681c0SMatthias Ringwald
9257f681c0SMatthias Ringwald# portaudio
9357f681c0SMatthias Ringwaldif (PkgConfig_FOUND)
94*caeaa206SMatthias Ringwald	pkg_check_modules(PORTAUDIO portaudio-2.0)
9557f681c0SMatthias Ringwald	if(PORTAUDIO_FOUND)
9657f681c0SMatthias Ringwald		message("HAVE_PORTAUDIO")
9757f681c0SMatthias Ringwald		include_directories(${PORTAUDIO_INCLUDE_DIRS})
9857f681c0SMatthias Ringwald		link_directories(${PORTAUDIO_LIBRARY_DIRS})
9957f681c0SMatthias Ringwald		link_libraries(${PORTAUDIO_LIBRARIES})
100*caeaa206SMatthias Ringwald		add_compile_definitions(HAVE_PORTAUDIO)
10157f681c0SMatthias Ringwald	endif()
10257f681c0SMatthias Ringwaldendif()
10357f681c0SMatthias Ringwald
104b260a82eSMatthias Ringwald# get list of examples, skipping mesh_node_demo
105b260a82eSMatthias Ringwaldinclude(../../example/CMakeLists.txt)
106b260a82eSMatthias Ringwaldset (EXAMPLES ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY}  ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE})
107b260a82eSMatthias Ringwaldlist(REMOVE_DUPLICATES EXAMPLES)
108b260a82eSMatthias Ringwaldlist(REMOVE_ITEM EXAMPLES "mesh_node_demo")
109b260a82eSMatthias Ringwald
110b260a82eSMatthias Ringwald# create targets
111b260a82eSMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES})
112b260a82eSMatthias Ringwald	# get c file
113b260a82eSMatthias Ringwald	set (SOURCES_EXAMPLE ${BTSTACK_ROOT}/example/${EXAMPLE}.c)
114b260a82eSMatthias Ringwald
115b260a82eSMatthias Ringwald	# add GATT DB creation
116b260a82eSMatthias Ringwald	if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} )
117b260a82eSMatthias Ringwald		message("example ${EXAMPLE} -- with GATT DB")
118b260a82eSMatthias Ringwald	  	add_custom_command(
119b260a82eSMatthias Ringwald		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
120b260a82eSMatthias Ringwald			DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt
121b260a82eSMatthias Ringwald			COMMAND ${Python_EXECUTABLE}
122b260a82eSMatthias Ringwald			ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
123b260a82eSMatthias Ringwald		)
124b260a82eSMatthias Ringwald		list(APPEND SOURCES_EXAMPLE ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
125b260a82eSMatthias Ringwald	else()
126b260a82eSMatthias Ringwald		message("example ${EXAMPLE}")
127b260a82eSMatthias Ringwald	endif()
128b260a82eSMatthias Ringwald	add_executable(${EXAMPLE} ${SOURCES_EXAMPLE})
129b260a82eSMatthias Ringwald	target_link_libraries(${EXAMPLE} btstack setupapi winusb)
130b260a82eSMatthias Ringwaldendforeach(EXAMPLE)
131