xref: /btstack/port/windows-winusb/CMakeLists.txt (revision 42c5c5581b83a00e2c1de42e4fe687a30b9efa5a)
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
20*42c5c558SMatthias Ringwald# pkgconfig
21*42c5c558SMatthias Ringwaldfind_package(PkgConfig REQUIRED)
22*42c5c558SMatthias Ringwald
23*42c5c558SMatthias Ringwald# portaudio
24*42c5c558SMatthias Ringwaldpkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0)
25*42c5c558SMatthias Ringwaldif(PORTAUDIO_FOUND)
26*42c5c558SMatthias Ringwald	message("HAVE_PORTAUDIO")
27*42c5c558SMatthias Ringwald	include_directories(${PORTAUDIO_INCLUDE_DIRS})
28*42c5c558SMatthias Ringwald	link_directories(${PORTAUDIO_LIBRARY_DIRS})
29*42c5c558SMatthias Ringwald	link_libraries(${PORTAUDIO_LIBRARIES})
30*42c5c558SMatthias Ringwald	# CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO)
31*42c5c558SMatthias Ringwald	SET(CMAKE_C_FLAGS  "-DHAVE_PORTAUDIO")
32*42c5c558SMatthias Ringwaldendif()
33*42c5c558SMatthias Ringwald
3402bddf72SMatthias Ringwald# to generate .h from .gatt files
3502bddf72SMatthias Ringwaldfind_package (Python REQUIRED COMPONENTS Interpreter)
368b0cf348SMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR})
378b0cf348SMatthias Ringwald
388b0cf348SMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile
398b0cf348SMatthias Ringwaldinclude_directories(.)
408b0cf348SMatthias Ringwald
418b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/decoder/include)
428b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/bluedroid/encoder/include)
438b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc)
448b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include)
458b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/md5)
468b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player)
478b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/hxcmod-player/mod)
488b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael)
498b0cf348SMatthias Ringwaldinclude_directories(../../3rd-party/yxml)
508b0cf348SMatthias Ringwaldinclude_directories(../../src)
518b0cf348SMatthias Ringwaldinclude_directories(../../chipset/zephyr)
528b0cf348SMatthias Ringwaldinclude_directories(../../platform/embedded)
538b0cf348SMatthias Ringwaldinclude_directories(../../platform/posix)
548b0cf348SMatthias Ringwaldinclude_directories(../../platform/windows)
558b0cf348SMatthias Ringwald
568b0cf348SMatthias Ringwaldfile(GLOB SOURCES_SRC       "../../src/*.c" "../../example/sco_demo_util.c" "../../platform/posix/wav_util.c")
578b0cf348SMatthias Ringwaldfile(GLOB SOURCES_BLUEDROID "../../3rd-party/bluedroid/encoder/srce/*.c" "../../3rd-party/bluedroid/decoder/srce/*.c")
588b0cf348SMatthias Ringwaldfile(GLOB SOURCES_CLASSIC   "../../src/classic/*.c")
598b0cf348SMatthias Ringwaldfile(GLOB SOURCES_BLE       "../../src/ble/*.c")
608b0cf348SMatthias Ringwaldfile(GLOB SOURCES_GATT      "../../src/ble/gatt-service/*.c")
618b0cf348SMatthias Ringwaldfile(GLOB SOURCES_UECC      "../../3rd-party/micro-ecc/uECC.c")
628b0cf348SMatthias Ringwaldfile(GLOB SOURCES_HXCMOD    "../../3rd-party/hxcmod-player/*.c"  "../../3rd-party/hxcmod-player/mods/*.c")
638b0cf348SMatthias Ringwaldfile(GLOB SOURCES_MD5       "../../3rd-party/md5/md5.c")
648b0cf348SMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL  "../../3rd-party/rijndael/rijndael.c")
658b0cf348SMatthias Ringwaldfile(GLOB SOURCES_WINDOWS   "../../platform/windows/*.c")
668b0cf348SMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR    "../../chipset/zephyr/*.c")
678b0cf348SMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "../../3rd-party/lc3-google/src/*.c")
68*42c5c558SMatthias Ringwaldfile(GLOB SOURCES_PORT      "main.c" "../../platform/posix/btstack_audio_portaudio.c")
698b0cf348SMatthias Ringwaldfile(GLOB SOURCES_YXML      "../../3rd-party/yxml/yxml.c")
708b0cf348SMatthias Ringwald
718b0cf348SMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "../../src/ble/le_device_db_memory.c")
728b0cf348SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE   ${SOURCES_BLE_OFF})
738b0cf348SMatthias Ringwald
748b0cf348SMatthias Ringwald
75*42c5c558SMatthias Ringwald
768b0cf348SMatthias Ringwaldset(SOURCES
778b0cf348SMatthias Ringwald	${SOURCES_BLE}
788b0cf348SMatthias Ringwald	${SOURCES_BLUEDROID}
798b0cf348SMatthias Ringwald	${SOURCES_CLASSIC}
808b0cf348SMatthias Ringwald	${SOURCES_GATT}
818b0cf348SMatthias Ringwald	${SOURCES_HXCMOD}
828b0cf348SMatthias Ringwald	${SOURCES_MD5}
838b0cf348SMatthias Ringwald	${SOURCES_PORT}
848b0cf348SMatthias Ringwald	${SOURCES_RIJNDAEL}
858b0cf348SMatthias Ringwald	${SOURCES_SRC}
868b0cf348SMatthias Ringwald	${SOURCES_UECC}
878b0cf348SMatthias Ringwald	${SOURCES_WINDOWS}
888b0cf348SMatthias Ringwald	${SOURCES_YXML}
898b0cf348SMatthias Ringwald	${SOURCES_ZEPHYR}
908b0cf348SMatthias Ringwald)
918b0cf348SMatthias Ringwaldlist(SORT SOURCES)
928b0cf348SMatthias Ringwald
938b0cf348SMatthias Ringwald# create static lib
948b0cf348SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES})
958b0cf348SMatthias Ringwald
968b0cf348SMatthias Ringwald# get list of examples, skipping mesh_node_demo
978b0cf348SMatthias Ringwaldinclude(../../example/CMakeLists.txt)
988b0cf348SMatthias Ringwaldset (EXAMPLES ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY}  ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE})
998b0cf348SMatthias Ringwaldlist(REMOVE_DUPLICATES EXAMPLES)
1008b0cf348SMatthias Ringwaldlist(REMOVE_ITEM EXAMPLES "mesh_node_demo")
1018b0cf348SMatthias Ringwald
1028b0cf348SMatthias Ringwald# create targets
1038b0cf348SMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES})
1048b0cf348SMatthias Ringwald	# get c file
1051e0ee29bSMatthias Ringwald	set (SOURCES_EXAMPLE ${BTSTACK_ROOT}/example/${EXAMPLE}.c)
1068b0cf348SMatthias Ringwald
1078b0cf348SMatthias Ringwald	# add GATT DB creation
1088b0cf348SMatthias Ringwald	if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} )
1098b0cf348SMatthias Ringwald		message("example ${EXAMPLE} -- with GATT DB")
1108b0cf348SMatthias Ringwald	  	add_custom_command(
1118b0cf348SMatthias Ringwald		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
11202bddf72SMatthias Ringwald			DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt
11302bddf72SMatthias Ringwald			COMMAND ${Python_EXECUTABLE}
11402bddf72SMatthias Ringwald			ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
1158b0cf348SMatthias Ringwald		)
1168b0cf348SMatthias Ringwald		list(APPEND SOURCE_FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
1178b0cf348SMatthias Ringwald	else()
1188b0cf348SMatthias Ringwald		message("example ${EXAMPLE}")
1198b0cf348SMatthias Ringwald	endif()
1201e0ee29bSMatthias Ringwald	add_executable(${EXAMPLE} ${SOURCES_EXAMPLE})
121e111ffb1SMatthias Ringwald	target_link_libraries(${EXAMPLE} btstack setupapi winusb)
1228b0cf348SMatthias Ringwaldendforeach(EXAMPLE)
123