From db8852c5d8f203848317f53f82037be3cf267479 Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Thu, 16 Sep 2021 16:37:32 +0100 Subject: [PATCH] CMake: connectivity: Guard unit test directories When unit tests or unit test stubs get added as CMake targets, they becomes part of the "all" target and get compiled when building the whole project. When building greentea tests we need to disable unit tests and stubs to avoid unnecessary compilation and errors. --- connectivity/FEATURE_BLE/CMakeLists.txt | 4 +++- connectivity/libraries/CMakeLists.txt | 4 +++- connectivity/mbedtls/CMakeLists.txt | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/connectivity/FEATURE_BLE/CMakeLists.txt b/connectivity/FEATURE_BLE/CMakeLists.txt index 1e9da9185a..fbd35db9af 100644 --- a/connectivity/FEATURE_BLE/CMakeLists.txt +++ b/connectivity/FEATURE_BLE/CMakeLists.txt @@ -2,7 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(NOT BUILD_GREENTEA_TESTS) + add_subdirectory(tests/UNITTESTS) + endif() endif() add_subdirectory(libraries) diff --git a/connectivity/libraries/CMakeLists.txt b/connectivity/libraries/CMakeLists.txt index 7d856fa25c..21af84b317 100644 --- a/connectivity/libraries/CMakeLists.txt +++ b/connectivity/libraries/CMakeLists.txt @@ -2,7 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(NOT BUILD_GREENTEA_TESTS) + add_subdirectory(tests/UNITTESTS) + endif() endif() add_subdirectory(mbed-coap) diff --git a/connectivity/mbedtls/CMakeLists.txt b/connectivity/mbedtls/CMakeLists.txt index f000967e33..7bacaa6d97 100644 --- a/connectivity/mbedtls/CMakeLists.txt +++ b/connectivity/mbedtls/CMakeLists.txt @@ -2,7 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(NOT BUILD_GREENTEA_TESTS) + add_subdirectory(tests/UNITTESTS) + endif() endif() target_include_directories(mbed-mbedtls