Imre Kis | 2be8593 | 2021-11-12 17:07:17 +0100 | [diff] [blame^] | 1 | #------------------------------------------------------------------------------- |
| 2 | # Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | #------------------------------------------------------------------------------- |
| 7 | cmake_minimum_required(VERSION 3.16) |
| 8 | include(../../deployment.cmake REQUIRED) |
| 9 | |
| 10 | project(smm-gateway-unit-tests LANGUAGES CXX C) |
| 11 | |
| 12 | # Preparing firmware-test-build by including it |
| 13 | include(${TS_ROOT}/external/firmware_test_builder/FirmwareTestBuilder.cmake) |
| 14 | |
| 15 | include(CTest) |
| 16 | include(UnitTest) |
| 17 | |
| 18 | set(COVERAGE FALSE CACHE BOOL "Enable code coverage measurement") |
| 19 | set(UNIT_TEST_PROJECT_PATH ${TS_ROOT} CACHE PATH "Path of the project directory") |
| 20 | set(CMAKE_CXX_STANDARD 11) |
| 21 | |
| 22 | unit_test_init_cpputest() |
| 23 | |
| 24 | if (COVERAGE) |
| 25 | include(Coverage) |
| 26 | |
| 27 | set(COVERAGE_FILE "coverage.info") |
| 28 | set(SMM_GATEWAY_COVERAGE_FILE "smm-gateway-coverage.info" CACHE PATH "Path of coverage info file") |
| 29 | set(SMM_GATEWAY_COVERAGE_REPORT_DIR "${CMAKE_CURRENT_BINARY_DIR}/smm-gateway-coverage-report" CACHE PATH "Directory of coverage report") |
| 30 | |
| 31 | # Collecting coverage |
| 32 | coverage_generate( |
| 33 | NAME "smm-gateway unit test" |
| 34 | SOURCE_DIR ${TS_ROOT} |
| 35 | BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} |
| 36 | OUTPUT_FILE ${COVERAGE_FILE} |
| 37 | ) |
| 38 | |
| 39 | # Filtering project file coverage |
| 40 | coverage_filter( |
| 41 | INPUT_FILE ${COVERAGE_FILE} |
| 42 | OUTPUT_FILE ${SMM_GATEWAY_COVERAGE_FILE} |
| 43 | INCLUDE_DIRECTORY ${UNIT_TEST_PROJECT_PATH}/components |
| 44 | ) |
| 45 | |
| 46 | # Coverage report |
| 47 | coverage_generate_report( |
| 48 | INPUT_FILE ${SMM_GATEWAY_COVERAGE_FILE} |
| 49 | OUTPUT_DIRECTORY ${SMM_GATEWAY_COVERAGE_REPORT_DIR} |
| 50 | ) |
| 51 | endif() |