xref: /btstack/port/windows-h4/CMakeLists.txt (revision bbce5fac02e7c3fe4c462c8b329e4dc586c0f952)
14e03265bSMatthias Ringwaldcmake_minimum_required (VERSION 3.18)
24e03265bSMatthias Ringwald
34e03265bSMatthias Ringwaldproject(BTstack-windows-h4)
44e03265bSMatthias Ringwald
54e03265bSMatthias RingwaldSET(BTSTACK_ROOT ${CMAKE_SOURCE_DIR}/../..)
64e03265bSMatthias Ringwald
74e03265bSMatthias Ringwald# extra compiler warnings
84e03265bSMatthias Ringwaldif ("${CMAKE_C_COMPILER_ID}" MATCHES ".*Clang.*")
94e03265bSMatthias Ringwald	# using Clang
104e03265bSMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-variable -Wswitch-default -Werror")
114e03265bSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
124e03265bSMatthias Ringwald	# using GCC
134e03265bSMatthias Ringwald	SET(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} -Wunused-but-set-variable -Wunused-variable -Wswitch-default -Werror")
144e03265bSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel")
154e03265bSMatthias Ringwald	# using Intel C++
164e03265bSMatthias Ringwaldelseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
174e03265bSMatthias Ringwald	# using Visual Studio C++
184e03265bSMatthias Ringwaldendif()
194e03265bSMatthias Ringwald
2042c5c558SMatthias Ringwald# pkgconfig
217367e9aaSMatthias Ringwaldfind_package(PkgConfig QUIET)
2242c5c558SMatthias Ringwald
2342c5c558SMatthias Ringwald# portaudio
247367e9aaSMatthias Ringwaldif (PkgConfig_FOUND)
2542c5c558SMatthias Ringwald	pkg_check_modules(PORTAUDIO REQUIRED portaudio-2.0)
2642c5c558SMatthias Ringwald	if(PORTAUDIO_FOUND)
2742c5c558SMatthias Ringwald		message("HAVE_PORTAUDIO")
2842c5c558SMatthias Ringwald		include_directories(${PORTAUDIO_INCLUDE_DIRS})
2942c5c558SMatthias Ringwald		link_directories(${PORTAUDIO_LIBRARY_DIRS})
3042c5c558SMatthias Ringwald		link_libraries(${PORTAUDIO_LIBRARIES})
3142c5c558SMatthias Ringwald		# CMake 3.12 - add_compile_definitions(HAVE_PORTAUDIO)
3242c5c558SMatthias Ringwald		SET(CMAKE_C_FLAGS  "-DHAVE_PORTAUDIO")
3342c5c558SMatthias Ringwald	endif()
347367e9aaSMatthias Ringwaldendif()
3542c5c558SMatthias Ringwald
3602bddf72SMatthias Ringwald# to generate .h from .gatt files
3702bddf72SMatthias Ringwaldfind_package (Python REQUIRED COMPONENTS Interpreter)
384e03265bSMatthias Ringwaldinclude_directories(${CMAKE_CURRENT_BINARY_DIR})
394e03265bSMatthias Ringwald
404e03265bSMatthias Ringwald# local dir for btstack_config.h after build dir to avoid using .h from Makefile
414e03265bSMatthias Ringwaldinclude_directories(.)
424e03265bSMatthias Ringwald
434e03265bSMatthias Ringwald
444e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/micro-ecc)
454e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/include)
464e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/include)
474e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/lc3-google/include)
484e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/md5)
494e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/hxcmod-player)
504e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/hxcmod-player/mod)
514e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/lwip/core/src/include)
524e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server)
534e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/rijndael)
544e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/yxml)
554e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/3rd-party/tinydir)
564e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/src)
574e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/bcm)
584e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/csr)
594e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/cc256x)
604e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/em9301)
614e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/realtek)
624e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/tc3566x)
634e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/stlc2500d)
644e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/chipset/zephyr)
654e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/embedded)
664e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/lwip)
674e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/lwip/port)
684e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/windows)
694e03265bSMatthias Ringwaldinclude_directories(${BTSTACK_ROOT}/platform/posix)
704e03265bSMatthias Ringwald
714e03265bSMatthias Ringwaldfile(GLOB SOURCES_SRC       "${BTSTACK_ROOT}/src/*.c" "${BTSTACK_ROOT}/example/sco_demo_util.c")
724e03265bSMatthias Ringwaldfile(GLOB SOURCES_BLE       "${BTSTACK_ROOT}/src/ble/*.c")
734e03265bSMatthias Ringwaldfile(GLOB SOURCES_BLUEDROID "${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/srce/*.c" "${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/srce/*.c")
744e03265bSMatthias Ringwaldfile(GLOB SOURCES_CLASSIC   "${BTSTACK_ROOT}/src/classic/*.c")
754e03265bSMatthias Ringwaldfile(GLOB SOURCES_MESH      "${BTSTACK_ROOT}/src/mesh/*.c")
764e03265bSMatthias Ringwaldfile(GLOB SOURCES_GATT      "${BTSTACK_ROOT}/src/ble/gatt-service/*.c")
774e03265bSMatthias Ringwaldfile(GLOB SOURCES_UECC      "${BTSTACK_ROOT}/3rd-party/micro-ecc/uECC.c")
784e03265bSMatthias Ringwaldfile(GLOB SOURCES_HXCMOD    "${BTSTACK_ROOT}/3rd-party/hxcmod-player/*.c"  "${BTSTACK_ROOT}/3rd-party/hxcmod-player/mods/*.c")
794e03265bSMatthias Ringwaldfile(GLOB SOURCES_MD5       "${BTSTACK_ROOT}/3rd-party/md5/md5.c")
804e03265bSMatthias Ringwaldfile(GLOB SOURCES_RIJNDAEL  "${BTSTACK_ROOT}/3rd-party/rijndael/rijndael.c")
814e03265bSMatthias Ringwaldfile(GLOB SOURCES_YXML      "${BTSTACK_ROOT}/3rd-party/yxml/yxml.c")
824e03265bSMatthias Ringwaldfile(GLOB SOURCES_WINDOWS   "${BTSTACK_ROOT}/platform/windows/*.c" ${BTSTACK_ROOT}/platform/posix/wav_util.c)
834e03265bSMatthias Ringwaldfile(GLOB SOURCES_BCM       "${BTSTACK_ROOT}/chipset/bcm/*.c")
844e03265bSMatthias Ringwaldfile(GLOB SOURCES_CSR       "${BTSTACK_ROOT}/chipset/csr/*.c")
854e03265bSMatthias Ringwaldfile(GLOB SOURCES_EM9301    "${BTSTACK_ROOT}/chipset/em9301/*.c")
864e03265bSMatthias Ringwaldfile(GLOB SOURCES_STLC2500D "${BTSTACK_ROOT}/chipset/stlc2500d/*.c")
874e03265bSMatthias Ringwaldfile(GLOB SOURCES_TC2566X   "${BTSTACK_ROOT}/chipset/tc3566x/*.c")
884e03265bSMatthias Ringwaldfile(GLOB SOURCES_REALTEK   "${BTSTACK_ROOT}/chipset/realtek/*.c")
894e03265bSMatthias Ringwaldfile(GLOB SOURCES_ZEPHYR    "${BTSTACK_ROOT}/chipset/zephyr/*.c")
904e03265bSMatthias Ringwaldfile(GLOB SOURCES_LC3_GOOGLE "${BTSTACK_ROOT}/3rd-party/lc3-google/src/*.c")
914e03265bSMatthias Ringwaldfile(GLOB SOURCES_PORT      "*.c")
924e03265bSMatthias Ringwald
934e03265bSMatthias Ringwaldset(LWIP_CORE_SRC
944e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/def.c
954e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/inet_chksum.c
964e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/init.c
974e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ip.c
984e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/mem.c
994e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/memp.c
1004e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/netif.c
1014e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/pbuf.c
1024e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp.c
1034e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_in.c
1044e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_out.c
1054e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/timeouts.c
1064e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/udp.c
1074e03265bSMatthias Ringwald		)
1084e03265bSMatthias Ringwaldset (LWIP_IPV4_SRC
1094e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/acd.c
1104e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/dhcp.c
1114e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/etharp.c
1124e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/icmp.c
1134e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4.c
1144e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_addr.c
1154e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_frag.c
1164e03265bSMatthias Ringwald		)
1174e03265bSMatthias Ringwaldset (LWIP_NETIF_SRC
1184e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/netif/ethernet.c
1194e03265bSMatthias Ringwald		)
1204e03265bSMatthias Ringwaldset (LWIP_HTTPD
1214e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/altcp_proxyconnect.c
1224e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/fs.c
1234e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/httpd.c
1244e03265bSMatthias Ringwald		)
1254e03265bSMatthias Ringwaldset (LWIP_DHCPD
1264e03265bSMatthias Ringwald		${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server/dhserver.c
1274e03265bSMatthias Ringwald		)
1284e03265bSMatthias Ringwaldset (LWIP_PORT
1294e03265bSMatthias Ringwald		${BTSTACK_ROOT}/platform/lwip/port/sys_arch.c
1304e03265bSMatthias Ringwald		${BTSTACK_ROOT}//platform/lwip/bnep_lwip.c
1314e03265bSMatthias Ringwald		)
1324e03265bSMatthias Ringwaldset (SOURCES_LWIP ${LWIP_CORE_SRC} ${LWIP_IPV4_SRC} ${LWIP_NETIF_SRC} ${LWIP_HTTPD} ${LWIP_DHCPD} ${LWIP_PORT})
1334e03265bSMatthias Ringwald
1344e03265bSMatthias Ringwaldfile(GLOB SOURCES_BLE_OFF "${BTSTACK_ROOT}/src/ble/le_device_db_memory.c")
1354e03265bSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE   ${SOURCES_BLE_OFF})
1364e03265bSMatthias Ringwald
1374e03265bSMatthias Ringwaldfile(GLOB SOURCES_POSIX_OFF "${BTSTACK_ROOT}/platform/posix/le_device_db_fs.c")
1384e03265bSMatthias Ringwaldlist(REMOVE_ITEM SOURCES_POSIX   ${SOURCES_POSIX_OFF})
1394e03265bSMatthias Ringwald
1404e03265bSMatthias Ringwaldset(SOURCES
1414e03265bSMatthias Ringwald		${SOURCES_BLE}
1424e03265bSMatthias Ringwald		${SOURCES_BCM}
1434e03265bSMatthias Ringwald		${SOURCES_BLUEDROID}
1444e03265bSMatthias Ringwald		${SOURCES_CLASSIC}
1454e03265bSMatthias Ringwald		${SOURCES_CSR}
1464e03265bSMatthias Ringwald		${SOURCES_EM9301}
1474e03265bSMatthias Ringwald		${SOURCES_GATT}
1484e03265bSMatthias Ringwald		${SOURCES_HXCMOD}
1494e03265bSMatthias Ringwald		${SOURCES_HXCMOD}
1504e03265bSMatthias Ringwald		${SOURCES_LIBUSB}
1514e03265bSMatthias Ringwald		${SOURCES_MD5}
1524e03265bSMatthias Ringwald		${SOURCES_PORT}
1534e03265bSMatthias Ringwald		${SOURCES_REALTEK}
1544e03265bSMatthias Ringwald		${SOURCES_RIJNDAEL}
1554e03265bSMatthias Ringwald		${SOURCES_SRC}
1564e03265bSMatthias Ringwald		${SOURCES_CC256X}
1574e03265bSMatthias Ringwald		${SOURCES_CSR}
1584e03265bSMatthias Ringwald		${SOURCES_STLC2500D}
1594e03265bSMatthias Ringwald		${SOURCES_TC2566X}
1604e03265bSMatthias Ringwald		${SOURCES_UECC}
1614e03265bSMatthias Ringwald		${SOURCES_WINDOWS}
1624e03265bSMatthias Ringwald		${SOURCES_YXML}
1634e03265bSMatthias Ringwald		${SOURCES_ZEPHYR}
1644e03265bSMatthias Ringwald)
1654e03265bSMatthias Ringwaldlist(SORT SOURCES)
1664e03265bSMatthias Ringwald
1674e03265bSMatthias Ringwald# create static lib
1684e03265bSMatthias Ringwaldadd_library(btstack STATIC ${SOURCES})
1694e03265bSMatthias Ringwald
1704e03265bSMatthias Ringwald# Add CC256x Support and specify init script
1714e03265bSMatthias Ringwaldset (CC256X_INIT_SCRIPT bluetooth_init_cc2564C_1.5.c)
1724e03265bSMatthias Ringwaldinclude(${BTSTACK_ROOT}/chipset/cc256x/cc256x.cmake)
1734e03265bSMatthias Ringwald
1744e03265bSMatthias Ringwald# Add BCM Support and download PatchRAM files
1754e03265bSMatthias Ringwaldinclude(${BTSTACK_ROOT}/chipset/bcm/bcm.cmake)
1764e03265bSMatthias Ringwald
1774e03265bSMatthias Ringwald# get list of examples, skipping mesh_node_demo
1784e03265bSMatthias Ringwaldinclude(../../example/CMakeLists.txt)
1794e03265bSMatthias Ringwaldset (EXAMPLES ${EXAMPLES_GENERAL} ${EXAMPLES_CLASSIC_ONLY}  ${EXAMPLES_LE_ONLY} ${EXAMPLES_DUAL_MODE})
1804e03265bSMatthias Ringwaldlist(REMOVE_DUPLICATES EXAMPLES)
1814e03265bSMatthias Ringwaldlist(REMOVE_ITEM EXAMPLES "mesh_node_demo")
1824e03265bSMatthias Ringwald
1834e03265bSMatthias Ringwald# create targets
1844e03265bSMatthias Ringwaldforeach(EXAMPLE ${EXAMPLES})
1854e03265bSMatthias Ringwald	# get c file
1861e0ee29bSMatthias Ringwald	set (SOURCES_EXAMPLE ${BTSTACK_ROOT}/example/${EXAMPLE}.c)
1874e03265bSMatthias Ringwald
1884e03265bSMatthias Ringwald	# add GATT DB creation
1894e03265bSMatthias Ringwald	if ( "${EXAMPLES_GATT_FILES}" MATCHES ${EXAMPLE} )
1904e03265bSMatthias Ringwald		message("example ${EXAMPLE} -- with GATT DB")
1914e03265bSMatthias Ringwald	  	add_custom_command(
1924e03265bSMatthias Ringwald		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
1934e03265bSMatthias Ringwald			DEPENDS ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt
19402bddf72SMatthias Ringwald			COMMAND ${Python_EXECUTABLE}
1954e03265bSMatthias Ringwald			ARGS ${BTSTACK_ROOT}/tool/compile_gatt.py ${BTSTACK_ROOT}/example/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
1964e03265bSMatthias Ringwald		)
197*bbce5facSMatthias Ringwald		list(APPEND SOURCES_EXAMPLE ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
1984e03265bSMatthias Ringwald	else()
1994e03265bSMatthias Ringwald		message("example ${EXAMPLE}")
2004e03265bSMatthias Ringwald	endif()
2011e0ee29bSMatthias Ringwald	add_executable(${EXAMPLE} ${SOURCES_EXAMPLE})
2024e03265bSMatthias Ringwald	target_link_libraries(${EXAMPLE} btstack)
2034e03265bSMatthias Ringwaldendforeach(EXAMPLE)
204