xref: /btstack/test/mesh/CMakeLists.txt (revision c589a9bb896bd3ca6ce0b0556b913c50596ccdf8)
11d1c93c5SMatthias Ringwaldcmake_minimum_required (VERSION 3.5)
21d1c93c5SMatthias Ringwaldproject(BTstackMesh)
31d1c93c5SMatthias Ringwald
48eed8510SMatthias Ringwald# enable AddressSanitizer
58eed8510SMatthias Ringwaldset (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
68eed8510SMatthias Ringwaldset (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
78eed8510SMatthias Ringwaldset (CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address")
88eed8510SMatthias Ringwald
98eed8510SMatthias Ringwald# AddressSanitizer for Xcode
108eed8510SMatthias Ringwaldset(CMAKE_XCODE_GENERATE_SCHEME ON)
118eed8510SMatthias Ringwaldset(CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER ON)
128eed8510SMatthias Ringwaldset(CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN ON)
138eed8510SMatthias Ringwald
142b6ecffcSMatthias Ringwald# fink pkgconfig
152b6ecffcSMatthias Ringwaldfind_package(PkgConfig REQUIRED)
162b6ecffcSMatthias Ringwald
172b6ecffcSMatthias Ringwald# libusb
182b6ecffcSMatthias Ringwaldpkg_check_modules(LIBUSB REQUIRED libusb-1.0)
192b6ecffcSMatthias Ringwaldinclude_directories(${LIBUSB_INCLUDE_DIRS})
202b6ecffcSMatthias Ringwaldlink_directories(${LIBUSB_LIBRARY_DIRS})
212b6ecffcSMatthias Ringwaldlink_libraries(${LIBUSB_LIBRARIES})
221d1c93c5SMatthias Ringwald
231d1c93c5SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc)
24d567aeb3SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael)
251d1c93c5SMatthias Ringwaldinclude_directories(../../3rd-party/tinydir)
26d567aeb3SMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include/)
271d1c93c5SMatthias Ringwaldinclude_directories(../../src)
281d1c93c5SMatthias Ringwaldinclude_directories(../../platform/posix)
291d1c93c5SMatthias Ringwaldinclude_directories(.)
301d1c93c5SMatthias Ringwald
31d935ec81SMatthias Ringwaldfile(GLOB SOURCES_SRC       "../../src/*.c"                     "../../src/*.h" "../../example/sco_demo_util.c" "../../example/sco_demo_util.h")
32d935ec81SMatthias Ringwaldfile(GLOB SOURCES_BLE       "../../src/ble/*.c"                 "../../src/ble/*.h")
33d935ec81SMatthias Ringwaldfile(GLOB SOURCES_GATT      "../../src/ble/gatt-service/*.c"    "../../src/ble/gatt-service/*.h")
34d567aeb3SMatthias Ringwaldfile(GLOB SOURCES_MESH      "../../src/mesh/*.c"                "../../src/mesh/*.h"   "../../src/mesh/gatt-service/*.c")
35d935ec81SMatthias Ringwaldfile(GLOB SOURCES_UECC      "../../3rd-party/micro-ecc/uECC.c"  "../../3rd-party/micro-ecc/uECC.h")
36d935ec81SMatthias Ringwaldfile(GLOB SOURCES_POSIX     "../../platform/posix/*.c"          "../../platform/posix/*.h")
37d935ec81SMatthias Ringwaldfile(GLOB SOURCES_LIBUSB    "../../platform/libusb/*.c"         "../../platform/libusb/*.h")
381d1c93c5SMatthias Ringwald
39d935ec81SMatthias Ringwald
40d935ec81SMatthias Ringwaldfile(GLOB SOURCES_OFF "../../src/ble/le_device_db_memory.c" "../../src/ble/le_device_db_memory.h" "../../src/ble/le_device_db_tlv.c" "../../src/ble/le_device_db_tlv.h")
411d1c93c5SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_OFF})
421d1c93c5SMatthias Ringwald
43a5a7b6daSMatthias Ringwaldset(SOURCES_MESH_NEW main.c)
441d1c93c5SMatthias Ringwald
451d1c93c5SMatthias Ringwaldset(SOURCES
461d1c93c5SMatthias Ringwald	${SOURCES_POSIX}
471d1c93c5SMatthias Ringwald	${SOURCES_LIBUSB}
481d1c93c5SMatthias Ringwald	${SOURCES_SRC}
491d1c93c5SMatthias Ringwald	${SOURCES_BLE}
501d1c93c5SMatthias Ringwald	${SOURCES_MESH}
511d1c93c5SMatthias Ringwald	${SOURCES_MESH_NEW}
521d1c93c5SMatthias Ringwald	${SOURCES_GATT}
531d1c93c5SMatthias Ringwald	${SOURCES_UECC}
541d1c93c5SMatthias Ringwald)
551d1c93c5SMatthias Ringwaldlist(SORT SOURCES)
561d1c93c5SMatthias Ringwald
571d1c93c5SMatthias Ringwald# create static lib
581d1c93c5SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES})
591d1c93c5SMatthias Ringwald
601d1c93c5SMatthias Ringwald# list of targets
61a5a7b6daSMatthias Ringwaldset(EXAMPLES_C mesh_pts.c)
620b2c76e9SMatthias Ringwald
630b2c76e9SMatthias Ringwaldfile(GLOB EXAMPLES_GATT "*.gatt")
641d1c93c5SMatthias Ringwald
651d1c93c5SMatthias Ringwald# create targets
660b2c76e9SMatthias Ringwaldforeach(EXAMPLE_FILE ${EXAMPLES_C})
671d1c93c5SMatthias Ringwald	get_filename_component(EXAMPLE ${EXAMPLE_FILE} NAME_WE)
680b2c76e9SMatthias Ringwald	if ( "${EXAMPLES_GATT}" MATCHES ${EXAMPLE} )
690b2c76e9SMatthias Ringwald		message("example ${EXAMPLE} -- with GATT DB")
700b2c76e9SMatthias Ringwald		add_custom_command(
710b2c76e9SMatthias Ringwald		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
720b2c76e9SMatthias Ringwald    		COMMAND ${CMAKE_SOURCE_DIR}/../../tool/compile_gatt.py ${CMAKE_SOURCE_DIR}/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h > /dev/null
730b2c76e9SMatthias Ringwald		)
740b2c76e9SMatthias Ringwald		add_executable(${EXAMPLE} ${EXAMPLE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
750b2c76e9SMatthias Ringwald	else()
761d1c93c5SMatthias Ringwald		message("example ${EXAMPLE}")
771d1c93c5SMatthias Ringwald		add_executable(${EXAMPLE} ${EXAMPLE_FILE})
780b2c76e9SMatthias Ringwald	endif()
791d1c93c5SMatthias Ringwald	target_link_libraries(${EXAMPLE} btstack)
801d1c93c5SMatthias Ringwaldendforeach(EXAMPLE_FILE)
8184242f88SMatthias Ringwald
82*c589a9bbSMatthias Ringwald# pkgconfig required to link cpputest
83*c589a9bbSMatthias Ringwaldfind_package(PkgConfig REQUIRED)
84*c589a9bbSMatthias Ringwald
85*c589a9bbSMatthias Ringwald# CppuTest
86*c589a9bbSMatthias Ringwaldpkg_check_modules(CPPUTEST REQUIRED CppuTest)
87*c589a9bbSMatthias Ringwaldinclude_directories(${CPPUTEST_INCLUDE_DIRS})
88*c589a9bbSMatthias Ringwaldlink_directories(${CPPUTEST_LIBRARY_DIRS})
89*c589a9bbSMatthias Ringwaldlink_libraries(${CPPUTEST_LIBRARIES})
9084242f88SMatthias Ringwald
911e116f54SMatthias Ringwaldmessage("example mesh_message_test")
92*c589a9bbSMatthias Ringwald
9384242f88SMatthias Ringwaldadd_executable(mesh_message_test
9484242f88SMatthias Ringwald../../src/mesh/mesh_foundation.c
9584242f88SMatthias Ringwald../../src/mesh/mesh_node.c
9684242f88SMatthias Ringwald../../src/mesh/mesh_iv_index_seq_number.c
9784242f88SMatthias Ringwald../../src/mesh/mesh_network.c
9884242f88SMatthias Ringwald../../src/mesh/mesh_peer.c
9984242f88SMatthias Ringwald../../src/mesh/mesh_lower_transport.c
10084242f88SMatthias Ringwald../../src/mesh/mesh_upper_transport.c
10184242f88SMatthias Ringwald../../src/mesh/mesh_virtual_addresses.c
10284242f88SMatthias Ringwald../../src/mesh/mesh_keys.c
10384242f88SMatthias Ringwald../../src/mesh/mesh_crypto.c
10484242f88SMatthias Ringwald../../src/btstack_memory.c
10584242f88SMatthias Ringwald../../src/btstack_memory_pool.c
10684242f88SMatthias Ringwald../../src/btstack_util.c
10784242f88SMatthias Ringwald../../src/btstack_crypto.c
10884242f88SMatthias Ringwald../../src/btstack_linked_list.c
10984242f88SMatthias Ringwald../../src/hci_dump.c
110d567aeb3SMatthias Ringwald../../platform/posix/hci_dump_posix_fs.c
11184242f88SMatthias Ringwald../../src/hci_cmd.c
11284242f88SMatthias Ringwald../../3rd-party/micro-ecc/uECC.c
1136fb99087SMatthias Ringwald../../3rd-party/rijndael/rijndael.c
11484242f88SMatthias Ringwaldmock.c
11584242f88SMatthias Ringwaldmesh_message_test.cpp
11684242f88SMatthias Ringwald)
11784242f88SMatthias Ringwald
1181e116f54SMatthias Ringwaldmessage("example provisioning_device_test")
1191e116f54SMatthias Ringwaldadd_executable(provisioning_device_test
1201e116f54SMatthias Ringwaldprovisioning_device_test.cpp
1211e116f54SMatthias Ringwaldmock.c
1221e116f54SMatthias Ringwald../../3rd-party/micro-ecc/uECC.c
1231e116f54SMatthias Ringwald../../3rd-party/rijndael/rijndael.c
1241e116f54SMatthias Ringwald../../src/mesh/mesh_crypto.c
1251e116f54SMatthias Ringwald../../src/mesh/provisioning_device.c
1261e116f54SMatthias Ringwald../../src/mesh/mesh_node.c
1271e116f54SMatthias Ringwald../../src/btstack_crypto.c
1281e116f54SMatthias Ringwald../../src/btstack_util.c
1291e116f54SMatthias Ringwald../../src/btstack_linked_list.c
1301e116f54SMatthias Ringwald../../src/hci_cmd.c
1311e116f54SMatthias Ringwald../../src/hci_dump.c
132d567aeb3SMatthias Ringwald../../platform/posix/hci_dump_posix_fs.c
1331e116f54SMatthias Ringwald)
13484242f88SMatthias Ringwald
1351e116f54SMatthias Ringwaldmessage("example provisioning_provisioner_test")
1361e116f54SMatthias Ringwaldadd_executable(provisioning_provisioner_test
1371e116f54SMatthias Ringwaldprovisioning_provisioner_test.cpp
1381e116f54SMatthias Ringwaldmock.c
1391e116f54SMatthias Ringwald../../3rd-party/micro-ecc/uECC.c
1401e116f54SMatthias Ringwald../../3rd-party/rijndael/rijndael.c
1411e116f54SMatthias Ringwald../../src/btstack_crypto.c
1421e116f54SMatthias Ringwald../../src/mesh/provisioning_provisioner.c
1431e116f54SMatthias Ringwald ../../src/mesh/mesh_crypto.c
1441e116f54SMatthias Ringwald../../src/btstack_crypto.c
1451e116f54SMatthias Ringwald../../src/btstack_util.c
1461e116f54SMatthias Ringwald../../src/btstack_linked_list.c
1471e116f54SMatthias Ringwald../../src/hci_cmd.c
1481e116f54SMatthias Ringwald../../src/hci_dump.c
149d567aeb3SMatthias Ringwald../../platform/posix/hci_dump_posix_fs.c
1501e116f54SMatthias Ringwald)
15184242f88SMatthias Ringwald
1521e116f54SMatthias Ringwaldmessage("example mesh_configuration_composition_data_message_test")
1531e116f54SMatthias Ringwaldadd_executable(mesh_configuration_composition_data_message_test
1541e116f54SMatthias Ringwaldmesh_configuration_composition_data_message_test.cpp
1551e116f54SMatthias Ringwald../../src/mesh/mesh_configuration_client.c
1561e116f54SMatthias Ringwald)
1571e116f54SMatthias Ringwaldtarget_link_libraries(mesh_configuration_composition_data_message_test btstack)
158