xref: /btstack/port/windows-winusb/CMakeLists.txt (revision caeaa206eb51459f9342b4042b1af2ec395bf0ac)
1*caeaa206SMatthias Ringwaldcmake_minimum_required (VERSION 3.12)
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
8157f681c0SMatthias Ringwald# pkgconfig
8257f681c0SMatthias Ringwaldfind_package(PkgConfig QUIET)
8357f681c0SMatthias Ringwald
8457f681c0SMatthias Ringwald# portaudio
8557f681c0SMatthias Ringwaldif (PkgConfig_FOUND)
86*caeaa206SMatthias Ringwald	pkg_check_modules(PORTAUDIO portaudio-2.0)
8757f681c0SMatthias Ringwald	if(PORTAUDIO_FOUND)
8857f681c0SMatthias Ringwald		message("HAVE_PORTAUDIO")
8957f681c0SMatthias Ringwald		include_directories(${PORTAUDIO_INCLUDE_DIRS})
9057f681c0SMatthias Ringwald		link_directories(${PORTAUDIO_LIBRARY_DIRS})
9157f681c0SMatthias Ringwald		link_libraries(${PORTAUDIO_LIBRARIES})
92*caeaa206SMatthias Ringwald		add_compile_definitions(HAVE_PORTAUDIO)
9357f681c0SMatthias Ringwald	endif()
9457f681c0SMatthias Ringwaldendif()
9557f681c0SMatthias 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		)
116bbce5facSMatthias Ringwald		list(APPEND SOURCES_EXAMPLE ${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