xref: /btstack/port/windows-winusb/CMakeLists.txt (revision 57f681c0f6daf7a74c0508286bfbd7ba6590c7c9)
18b0cf348SMatthias Ringwaldcmake_minimum_required (VERSION 3.5)
28b0cf348SMatthias Ringwald
38b0cf348SMatthias Ringwaldproject(BTstack-windows-winusb)
48b0cf348SMatthias Ringwald
5dce6d7b3SMatthias RingwaldSET(BTSTACK_ROOT ${CMAKE_SOURCE_DIR}/../..)
6dce6d7b3SMatthias Ringwald
78b0cf348SMatthias Ringwald# extra compiler warnings
88b0cf348SMatthias Ringwaldif ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*")
98b0cf348SMatthias Ringwald	# using Clang
108b0cf348SMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-variable -Wswitch-default -Werror")
118b0cf348SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
128b0cf348SMatthias Ringwald	# using GCC
138b0cf348SMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror")
148b0cf348SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
158b0cf348SMatthias Ringwald	# using Intel C++
168b0cf348SMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
178b0cf348SMatthias Ringwald	# using Visual Studio C++
188b0cf348SMatthias Ringwaldendif()
198b0cf348SMatthias Ringwald
2042c5c558SMatthias Ringwald
2102bddf72SMatthias Ringwald# to generate .h from .gatt files
2202bddf72SMatthias Ringwaldfind_package (Python REQUIRED COMPONENTS Interpreter)
238b0cf348SMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR})
248b0cf348SMatthias Ringwald
258b0cf348SMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile
268b0cf348SMatthias Ringwaldinclude_directories(.)
278b0cf348SMatthias Ringwald
288b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/decoder/include)
298b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/encoder/include)
308b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc)
318b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include)
328b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/md5)
338b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player)
348b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod)
358b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael)
368b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/yxml)
378b0cf348SMatthias Ringwaldinclude_directories(../../src)
388b0cf348SMatthias Ringwaldinclude_directories(../../chipset/zephyr)
398b0cf348SMatthias Ringwaldinclude_directories(../../platform/embedded)
408b0cf348SMatthias Ringwaldinclude_directories(../../platform/posix)
418b0cf348SMatthias Ringwaldinclude_directories(../../platform/windows)
428b0cf348SMatthias Ringwald
438b0cf348SMatthias Ringwaldfile(GLOB SOURCES_SRC       "../../src/*.c" "../../example/sco_demo_util.c" "../../platform/posix/wav_util.c")
448b0cf348SMatthias Ringwaldfile(GLOB SOURCES_BLUEDROID "../../3rd-party/bluedroid/encoder/srce/*.c" "../../3rd-party/bluedroid/decoder/srce/*.c")
458b0cf348SMatthias Ringwaldfile(GLOB SOURCES_CLASSIC   "../../src/classic/*.c")
468b0cf348SMatthias Ringwaldfile(GLOB SOURCES_BLE       "../../src/ble/*.c")
478b0cf348SMatthias Ringwaldfile(GLOB SOURCES_GATT      "../../src/ble/gatt-service/*.c")
488b0cf348SMatthias Ringwaldfile(GLOB SOURCES_UECC      "../../3rd-party/micro-ecc/uECC.c")
498b0cf348SMatthias Ringwaldfile(GLOB SOURCES_HXCMOD    "../../3rd-party/hxcmod-player/*.c"  "../../3rd-party/hxcmod-player/mods/*.c")
508b0cf348SMatthias Ringwaldfile(GLOB SOURCES_MD5       "../../3rd-party/md5/md5.c")
518b0cf348SMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL  "../../3rd-party/rijndael/rijndael.c")
528b0cf348SMatthias Ringwaldfile(GLOB SOURCES_WINDOWS   "../../platform/windows/*.c")
538b0cf348SMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR    "../../chipset/zephyr/*.c")
548b0cf348SMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c")
5542c5c558SMatthias Ringwaldfile(GLOB SOURCES_PORT      "main.c" "../../platform/posix/btstack_audio_portaudio.c")
568b0cf348SMatthias Ringwaldfile(GLOB SOURCES_YXML      "../../3rd-party/yxml/yxml.c")
578b0cf348SMatthias Ringwald
588b0cf348SMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c")
598b0cf348SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE   ${SOURCES_BLE_OFF})
608b0cf348SMatthias Ringwald
618b0cf348SMatthias Ringwaldset(SOURCES
628b0cf348SMatthias Ringwald	${SOURCES_BLE}
638b0cf348SMatthias Ringwald	${SOURCES_BLUEDROID}
648b0cf348SMatthias Ringwald	${SOURCES_CLASSIC}
658b0cf348SMatthias Ringwald	${SOURCES_GATT}
668b0cf348SMatthias Ringwald	${SOURCES_HXCMOD}
678b0cf348SMatthias Ringwald	${SOURCES_MD5}
688b0cf348SMatthias Ringwald	${SOURCES_PORT}
698b0cf348SMatthias Ringwald	${SOURCES_RIJNDAEL}
708b0cf348SMatthias Ringwald	${SOURCES_SRC}
718b0cf348SMatthias Ringwald	${SOURCES_UECC}
728b0cf348SMatthias Ringwald	${SOURCES_WINDOWS}
738b0cf348SMatthias Ringwald	${SOURCES_YXML}
748b0cf348SMatthias Ringwald	${SOURCES_ZEPHYR}
758b0cf348SMatthias Ringwald)
768b0cf348SMatthias Ringwaldlist(SORT SOURCES)
778b0cf348SMatthias Ringwald
788b0cf348SMatthias Ringwald# create static lib
798b0cf348SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES})
808b0cf348SMatthias Ringwald
81*57f681c0SMatthias Ringwald# pkgconfig
82*57f681c0SMatthias Ringwaldfind_package(PkgConfig QUIET)
83*57f681c0SMatthias Ringwald
84*57f681c0SMatthias Ringwald# portaudio
85*57f681c0SMatthias Ringwaldif (PkgConfig_FOUND)
86*57f681c0SMatthias Ringwald	pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0)
87*57f681c0SMatthias Ringwald	if(PORTAUDIO_FOUND)
88*57f681c0SMatthias Ringwald		message("HAVE_PORTAUDIO")
89*57f681c0SMatthias Ringwald		include_directories(${PORTAUDIO_INCLUDE_DIRS})
90*57f681c0SMatthias Ringwald		link_directories(${PORTAUDIO_LIBRARY_DIRS})
91*57f681c0SMatthias Ringwald		link_libraries(${PORTAUDIO_LIBRARIES})
92*57f681c0SMatthias Ringwald		# CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO)
93*57f681c0SMatthias Ringwald		SET(CMAKE_C_FLAGS  "-DHAVE_PORTAUDIO")
94*57f681c0SMatthias Ringwald	endif()
95*57f681c0SMatthias Ringwaldendif()
96*57f681c0SMatthias Ringwald
97*57f681c0SMatthias Ringwald
988b0cf348SMatthias Ringwald# get list of examples, skipping mesh_node_demo
998b0cf348SMatthias Ringwaldinclude(../../example/CMakeLists.txt)
1008b0cf348SMatthias Ringwaldset (EXAMPLES ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY}  ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE})
1018b0cf348SMatthias Ringwaldlist(REMOVE_DUPLICATES EXAMPLES)
1028b0cf348SMatthias Ringwaldlist(REMOVE_ITEM EXAMPLES "mesh_node_demo")
1038b0cf348SMatthias Ringwald
1048b0cf348SMatthias Ringwald# create targets
1058b0cf348SMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES})
1068b0cf348SMatthias Ringwald	# get c file
1071e0ee29bSMatthias Ringwald	set (SOURCES_EXAMPLE ${BTSTACK_ROOT}/example/${EXAMPLE}.c)
1088b0cf348SMatthias Ringwald
1098b0cf348SMatthias Ringwald	# add GATT DB creation
1108b0cf348SMatthias Ringwald	if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} )
1118b0cf348SMatthias Ringwald		message("example ${EXAMPLE} -- with GATT DB")
1128b0cf348SMatthias Ringwald	  	add_custom_command(
1138b0cf348SMatthias Ringwald		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
11402bddf72SMatthias Ringwald			DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt
11502bddf72SMatthias Ringwald			COMMAND ${Python_EXECUTABLE}
11602bddf72SMatthias Ringwald			ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
1178b0cf348SMatthias Ringwald		)
118bbce5facSMatthias Ringwald		list(APPEND SOURCES_EXAMPLE ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
1198b0cf348SMatthias Ringwald	else()
1208b0cf348SMatthias Ringwald		message("example ${EXAMPLE}")
1218b0cf348SMatthias Ringwald	endif()
1221e0ee29bSMatthias Ringwald	add_executable(${EXAMPLE} ${SOURCES_EXAMPLE})
123e111ffb1SMatthias Ringwald	target_link_libraries(${EXAMPLE} btstack setupapi winusb)
1248b0cf348SMatthias Ringwaldendforeach(EXAMPLE)
125