diff --git a/CMakeLists.txt b/CMakeLists.txt index e91ccf6..afb153a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR) +option(BUILD_GREENTEA_TESTS "Build greentea tests only." OFF) + if(${CMAKE_CROSSCOMPILING}) include(${MBED_CONFIG_PATH}/mbed_config.cmake) include(mbed_set_linker_script) @@ -19,12 +21,14 @@ add_subdirectory(extern) -option(BUILD_TESTING "Run unit tests only." OFF) - -if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) include(CTest) - add_definitions(-DUNITTEST) - add_subdirectory(UNITTESTS) + + if((NOT BUILD_GREENTEA_TESTS) AND BUILD_TESTING) + # Building unit tests only. + add_definitions(-DUNITTEST) + add_subdirectory(UNITTESTS) + endif() endif() add_library(mbed-core INTERFACE) @@ -94,10 +98,12 @@ # Add MBED_TEST_MODE for backward compatibility with Greentea tests written for use with Mbed CLI 1 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - target_compile_definitions(${PROJECT_NAME} - INTERFACE - MBED_TEST_MODE - ) + if(NOT BUILD_GREENTEA_TESTS) + target_compile_definitions(${PROJECT_NAME} + INTERFACE + MBED_TEST_MODE + ) + endif() endif() # We need to generate a "response file" to pass to the C preprocessor when we preprocess the linker diff --git a/connectivity/cellular/CMakeLists.txt b/connectivity/cellular/CMakeLists.txt index d7ce11f..1c87aed 100644 --- a/connectivity/cellular/CMakeLists.txt +++ b/connectivity/cellular/CMakeLists.txt @@ -2,7 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(BUILD_GREENTEA_TESTS) + # add greentea test + else() + add_subdirectory(tests/UNITTESTS) + endif() endif() add_subdirectory(source/framework) diff --git a/connectivity/lorawan/CMakeLists.txt b/connectivity/lorawan/CMakeLists.txt index 941b01e..d30bdac 100644 --- a/connectivity/lorawan/CMakeLists.txt +++ b/connectivity/lorawan/CMakeLists.txt @@ -2,7 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(BUILD_GREENTEA_TESTS) + # add greentea test + else() + add_subdirectory(tests/UNITTESTS) + endif() endif() add_subdirectory(lorastack) diff --git a/connectivity/netsocket/CMakeLists.txt b/connectivity/netsocket/CMakeLists.txt index 62bea8c..9760c60 100644 --- a/connectivity/netsocket/CMakeLists.txt +++ b/connectivity/netsocket/CMakeLists.txt @@ -2,7 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(BUILD_GREENTEA_TESTS) + # add greentea test + else() + add_subdirectory(tests/UNITTESTS) + endif() endif() # TODO CMake: Perhaps move this/these file(s) into connectivity/drivers/cellular diff --git a/drivers/CMakeLists.txt b/drivers/CMakeLists.txt index 9079d3d..ad62808 100644 --- a/drivers/CMakeLists.txt +++ b/drivers/CMakeLists.txt @@ -2,7 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(BUILD_GREENTEA_TESTS) + # add greentea test + else() + add_subdirectory(tests/UNITTESTS) + endif() endif() target_include_directories(mbed-core diff --git a/events/CMakeLists.txt b/events/CMakeLists.txt index da4d693..6e7a6c6 100644 --- a/events/CMakeLists.txt +++ b/events/CMakeLists.txt @@ -2,8 +2,12 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) -else() + if(BUILD_GREENTEA_TESTS) + # add greentea test + else() + add_subdirectory(tests/UNITTESTS) + endif() +endif() add_library(mbed-events INTERFACE) @@ -28,4 +32,3 @@ INTERFACE MBED_CONF_EVENTS_PRESENT=1 ) -endif() diff --git a/hal/CMakeLists.txt b/hal/CMakeLists.txt index 87f88be..3af169e 100644 --- a/hal/CMakeLists.txt +++ b/hal/CMakeLists.txt @@ -2,7 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(BUILD_GREENTEA_TESTS) + # add greentea test + else() + add_subdirectory(tests/UNITTESTS) + endif() endif() add_subdirectory(TARGET_FLASH_CMSIS_ALGO EXCLUDE_FROM_ALL) diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt index df83719..4be5414 100644 --- a/platform/CMakeLists.txt +++ b/platform/CMakeLists.txt @@ -2,7 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(BUILD_GREENTEA_TESTS) + # add greentea test + else() + add_subdirectory(tests/UNITTESTS) + endif() endif() # List of all optional platform libraries available. diff --git a/rtos/CMakeLists.txt b/rtos/CMakeLists.txt index ab9d308..8af23d8 100644 --- a/rtos/CMakeLists.txt +++ b/rtos/CMakeLists.txt @@ -2,7 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(BUILD_GREENTEA_TESTS) + # add greentea test + else() + add_subdirectory(tests/UNITTESTS) + endif() endif() target_include_directories(mbed-core diff --git a/storage/blockdevice/CMakeLists.txt b/storage/blockdevice/CMakeLists.txt index 9f847d4..6b03244 100644 --- a/storage/blockdevice/CMakeLists.txt +++ b/storage/blockdevice/CMakeLists.txt @@ -2,7 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(BUILD_GREENTEA_TESTS) + # add greentea test + else() + add_subdirectory(tests/UNITTESTS) + endif() endif() if("DATAFLASH" IN_LIST MBED_TARGET_LABELS) diff --git a/storage/filesystem/CMakeLists.txt b/storage/filesystem/CMakeLists.txt index cacd423..5d6fca3 100644 --- a/storage/filesystem/CMakeLists.txt +++ b/storage/filesystem/CMakeLists.txt @@ -2,7 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(BUILD_GREENTEA_TESTS) + # add greentea test + else() + add_subdirectory(tests/UNITTESTS) + endif() endif() add_subdirectory(fat) diff --git a/storage/kvstore/CMakeLists.txt b/storage/kvstore/CMakeLists.txt index 3f9f137..1d0feee 100644 --- a/storage/kvstore/CMakeLists.txt +++ b/storage/kvstore/CMakeLists.txt @@ -2,7 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(BUILD_GREENTEA_TESTS) + # add greentea test + else() + add_subdirectory(tests/UNITTESTS) + endif() endif() add_subdirectory(tdbstore) diff --git a/storage/kvstore/filesystemstore/CMakeLists.txt b/storage/kvstore/filesystemstore/CMakeLists.txt index 7289fe8..49b2d34 100644 --- a/storage/kvstore/filesystemstore/CMakeLists.txt +++ b/storage/kvstore/filesystemstore/CMakeLists.txt @@ -2,7 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(BUILD_GREENTEA_TESTS) + # add greentea test + else() + add_subdirectory(tests/UNITTESTS) + endif() endif() target_include_directories(mbed-storage-filesystemstore diff --git a/storage/kvstore/tdbstore/CMakeLists.txt b/storage/kvstore/tdbstore/CMakeLists.txt index d4f8d92..82cd283 100644 --- a/storage/kvstore/tdbstore/CMakeLists.txt +++ b/storage/kvstore/tdbstore/CMakeLists.txt @@ -2,7 +2,11 @@ # SPDX-License-Identifier: Apache-2.0 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) - add_subdirectory(tests/UNITTESTS) + if(BUILD_GREENTEA_TESTS) + # add greentea test + else() + add_subdirectory(tests/UNITTESTS) + endif() endif() target_include_directories(mbed-storage-tdbstore