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 23*cd897979SSteven Kneiserinclude_directories(../../3rd-party/bluedroid/decoder/include) 24*cd897979SSteven Kneiserinclude_directories(../../3rd-party/bluedroid/encoder/include) 251d1c93c5SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc) 26d567aeb3SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael) 271d1c93c5SMatthias Ringwaldinclude_directories(../../3rd-party/tinydir) 28d567aeb3SMatthias Ringwaldinclude_directories(../../3rd-party/lc3-google/include/) 291d1c93c5SMatthias Ringwaldinclude_directories(../../src) 301d1c93c5SMatthias Ringwaldinclude_directories(../../platform/posix) 311d1c93c5SMatthias Ringwaldinclude_directories(.) 321d1c93c5SMatthias Ringwald 33d935ec81SMatthias Ringwaldfile(GLOB SOURCES_SRC "../../src/*.c" "../../src/*.h" "../../example/sco_demo_util.c" "../../example/sco_demo_util.h") 34d935ec81SMatthias Ringwaldfile(GLOB SOURCES_BLE "../../src/ble/*.c" "../../src/ble/*.h") 35d935ec81SMatthias Ringwaldfile(GLOB SOURCES_GATT "../../src/ble/gatt-service/*.c" "../../src/ble/gatt-service/*.h") 36d567aeb3SMatthias Ringwaldfile(GLOB SOURCES_MESH "../../src/mesh/*.c" "../../src/mesh/*.h" "../../src/mesh/gatt-service/*.c") 37d935ec81SMatthias Ringwaldfile(GLOB SOURCES_UECC "../../3rd-party/micro-ecc/uECC.c" "../../3rd-party/micro-ecc/uECC.h") 38d935ec81SMatthias Ringwaldfile(GLOB SOURCES_POSIX "../../platform/posix/*.c" "../../platform/posix/*.h") 39d935ec81SMatthias Ringwaldfile(GLOB SOURCES_LIBUSB "../../platform/libusb/*.c" "../../platform/libusb/*.h") 401d1c93c5SMatthias Ringwald 41d935ec81SMatthias Ringwald 42d935ec81SMatthias 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") 431d1c93c5SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_OFF}) 441d1c93c5SMatthias Ringwald 45a5a7b6daSMatthias Ringwaldset(SOURCES_MESH_NEW main.c) 461d1c93c5SMatthias Ringwald 471d1c93c5SMatthias Ringwaldset(SOURCES 481d1c93c5SMatthias Ringwald ${SOURCES_POSIX} 491d1c93c5SMatthias Ringwald ${SOURCES_LIBUSB} 501d1c93c5SMatthias Ringwald ${SOURCES_SRC} 511d1c93c5SMatthias Ringwald ${SOURCES_BLE} 521d1c93c5SMatthias Ringwald ${SOURCES_MESH} 531d1c93c5SMatthias Ringwald ${SOURCES_MESH_NEW} 541d1c93c5SMatthias Ringwald ${SOURCES_GATT} 551d1c93c5SMatthias Ringwald ${SOURCES_UECC} 561d1c93c5SMatthias Ringwald) 571d1c93c5SMatthias Ringwaldlist(SORT SOURCES) 581d1c93c5SMatthias Ringwald 591d1c93c5SMatthias Ringwald# create static lib 601d1c93c5SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES}) 611d1c93c5SMatthias Ringwald 621d1c93c5SMatthias Ringwald# list of targets 63a5a7b6daSMatthias Ringwaldset(EXAMPLES_C mesh_pts.c) 640b2c76e9SMatthias Ringwald 650b2c76e9SMatthias Ringwaldfile(GLOB EXAMPLES_GATT "*.gatt") 661d1c93c5SMatthias Ringwald 671d1c93c5SMatthias Ringwald# create targets 680b2c76e9SMatthias Ringwaldforeach(EXAMPLE_FILE ${EXAMPLES_C}) 691d1c93c5SMatthias Ringwald get_filename_component(EXAMPLE ${EXAMPLE_FILE} NAME_WE) 700b2c76e9SMatthias Ringwald if ( "${EXAMPLES_GATT}" MATCHES ${EXAMPLE} ) 710b2c76e9SMatthias Ringwald message("example ${EXAMPLE} -- with GATT DB") 720b2c76e9SMatthias Ringwald add_custom_command( 730b2c76e9SMatthias Ringwald OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 740b2c76e9SMatthias Ringwald COMMAND ${CMAKE_SOURCE_DIR}/../../tool/compile_gatt.py ${CMAKE_SOURCE_DIR}/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h > /dev/null 750b2c76e9SMatthias Ringwald ) 760b2c76e9SMatthias Ringwald add_executable(${EXAMPLE} ${EXAMPLE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h) 770b2c76e9SMatthias Ringwald else() 781d1c93c5SMatthias Ringwald message("example ${EXAMPLE}") 791d1c93c5SMatthias Ringwald add_executable(${EXAMPLE} ${EXAMPLE_FILE}) 800b2c76e9SMatthias Ringwald endif() 811d1c93c5SMatthias Ringwald target_link_libraries(${EXAMPLE} btstack) 821d1c93c5SMatthias Ringwaldendforeach(EXAMPLE_FILE) 8384242f88SMatthias Ringwald 84c589a9bbSMatthias Ringwald# pkgconfig required to link cpputest 85c589a9bbSMatthias Ringwaldfind_package(PkgConfig REQUIRED) 86c589a9bbSMatthias Ringwald 87c589a9bbSMatthias Ringwald# CppuTest 88c589a9bbSMatthias Ringwaldpkg_check_modules(CPPUTEST REQUIRED CppuTest) 89c589a9bbSMatthias Ringwaldinclude_directories(${CPPUTEST_INCLUDE_DIRS}) 90c589a9bbSMatthias Ringwaldlink_directories(${CPPUTEST_LIBRARY_DIRS}) 91c589a9bbSMatthias Ringwaldlink_libraries(${CPPUTEST_LIBRARIES}) 9284242f88SMatthias Ringwald 931e116f54SMatthias Ringwaldmessage("example mesh_message_test") 94c589a9bbSMatthias Ringwald 9584242f88SMatthias Ringwaldadd_executable(mesh_message_test 9684242f88SMatthias Ringwald../../src/mesh/mesh_foundation.c 9784242f88SMatthias Ringwald../../src/mesh/mesh_node.c 9884242f88SMatthias Ringwald../../src/mesh/mesh_iv_index_seq_number.c 9984242f88SMatthias Ringwald../../src/mesh/mesh_network.c 10084242f88SMatthias Ringwald../../src/mesh/mesh_peer.c 10184242f88SMatthias Ringwald../../src/mesh/mesh_lower_transport.c 10284242f88SMatthias Ringwald../../src/mesh/mesh_upper_transport.c 10384242f88SMatthias Ringwald../../src/mesh/mesh_virtual_addresses.c 10484242f88SMatthias Ringwald../../src/mesh/mesh_keys.c 10584242f88SMatthias Ringwald../../src/mesh/mesh_crypto.c 10684242f88SMatthias Ringwald../../src/btstack_memory.c 10784242f88SMatthias Ringwald../../src/btstack_memory_pool.c 10884242f88SMatthias Ringwald../../src/btstack_util.c 10984242f88SMatthias Ringwald../../src/btstack_crypto.c 11084242f88SMatthias Ringwald../../src/btstack_linked_list.c 11184242f88SMatthias Ringwald../../src/hci_dump.c 112d567aeb3SMatthias Ringwald../../platform/posix/hci_dump_posix_fs.c 11384242f88SMatthias Ringwald../../src/hci_cmd.c 11484242f88SMatthias Ringwald../../3rd-party/micro-ecc/uECC.c 1156fb99087SMatthias Ringwald../../3rd-party/rijndael/rijndael.c 11684242f88SMatthias Ringwaldmock.c 11784242f88SMatthias Ringwaldmesh_message_test.cpp 11884242f88SMatthias Ringwald) 11984242f88SMatthias Ringwald 1201e116f54SMatthias Ringwaldmessage("example provisioning_device_test") 1211e116f54SMatthias Ringwaldadd_executable(provisioning_device_test 1221e116f54SMatthias Ringwaldprovisioning_device_test.cpp 1231e116f54SMatthias Ringwaldmock.c 1241e116f54SMatthias Ringwald../../3rd-party/micro-ecc/uECC.c 1251e116f54SMatthias Ringwald../../3rd-party/rijndael/rijndael.c 1261e116f54SMatthias Ringwald../../src/mesh/mesh_crypto.c 1271e116f54SMatthias Ringwald../../src/mesh/provisioning_device.c 1281e116f54SMatthias Ringwald../../src/mesh/mesh_node.c 1291e116f54SMatthias Ringwald../../src/btstack_crypto.c 1301e116f54SMatthias Ringwald../../src/btstack_util.c 1311e116f54SMatthias Ringwald../../src/btstack_linked_list.c 1321e116f54SMatthias Ringwald../../src/hci_cmd.c 1331e116f54SMatthias Ringwald../../src/hci_dump.c 134d567aeb3SMatthias Ringwald../../platform/posix/hci_dump_posix_fs.c 1351e116f54SMatthias Ringwald) 13684242f88SMatthias Ringwald 1371e116f54SMatthias Ringwaldmessage("example provisioning_provisioner_test") 1381e116f54SMatthias Ringwaldadd_executable(provisioning_provisioner_test 1391e116f54SMatthias Ringwaldprovisioning_provisioner_test.cpp 1401e116f54SMatthias Ringwaldmock.c 1411e116f54SMatthias Ringwald../../3rd-party/micro-ecc/uECC.c 1421e116f54SMatthias Ringwald../../3rd-party/rijndael/rijndael.c 1431e116f54SMatthias Ringwald../../src/btstack_crypto.c 1441e116f54SMatthias Ringwald../../src/mesh/provisioning_provisioner.c 1451e116f54SMatthias Ringwald ../../src/mesh/mesh_crypto.c 1461e116f54SMatthias Ringwald../../src/btstack_crypto.c 1471e116f54SMatthias Ringwald../../src/btstack_util.c 1481e116f54SMatthias Ringwald../../src/btstack_linked_list.c 1491e116f54SMatthias Ringwald../../src/hci_cmd.c 1501e116f54SMatthias Ringwald../../src/hci_dump.c 151d567aeb3SMatthias Ringwald../../platform/posix/hci_dump_posix_fs.c 1521e116f54SMatthias Ringwald) 15384242f88SMatthias Ringwald 1541e116f54SMatthias Ringwaldmessage("example mesh_configuration_composition_data_message_test") 1551e116f54SMatthias Ringwaldadd_executable(mesh_configuration_composition_data_message_test 1561e116f54SMatthias Ringwaldmesh_configuration_composition_data_message_test.cpp 1571e116f54SMatthias Ringwald../../src/mesh/mesh_configuration_client.c 1581e116f54SMatthias Ringwald) 1591e116f54SMatthias Ringwaldtarget_link_libraries(mesh_configuration_composition_data_message_test btstack) 160