xref: /btstack/test/mesh/CMakeLists.txt (revision 0b2c76e9ae80f862eb9a423366c29b64386782f0)
11d1c93c5SMatthias Ringwaldcmake_minimum_required (VERSION 3.5)
21d1c93c5SMatthias Ringwaldproject(BTstackMesh)
31d1c93c5SMatthias Ringwald
41d1c93c5SMatthias Ringwald# add libusb
51d1c93c5SMatthias Ringwaldfind_path(LIBUSB_INCLUDE_DIR NAMES libusb.h PATH_SUFFIXES "include" "libusb" "libusb-1.0")
61d1c93c5SMatthias Ringwaldfind_library(LIBUSB_LIBRARY NAMES usb-1.0 PATH_SUFFIXES "lib" "lib32" "lib64" "dylib")
71d1c93c5SMatthias Ringwaldget_filename_component(LIBUSB_LIBRARY_PATH ${LIBUSB_LIBRARY} DIRECTORY)
81d1c93c5SMatthias Ringwaldinclude_directories( ${LIBUSB_INCLUDE_DIR} )
91d1c93c5SMatthias Ringwaldlink_directories( ${LIBUSB_LIBRARY_PATH} )
101d1c93c5SMatthias Ringwaldlink_libraries( usb-1.0 )
111d1c93c5SMatthias Ringwald
121d1c93c5SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc)
131d1c93c5SMatthias Ringwaldinclude_directories(../../3rd-party/tinydir)
141d1c93c5SMatthias Ringwaldinclude_directories(../../src)
151d1c93c5SMatthias Ringwaldinclude_directories(../../platform/posix)
161d1c93c5SMatthias Ringwald# include_directories(../../platform/embedded)
171d1c93c5SMatthias Ringwaldinclude_directories(.)
181d1c93c5SMatthias Ringwald
191d1c93c5SMatthias Ringwaldfile(GLOB SOURCES_SRC       "../../src/*.c" "../../example/sco_demo_util.c")
201d1c93c5SMatthias Ringwaldfile(GLOB SOURCES_BLE       "../../src/ble/*.c")
211d1c93c5SMatthias Ringwaldfile(GLOB SOURCES_MESH      "../../src/ble/mesh/*.c")
221d1c93c5SMatthias Ringwaldfile(GLOB SOURCES_GATT      "../../src/ble/gatt-service/*.c")
231d1c93c5SMatthias Ringwaldfile(GLOB SOURCES_UECC      "../../3rd-party/micro-ecc/uECC.c")
241d1c93c5SMatthias Ringwaldfile(GLOB SOURCES_POSIX     "../../platform/posix/*.c")
251d1c93c5SMatthias Ringwaldfile(GLOB SOURCES_LIBUSB    "../../platform/libusb/*.c")
261d1c93c5SMatthias Ringwald
271d1c93c5SMatthias Ringwaldfile(GLOB SOURCES_OFF "../../src/ble/le_device_db_memory.c" "../../src/ble/le_device_db_tlv.c")
281d1c93c5SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_OFF})
291d1c93c5SMatthias Ringwald
3046f4dee8SMatthias Ringwaldset(SOURCES_MESH_NEW main.c mesh_transport.c mesh_foundation.c mesh_keys.c mesh_virtual_addresses.c mesh_peer.c provisioner.c provisioning.c provisioning_device.c provisioning_provisioner.c)
311d1c93c5SMatthias Ringwald
321d1c93c5SMatthias Ringwaldset(SOURCES
331d1c93c5SMatthias Ringwald	${SOURCES_POSIX}
341d1c93c5SMatthias Ringwald	${SOURCES_LIBUSB}
351d1c93c5SMatthias Ringwald	${SOURCES_SRC}
361d1c93c5SMatthias Ringwald	${SOURCES_BLE}
371d1c93c5SMatthias Ringwald	${SOURCES_MESH}
381d1c93c5SMatthias Ringwald	${SOURCES_MESH_NEW}
391d1c93c5SMatthias Ringwald	${SOURCES_GATT}
401d1c93c5SMatthias Ringwald	${SOURCES_UECC}
411d1c93c5SMatthias Ringwald)
421d1c93c5SMatthias Ringwaldlist(SORT SOURCES)
431d1c93c5SMatthias Ringwald
441d1c93c5SMatthias Ringwald# create static lib
451d1c93c5SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES})
461d1c93c5SMatthias Ringwald
471d1c93c5SMatthias Ringwald# list of targets
48*0b2c76e9SMatthias Ringwaldset(EXAMPLES_C mesh.c)
49*0b2c76e9SMatthias Ringwald
50*0b2c76e9SMatthias Ringwaldfile(GLOB EXAMPLES_GATT "*.gatt")
511d1c93c5SMatthias Ringwald
521d1c93c5SMatthias Ringwald# create targets
53*0b2c76e9SMatthias Ringwaldforeach(EXAMPLE_FILE ${EXAMPLES_C})
541d1c93c5SMatthias Ringwald	get_filename_component(EXAMPLE ${EXAMPLE_FILE} NAME_WE)
55*0b2c76e9SMatthias Ringwald	if ( "${EXAMPLES_GATT}" MATCHES ${EXAMPLE} )
56*0b2c76e9SMatthias Ringwald		message("example ${EXAMPLE} -- with GATT DB")
57*0b2c76e9SMatthias Ringwald		add_custom_command(
58*0b2c76e9SMatthias Ringwald		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
59*0b2c76e9SMatthias Ringwald    		COMMAND ${CMAKE_SOURCE_DIR}/../../tool/compile_gatt.py ${CMAKE_SOURCE_DIR}/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h > /dev/null
60*0b2c76e9SMatthias Ringwald		)
61*0b2c76e9SMatthias Ringwald		add_executable(${EXAMPLE} ${EXAMPLE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
62*0b2c76e9SMatthias Ringwald	else()
631d1c93c5SMatthias Ringwald		message("example ${EXAMPLE}")
641d1c93c5SMatthias Ringwald		add_executable(${EXAMPLE} ${EXAMPLE_FILE})
65*0b2c76e9SMatthias Ringwald	endif()
661d1c93c5SMatthias Ringwald	target_link_libraries(${EXAMPLE} btstack)
671d1c93c5SMatthias Ringwaldendforeach(EXAMPLE_FILE)
68