xref: /btstack/test/mesh/CMakeLists.txt (revision 2b6ecffc7fb32ca6316289f83fcad739ef69c659)
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
14*2b6ecffcSMatthias Ringwald# fink pkgconfig
15*2b6ecffcSMatthias Ringwaldfind_package(PkgConfig REQUIRED)
16*2b6ecffcSMatthias Ringwald
17*2b6ecffcSMatthias Ringwald# libusb
18*2b6ecffcSMatthias Ringwaldpkg_check_modules(LIBUSB REQUIRED libusb-1.0)
19*2b6ecffcSMatthias Ringwaldinclude_directories(${LIBUSB_INCLUDE_DIRS})
20*2b6ecffcSMatthias Ringwaldlink_directories(${LIBUSB_LIBRARY_DIRS})
21*2b6ecffcSMatthias Ringwaldlink_libraries(${LIBUSB_LIBRARIES})
221d1c93c5SMatthias Ringwald
231d1c93c5SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc)
241d1c93c5SMatthias Ringwaldinclude_directories(../../3rd-party/tinydir)
251d1c93c5SMatthias Ringwaldinclude_directories(../../src)
261d1c93c5SMatthias Ringwaldinclude_directories(../../platform/posix)
276fb99087SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael)
281d1c93c5SMatthias Ringwaldinclude_directories(.)
291d1c93c5SMatthias Ringwald
30d935ec81SMatthias Ringwaldfile(GLOB SOURCES_SRC       "../../src/*.c"                     "../../src/*.h" "../../example/sco_demo_util.c" "../../example/sco_demo_util.h")
31d935ec81SMatthias Ringwaldfile(GLOB SOURCES_BLE       "../../src/ble/*.c"                 "../../src/ble/*.h")
32d935ec81SMatthias Ringwaldfile(GLOB SOURCES_GATT      "../../src/ble/gatt-service/*.c"    "../../src/ble/gatt-service/*.h")
3377ba3d3fSMatthias Ringwaldfile(GLOB SOURCES_MESH      "../../src/mesh/*.c"                "../../src/mesh/*.h" )
34d935ec81SMatthias Ringwaldfile(GLOB SOURCES_UECC      "../../3rd-party/micro-ecc/uECC.c"  "../../3rd-party/micro-ecc/uECC.h")
35d935ec81SMatthias Ringwaldfile(GLOB SOURCES_POSIX     "../../platform/posix/*.c"          "../../platform/posix/*.h")
36d935ec81SMatthias Ringwaldfile(GLOB SOURCES_LIBUSB    "../../platform/libusb/*.c"         "../../platform/libusb/*.h")
371d1c93c5SMatthias Ringwald
38d935ec81SMatthias Ringwald
39d935ec81SMatthias 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")
401d1c93c5SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_OFF})
411d1c93c5SMatthias Ringwald
42a5a7b6daSMatthias Ringwaldset(SOURCES_MESH_NEW main.c)
431d1c93c5SMatthias Ringwald
441d1c93c5SMatthias Ringwaldset(SOURCES
451d1c93c5SMatthias Ringwald	${SOURCES_POSIX}
461d1c93c5SMatthias Ringwald	${SOURCES_LIBUSB}
471d1c93c5SMatthias Ringwald	${SOURCES_SRC}
481d1c93c5SMatthias Ringwald	${SOURCES_BLE}
491d1c93c5SMatthias Ringwald	${SOURCES_MESH}
501d1c93c5SMatthias Ringwald	${SOURCES_MESH_NEW}
511d1c93c5SMatthias Ringwald	${SOURCES_GATT}
521d1c93c5SMatthias Ringwald	${SOURCES_UECC}
531d1c93c5SMatthias Ringwald)
541d1c93c5SMatthias Ringwaldlist(SORT SOURCES)
551d1c93c5SMatthias Ringwald
561d1c93c5SMatthias Ringwald# create static lib
571d1c93c5SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES})
581d1c93c5SMatthias Ringwald
591d1c93c5SMatthias Ringwald# list of targets
60a5a7b6daSMatthias Ringwaldset(EXAMPLES_C mesh_pts.c)
610b2c76e9SMatthias Ringwald
620b2c76e9SMatthias Ringwaldfile(GLOB EXAMPLES_GATT "*.gatt")
631d1c93c5SMatthias Ringwald
641d1c93c5SMatthias Ringwald# create targets
650b2c76e9SMatthias Ringwaldforeach(EXAMPLE_FILE ${EXAMPLES_C})
661d1c93c5SMatthias Ringwald	get_filename_component(EXAMPLE ${EXAMPLE_FILE} NAME_WE)
670b2c76e9SMatthias Ringwald	if ( "${EXAMPLES_GATT}" MATCHES ${EXAMPLE} )
680b2c76e9SMatthias Ringwald		message("example ${EXAMPLE} -- with GATT DB")
690b2c76e9SMatthias Ringwald		add_custom_command(
700b2c76e9SMatthias Ringwald		    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h
710b2c76e9SMatthias Ringwald    		COMMAND ${CMAKE_SOURCE_DIR}/../../tool/compile_gatt.py ${CMAKE_SOURCE_DIR}/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h > /dev/null
720b2c76e9SMatthias Ringwald		)
730b2c76e9SMatthias Ringwald		add_executable(${EXAMPLE} ${EXAMPLE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h)
740b2c76e9SMatthias Ringwald	else()
751d1c93c5SMatthias Ringwald		message("example ${EXAMPLE}")
761d1c93c5SMatthias Ringwald		add_executable(${EXAMPLE} ${EXAMPLE_FILE})
770b2c76e9SMatthias Ringwald	endif()
781d1c93c5SMatthias Ringwald	target_link_libraries(${EXAMPLE} btstack)
791d1c93c5SMatthias Ringwaldendforeach(EXAMPLE_FILE)
8084242f88SMatthias Ringwald
811e116f54SMatthias Ringwald## hard-coded tests that use CPPUtest
8284242f88SMatthias Ringwald
831e116f54SMatthias Ringwaldmessage("example mesh_message_test")
8484242f88SMatthias Ringwaldinclude_directories( /usr/local/include)
8584242f88SMatthias Ringwaldlink_directories( /usr/local/lib)
8684242f88SMatthias Ringwaldlink_libraries(CppUTest CppUTestExt)
8784242f88SMatthias Ringwaldadd_executable(mesh_message_test
8884242f88SMatthias Ringwald../../src/mesh/mesh_foundation.c
8984242f88SMatthias Ringwald../../src/mesh/mesh_node.c
9084242f88SMatthias Ringwald../../src/mesh/mesh_iv_index_seq_number.c
9184242f88SMatthias Ringwald../../src/mesh/mesh_network.c
9284242f88SMatthias Ringwald../../src/mesh/mesh_peer.c
9384242f88SMatthias Ringwald../../src/mesh/mesh_lower_transport.c
9484242f88SMatthias Ringwald../../src/mesh/mesh_upper_transport.c
9584242f88SMatthias Ringwald../../src/mesh/mesh_virtual_addresses.c
9684242f88SMatthias Ringwald../../src/mesh/mesh_keys.c
9784242f88SMatthias Ringwald../../src/mesh/mesh_crypto.c
9884242f88SMatthias Ringwald../../src/btstack_memory.c
9984242f88SMatthias Ringwald../../src/btstack_memory_pool.c
10084242f88SMatthias Ringwald../../src/btstack_util.c
10184242f88SMatthias Ringwald../../src/btstack_crypto.c
10284242f88SMatthias Ringwald../../src/btstack_linked_list.c
10384242f88SMatthias Ringwald../../src/hci_dump.c
10484242f88SMatthias Ringwald../../src/hci_cmd.c
10584242f88SMatthias Ringwald../../3rd-party/micro-ecc/uECC.c
1066fb99087SMatthias Ringwald../../3rd-party/rijndael/rijndael.c
10784242f88SMatthias Ringwaldmock.c
10884242f88SMatthias Ringwaldmesh_message_test.cpp
10984242f88SMatthias Ringwald)
11084242f88SMatthias Ringwald
1111e116f54SMatthias Ringwaldmessage("example provisioning_device_test")
1121e116f54SMatthias Ringwaldadd_executable(provisioning_device_test
1131e116f54SMatthias Ringwaldprovisioning_device_test.cpp
1141e116f54SMatthias Ringwaldmock.c
1151e116f54SMatthias Ringwald../../3rd-party/micro-ecc/uECC.c
1161e116f54SMatthias Ringwald../../3rd-party/rijndael/rijndael.c
1171e116f54SMatthias Ringwald../../src/mesh/mesh_crypto.c
1181e116f54SMatthias Ringwald../../src/mesh/provisioning_device.c
1191e116f54SMatthias Ringwald../../src/mesh/mesh_node.c
1201e116f54SMatthias Ringwald../../src/btstack_crypto.c
1211e116f54SMatthias Ringwald../../src/btstack_util.c
1221e116f54SMatthias Ringwald../../src/btstack_linked_list.c
1231e116f54SMatthias Ringwald../../src/hci_cmd.c
1241e116f54SMatthias Ringwald../../src/hci_dump.c
1251e116f54SMatthias Ringwald)
12684242f88SMatthias Ringwald
1271e116f54SMatthias Ringwaldmessage("example provisioning_provisioner_test")
1281e116f54SMatthias Ringwaldadd_executable(provisioning_provisioner_test
1291e116f54SMatthias Ringwaldprovisioning_provisioner_test.cpp
1301e116f54SMatthias Ringwaldmock.c
1311e116f54SMatthias Ringwald../../3rd-party/micro-ecc/uECC.c
1321e116f54SMatthias Ringwald../../3rd-party/rijndael/rijndael.c
1331e116f54SMatthias Ringwald../../src/btstack_crypto.c
1341e116f54SMatthias Ringwald../../src/mesh/provisioning_provisioner.c
1351e116f54SMatthias Ringwald ../../src/mesh/mesh_crypto.c
1361e116f54SMatthias Ringwald../../src/btstack_crypto.c
1371e116f54SMatthias Ringwald../../src/btstack_util.c
1381e116f54SMatthias Ringwald../../src/btstack_linked_list.c
1391e116f54SMatthias Ringwald../../src/hci_cmd.c
1401e116f54SMatthias Ringwald../../src/hci_dump.c
1411e116f54SMatthias Ringwald)
14284242f88SMatthias Ringwald
1431e116f54SMatthias Ringwaldmessage("example mesh_configuration_composition_data_message_test")
1441e116f54SMatthias Ringwaldadd_executable(mesh_configuration_composition_data_message_test
1451e116f54SMatthias Ringwaldmesh_configuration_composition_data_message_test.cpp
1461e116f54SMatthias Ringwald../../src/mesh/mesh_configuration_client.c
1471e116f54SMatthias Ringwald)
1481e116f54SMatthias Ringwaldtarget_link_libraries(mesh_configuration_composition_data_message_test btstack)
149