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 141d1c93c5SMatthias Ringwald# add libusb 151d1c93c5SMatthias Ringwaldfind_path(LIBUSB_INCLUDE_DIR NAMES libusb.h PATH_SUFFIXES "include" "libusb" "libusb-1.0") 161d1c93c5SMatthias Ringwaldfind_library(LIBUSB_LIBRARY NAMES usb-1.0 PATH_SUFFIXES "lib" "lib32" "lib64" "dylib") 171d1c93c5SMatthias Ringwaldget_filename_component(LIBUSB_LIBRARY_PATH ${LIBUSB_LIBRARY} DIRECTORY) 181d1c93c5SMatthias Ringwaldinclude_directories( ${LIBUSB_INCLUDE_DIR} ) 191d1c93c5SMatthias Ringwaldlink_directories( ${LIBUSB_LIBRARY_PATH} ) 201d1c93c5SMatthias Ringwaldlink_libraries( usb-1.0 ) 211d1c93c5SMatthias Ringwald 221d1c93c5SMatthias Ringwaldinclude_directories(../../3rd-party/micro-ecc) 231d1c93c5SMatthias Ringwaldinclude_directories(../../3rd-party/tinydir) 241d1c93c5SMatthias Ringwaldinclude_directories(../../src) 251d1c93c5SMatthias Ringwaldinclude_directories(../../platform/posix) 266fb99087SMatthias Ringwaldinclude_directories(../../3rd-party/rijndael) 271d1c93c5SMatthias Ringwaldinclude_directories(.) 281d1c93c5SMatthias Ringwald 29d935ec81SMatthias Ringwaldfile(GLOB SOURCES_SRC "../../src/*.c" "../../src/*.h" "../../example/sco_demo_util.c" "../../example/sco_demo_util.h") 30d935ec81SMatthias Ringwaldfile(GLOB SOURCES_BLE "../../src/ble/*.c" "../../src/ble/*.h") 31d935ec81SMatthias Ringwaldfile(GLOB SOURCES_GATT "../../src/ble/gatt-service/*.c" "../../src/ble/gatt-service/*.h") 3277ba3d3fSMatthias Ringwaldfile(GLOB SOURCES_MESH "../../src/mesh/*.c" "../../src/mesh/*.h" ) 33d935ec81SMatthias Ringwaldfile(GLOB SOURCES_UECC "../../3rd-party/micro-ecc/uECC.c" "../../3rd-party/micro-ecc/uECC.h") 34d935ec81SMatthias Ringwaldfile(GLOB SOURCES_POSIX "../../platform/posix/*.c" "../../platform/posix/*.h") 35d935ec81SMatthias Ringwaldfile(GLOB SOURCES_LIBUSB "../../platform/libusb/*.c" "../../platform/libusb/*.h") 361d1c93c5SMatthias Ringwald 37d935ec81SMatthias Ringwald 38d935ec81SMatthias 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") 391d1c93c5SMatthias Ringwaldlist(REMOVE_ITEM SOURCES_BLE ${SOURCES_OFF}) 401d1c93c5SMatthias Ringwald 41a5a7b6daSMatthias Ringwaldset(SOURCES_MESH_NEW main.c) 421d1c93c5SMatthias Ringwald 431d1c93c5SMatthias Ringwaldset(SOURCES 441d1c93c5SMatthias Ringwald ${SOURCES_POSIX} 451d1c93c5SMatthias Ringwald ${SOURCES_LIBUSB} 461d1c93c5SMatthias Ringwald ${SOURCES_SRC} 471d1c93c5SMatthias Ringwald ${SOURCES_BLE} 481d1c93c5SMatthias Ringwald ${SOURCES_MESH} 491d1c93c5SMatthias Ringwald ${SOURCES_MESH_NEW} 501d1c93c5SMatthias Ringwald ${SOURCES_GATT} 511d1c93c5SMatthias Ringwald ${SOURCES_UECC} 521d1c93c5SMatthias Ringwald) 531d1c93c5SMatthias Ringwaldlist(SORT SOURCES) 541d1c93c5SMatthias Ringwald 551d1c93c5SMatthias Ringwald# create static lib 561d1c93c5SMatthias Ringwaldadd_library(btstack STATIC ${SOURCES}) 571d1c93c5SMatthias Ringwald 581d1c93c5SMatthias Ringwald# list of targets 59a5a7b6daSMatthias Ringwaldset(EXAMPLES_C mesh_pts.c) 600b2c76e9SMatthias Ringwald 610b2c76e9SMatthias Ringwaldfile(GLOB EXAMPLES_GATT "*.gatt") 621d1c93c5SMatthias Ringwald 631d1c93c5SMatthias Ringwald# create targets 640b2c76e9SMatthias Ringwaldforeach(EXAMPLE_FILE ${EXAMPLES_C}) 651d1c93c5SMatthias Ringwald get_filename_component(EXAMPLE ${EXAMPLE_FILE} NAME_WE) 660b2c76e9SMatthias Ringwald if ( "${EXAMPLES_GATT}" MATCHES ${EXAMPLE} ) 670b2c76e9SMatthias Ringwald message("example ${EXAMPLE} -- with GATT DB") 680b2c76e9SMatthias Ringwald add_custom_command( 690b2c76e9SMatthias Ringwald OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h 700b2c76e9SMatthias Ringwald COMMAND ${CMAKE_SOURCE_DIR}/../../tool/compile_gatt.py ${CMAKE_SOURCE_DIR}/${EXAMPLE}.gatt ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h > /dev/null 710b2c76e9SMatthias Ringwald ) 720b2c76e9SMatthias Ringwald add_executable(${EXAMPLE} ${EXAMPLE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${EXAMPLE}.h) 730b2c76e9SMatthias Ringwald else() 741d1c93c5SMatthias Ringwald message("example ${EXAMPLE}") 751d1c93c5SMatthias Ringwald add_executable(${EXAMPLE} ${EXAMPLE_FILE}) 760b2c76e9SMatthias Ringwald endif() 771d1c93c5SMatthias Ringwald target_link_libraries(${EXAMPLE} btstack) 781d1c93c5SMatthias Ringwaldendforeach(EXAMPLE_FILE) 7984242f88SMatthias Ringwald 80*1e116f54SMatthias Ringwald## hard-coded tests that use CPPUtest 8184242f88SMatthias Ringwald 82*1e116f54SMatthias Ringwaldmessage("example mesh_message_test") 8384242f88SMatthias Ringwaldinclude_directories( /usr/local/include) 8484242f88SMatthias Ringwaldlink_directories( /usr/local/lib) 8584242f88SMatthias Ringwaldlink_libraries(CppUTest CppUTestExt) 8684242f88SMatthias Ringwaldadd_executable(mesh_message_test 8784242f88SMatthias Ringwald../../src/mesh/mesh_foundation.c 8884242f88SMatthias Ringwald../../src/mesh/mesh_node.c 8984242f88SMatthias Ringwald../../src/mesh/mesh_iv_index_seq_number.c 9084242f88SMatthias Ringwald../../src/mesh/mesh_network.c 9184242f88SMatthias Ringwald../../src/mesh/mesh_peer.c 9284242f88SMatthias Ringwald../../src/mesh/mesh_lower_transport.c 9384242f88SMatthias Ringwald../../src/mesh/mesh_upper_transport.c 9484242f88SMatthias Ringwald../../src/mesh/mesh_virtual_addresses.c 9584242f88SMatthias Ringwald../../src/mesh/mesh_keys.c 9684242f88SMatthias Ringwald../../src/mesh/mesh_crypto.c 9784242f88SMatthias Ringwald../../src/btstack_memory.c 9884242f88SMatthias Ringwald../../src/btstack_memory_pool.c 9984242f88SMatthias Ringwald../../src/btstack_util.c 10084242f88SMatthias Ringwald../../src/btstack_crypto.c 10184242f88SMatthias Ringwald../../src/btstack_linked_list.c 10284242f88SMatthias Ringwald../../src/hci_dump.c 10384242f88SMatthias Ringwald../../src/hci_cmd.c 10484242f88SMatthias Ringwald../../3rd-party/micro-ecc/uECC.c 1056fb99087SMatthias Ringwald../../3rd-party/rijndael/rijndael.c 10684242f88SMatthias Ringwaldmock.c 10784242f88SMatthias Ringwaldmesh_message_test.cpp 10884242f88SMatthias Ringwald) 10984242f88SMatthias Ringwald 110*1e116f54SMatthias Ringwaldmessage("example provisioning_device_test") 111*1e116f54SMatthias Ringwaldadd_executable(provisioning_device_test 112*1e116f54SMatthias Ringwaldprovisioning_device_test.cpp 113*1e116f54SMatthias Ringwaldmock.c 114*1e116f54SMatthias Ringwald../../3rd-party/micro-ecc/uECC.c 115*1e116f54SMatthias Ringwald../../3rd-party/rijndael/rijndael.c 116*1e116f54SMatthias Ringwald../../src/mesh/mesh_crypto.c 117*1e116f54SMatthias Ringwald../../src/mesh/provisioning_device.c 118*1e116f54SMatthias Ringwald../../src/mesh/mesh_node.c 119*1e116f54SMatthias Ringwald../../src/btstack_crypto.c 120*1e116f54SMatthias Ringwald../../src/btstack_util.c 121*1e116f54SMatthias Ringwald../../src/btstack_linked_list.c 122*1e116f54SMatthias Ringwald../../src/hci_cmd.c 123*1e116f54SMatthias Ringwald../../src/hci_dump.c 124*1e116f54SMatthias Ringwald) 12584242f88SMatthias Ringwald 126*1e116f54SMatthias Ringwaldmessage("example provisioning_provisioner_test") 127*1e116f54SMatthias Ringwaldadd_executable(provisioning_provisioner_test 128*1e116f54SMatthias Ringwaldprovisioning_provisioner_test.cpp 129*1e116f54SMatthias Ringwaldmock.c 130*1e116f54SMatthias Ringwald../../3rd-party/micro-ecc/uECC.c 131*1e116f54SMatthias Ringwald../../3rd-party/rijndael/rijndael.c 132*1e116f54SMatthias Ringwald../../src/btstack_crypto.c 133*1e116f54SMatthias Ringwald../../src/mesh/provisioning_provisioner.c 134*1e116f54SMatthias Ringwald ../../src/mesh/mesh_crypto.c 135*1e116f54SMatthias Ringwald../../src/btstack_crypto.c 136*1e116f54SMatthias Ringwald../../src/btstack_util.c 137*1e116f54SMatthias Ringwald../../src/btstack_linked_list.c 138*1e116f54SMatthias Ringwald../../src/hci_cmd.c 139*1e116f54SMatthias Ringwald../../src/hci_dump.c 140*1e116f54SMatthias Ringwald) 14184242f88SMatthias Ringwald 142*1e116f54SMatthias Ringwaldmessage("example mesh_configuration_composition_data_message_test") 143*1e116f54SMatthias Ringwaldadd_executable(mesh_configuration_composition_data_message_test 144*1e116f54SMatthias Ringwaldmesh_configuration_composition_data_message_test.cpp 145*1e116f54SMatthias Ringwald../../src/mesh/mesh_configuration_client.c 146*1e116f54SMatthias Ringwald) 147*1e116f54SMatthias Ringwaldtarget_link_libraries(mesh_configuration_composition_data_message_test btstack) 148