|
| 1 | +########################################################################## |
| 2 | + |
| 3 | +set(CMAKE_VERBOSE_MAKEFILE ON) |
| 4 | +cmake_minimum_required(VERSION 2.8) |
| 5 | + |
| 6 | +########################################################################## |
| 7 | + |
| 8 | +project(testArduinoBLE) |
| 9 | + |
| 10 | +########################################################################## |
| 11 | + |
| 12 | +set(CMAKE_CXX_STANDARD 11) |
| 13 | +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
| 14 | + |
| 15 | +########################################################################## |
| 16 | + |
| 17 | +set(COMMON_TEST_SRCS |
| 18 | + src/test_main.cpp |
| 19 | + src/Arduino.cpp |
| 20 | + src/util/itoa.c |
| 21 | + src/util/TestUtil.cpp |
| 22 | + src/util/String.cpp |
| 23 | + src/util/Common.cpp |
| 24 | +) |
| 25 | + |
| 26 | +set(DUT_SRCS |
| 27 | + ../../src/utility/BLEUuid.cpp |
| 28 | + ../../src/BLEDevice.cpp |
| 29 | + ../../src/BLECharacteristic.cpp |
| 30 | + ../../src/BLEDescriptor.cpp |
| 31 | + ../../src/BLEService.cpp |
| 32 | + ../../src/BLEAdvertisingData.cpp |
| 33 | + ../../src/utility/ATT.cpp |
| 34 | + ../../src/utility/GAP.cpp |
| 35 | + ../../src/utility/HCI.cpp |
| 36 | + ../../src/utility/GATT.cpp |
| 37 | + ../../src/utility/L2CAPSignaling.cpp |
| 38 | + ../../src/local/BLELocalAttribute.cpp |
| 39 | + ../../src/local/BLELocalCharacteristic.cpp |
| 40 | + ../../src/local/BLELocalDescriptor.cpp |
| 41 | + ../../src/local/BLELocalDevice.cpp |
| 42 | + ../../src/local/BLELocalService.cpp |
| 43 | + ../../src/remote/BLERemoteAttribute.cpp |
| 44 | + ../../src/remote/BLERemoteCharacteristic.cpp |
| 45 | + ../../src/remote/BLERemoteDescriptor.cpp |
| 46 | + ../../src/remote/BLERemoteDevice.cpp |
| 47 | + ../../src/remote/BLERemoteService.cpp |
| 48 | + ../../src/BLEStringCharacteristic.cpp |
| 49 | + ../../src/BLETypedCharacteristics.cpp |
| 50 | +) |
| 51 | + |
| 52 | +set(TEST_TARGET_UUID_SRCS |
| 53 | + # Test files |
| 54 | + ${COMMON_TEST_SRCS} |
| 55 | + src/test_uuid/test_uuid.cpp |
| 56 | + # DUT files |
| 57 | + #${DUT_SRCS} |
| 58 | + ../../src/utility/BLEUuid.cpp |
| 59 | +) |
| 60 | + |
| 61 | +set(TEST_TARGET_DISC_DEVICE_SRCS |
| 62 | + # Test files |
| 63 | + ${COMMON_TEST_SRCS} |
| 64 | + src/test_discovered_device/test_discovered_device.cpp |
| 65 | + # DUT files |
| 66 | + ${DUT_SRCS} |
| 67 | + # Fake classes files |
| 68 | + src/util/HCIFakeTransport.cpp |
| 69 | + src/test_discovered_device/FakeGAP.cpp |
| 70 | +) |
| 71 | + |
| 72 | +set(TEST_TARGET_ADVERTISING_DATA_SRCS |
| 73 | + # Test files |
| 74 | + ${COMMON_TEST_SRCS} |
| 75 | + src/test_advertising_data/test_advertising_data.cpp |
| 76 | + src/test_advertising_data/test_service.cpp |
| 77 | + src/test_advertising_data/test_local_name.cpp |
| 78 | + src/test_advertising_data/test_manufacturer.cpp |
| 79 | + # DUT files |
| 80 | + ${DUT_SRCS} |
| 81 | + # Fake classes files |
| 82 | + src/util/HCIFakeTransport.cpp |
| 83 | + src/test_advertising_data/FakeBLELocalDevice.cpp |
| 84 | +) |
| 85 | + |
| 86 | +########################################################################## |
| 87 | + |
| 88 | +set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "--coverage") |
| 89 | +set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "--coverage") |
| 90 | + |
| 91 | +########################################################################## |
| 92 | + |
| 93 | +add_executable(TEST_TARGET_UUID ${TEST_TARGET_UUID_SRCS}) |
| 94 | +add_executable(TEST_TARGET_DISC_DEVICE ${TEST_TARGET_DISC_DEVICE_SRCS}) |
| 95 | +add_executable(TEST_TARGET_ADVERTISING_DATA ${TEST_TARGET_ADVERTISING_DATA_SRCS}) |
| 96 | + |
| 97 | +########################################################################## |
| 98 | + |
| 99 | +include_directories(include) |
| 100 | +include_directories(include/util) |
| 101 | +include_directories(../../src) |
| 102 | +include_directories(../../src/local) |
| 103 | +include_directories(../../src/remote) |
| 104 | +include_directories(../../src/utility) |
| 105 | +include_directories(external/catch/v2.12.1/include) |
| 106 | + |
| 107 | +target_include_directories(TEST_TARGET_DISC_DEVICE PUBLIC include/test_discovered_device) |
| 108 | +target_include_directories(TEST_TARGET_ADVERTISING_DATA PUBLIC include/test_advertising_data) |
| 109 | + |
| 110 | +########################################################################## |
| 111 | + |
| 112 | +target_compile_definitions(TEST_TARGET_DISC_DEVICE PUBLIC FAKE_GAP) |
| 113 | +target_compile_definitions(TEST_TARGET_ADVERTISING_DATA PUBLIC FAKE_BLELOCALDEVICE) |
| 114 | + |
| 115 | +########################################################################## |
| 116 | + |
| 117 | +# Build unit tests as a post build step |
| 118 | +add_custom_command(TARGET TEST_TARGET_UUID POST_BUILD |
| 119 | + COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/TEST_TARGET_UUID |
| 120 | +) |
| 121 | +add_custom_command(TARGET TEST_TARGET_DISC_DEVICE POST_BUILD |
| 122 | + COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/TEST_TARGET_DISC_DEVICE |
| 123 | +) |
| 124 | +add_custom_command(TARGET TEST_TARGET_ADVERTISING_DATA POST_BUILD |
| 125 | + COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/TEST_TARGET_ADVERTISING_DATA |
| 126 | +) |
0 commit comments