From ba04c1cf7678a8552f557c51b10558a13fa17b66 Mon Sep 17 00:00:00 2001 From: Rajkumar Kanagaraj Date: Wed, 7 Apr 2021 09:58:32 -0700 Subject: [PATCH] CMake: Add add_subdirectory of unittests - add every libraries unittest directory into respective CMake which allows to include unittest source into build based on MBED_BUILD_UNITTESTS flag --- connectivity/cellular/CMakeLists.txt | 4 ++++ connectivity/lorawan/CMakeLists.txt | 4 ++++ connectivity/netsocket/CMakeLists.txt | 4 ++++ drivers/CMakeLists.txt | 4 ++++ events/CMakeLists.txt | 4 ++++ platform/CMakeLists.txt | 4 ++++ storage/blockdevice/CMakeLists.txt | 4 ++++ storage/kvstore/filesystemstore/CMakeLists.txt | 4 ++++ storage/kvstore/tdbstore/CMakeLists.txt | 4 ++++ 9 files changed, 36 insertions(+) diff --git a/connectivity/cellular/CMakeLists.txt b/connectivity/cellular/CMakeLists.txt index 00b5d7a84a..8455c59b4c 100644 --- a/connectivity/cellular/CMakeLists.txt +++ b/connectivity/cellular/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +if(NOT ${CMAKE_CROSSCOMPILING}) + add_subdirectory(tests/UNITTESTS) +endif() + add_subdirectory(source/framework) target_include_directories(mbed-cellular diff --git a/connectivity/lorawan/CMakeLists.txt b/connectivity/lorawan/CMakeLists.txt index 743a0ff9ae..552a72a6fe 100644 --- a/connectivity/lorawan/CMakeLists.txt +++ b/connectivity/lorawan/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +if(NOT ${CMAKE_CROSSCOMPILING}) + add_subdirectory(tests/UNITTESTS) +endif() + add_subdirectory(lorastack) add_subdirectory(system) diff --git a/connectivity/netsocket/CMakeLists.txt b/connectivity/netsocket/CMakeLists.txt index f99ae1dbaa..0ce8a2f466 100644 --- a/connectivity/netsocket/CMakeLists.txt +++ b/connectivity/netsocket/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +if(NOT ${CMAKE_CROSSCOMPILING}) + add_subdirectory(tests/UNITTESTS) +endif() + # TODO CMake: Perhaps move this/these file(s) into connectivity/drivers/cellular target_sources(mbed-cellular INTERFACE diff --git a/drivers/CMakeLists.txt b/drivers/CMakeLists.txt index 83bb222309..4d26ac6dec 100644 --- a/drivers/CMakeLists.txt +++ b/drivers/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +if(NOT ${CMAKE_CROSSCOMPILING}) + add_subdirectory(tests/UNITTESTS) +endif() + target_include_directories(mbed-core INTERFACE . diff --git a/events/CMakeLists.txt b/events/CMakeLists.txt index 591b01259a..061c23c43c 100644 --- a/events/CMakeLists.txt +++ b/events/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +if(NOT ${CMAKE_CROSSCOMPILING}) + add_subdirectory(tests/UNITTESTS) +endif() + add_library(mbed-events INTERFACE) target_include_directories(mbed-events diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt index c68f815223..b79a4a28cb 100644 --- a/platform/CMakeLists.txt +++ b/platform/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +if(NOT ${CMAKE_CROSSCOMPILING}) + add_subdirectory(tests/UNITTESTS) +endif() + # List of all optional platform libraries available. add_library(mbed-psa INTERFACE) diff --git a/storage/blockdevice/CMakeLists.txt b/storage/blockdevice/CMakeLists.txt index 6181735cd3..cbbb76f0aa 100644 --- a/storage/blockdevice/CMakeLists.txt +++ b/storage/blockdevice/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +if(NOT ${CMAKE_CROSSCOMPILING}) + add_subdirectory(tests/UNITTESTS) +endif() + if("DATAFLASH" IN_LIST MBED_TARGET_LABELS) add_subdirectory(COMPONENT_DATAFLASH) endif() diff --git a/storage/kvstore/filesystemstore/CMakeLists.txt b/storage/kvstore/filesystemstore/CMakeLists.txt index 116a5abf2a..aeb8aef191 100644 --- a/storage/kvstore/filesystemstore/CMakeLists.txt +++ b/storage/kvstore/filesystemstore/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +if(NOT ${CMAKE_CROSSCOMPILING}) + add_subdirectory(tests/UNITTESTS) +endif() + target_include_directories(mbed-storage-filesystemstore INTERFACE . diff --git a/storage/kvstore/tdbstore/CMakeLists.txt b/storage/kvstore/tdbstore/CMakeLists.txt index 38a992a488..a1cb048ad9 100644 --- a/storage/kvstore/tdbstore/CMakeLists.txt +++ b/storage/kvstore/tdbstore/CMakeLists.txt @@ -1,6 +1,10 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 +if(NOT ${CMAKE_CROSSCOMPILING}) + add_subdirectory(tests/UNITTESTS) +endif() + target_include_directories(mbed-storage-tdbstore INTERFACE .