diff --git a/CMakeLists.txt b/CMakeLists.txt index f85615fc9cb..3b96df785c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,8 @@ list(APPEND CMAKE_MODULE_PATH "${mbed-os_SOURCE_DIR}/platform/FEATURE_EXPERIMENTAL_API/FEATURE_PSA/TARGET_TFM/TARGET_TFM_LATEST/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_Cypress/scripts;${mbed-os_SOURCE_DIR}/targets/TARGET_NXP/scripts" ) +add_subdirectory(extern) + option(BUILD_TESTING "Run unit tests only." OFF) if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) @@ -92,7 +94,7 @@ if(${CMAKE_CROSSCOMPILING}) # 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} - PUBLIC + INTERFACE MBED_TEST_MODE ) endif() diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt new file mode 100644 index 00000000000..8441653ab3a --- /dev/null +++ b/extern/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (c) 2021 ARM Limited. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +include(FetchContent) + +FetchContent_Declare( + greentea-client + GIT_REPOSITORY https://github.com/ARMmbed/greentea-client.git + GIT_TAG 472aad2327fbfde827852fc44775904706847a3a +) + +FetchContent_MakeAvailable(greentea-client) diff --git a/extern/README.md b/extern/README.md new file mode 100644 index 00000000000..21bd1552cef --- /dev/null +++ b/extern/README.md @@ -0,0 +1,4 @@ +# Mbed OS External Dependencies + +This directory contains external dependencies, often fetched with CMake's +FetchContent(). diff --git a/features/CMakeLists.txt b/features/CMakeLists.txt index f02bf73ebfd..8109c714991 100644 --- a/features/CMakeLists.txt +++ b/features/CMakeLists.txt @@ -4,10 +4,10 @@ # List of all features libraries available. add_library(mbed-fpga-ci-test-shield INTERFACE) add_library(mbed-client-cli INTERFACE) -add_library(mbed-greentea INTERFACE) +add_library(mbed-unity INTERFACE) +add_library(mbed-utest INTERFACE) add_subdirectory(frameworks/COMPONENT_FPGA_CI_TEST_SHIELD) add_subdirectory(frameworks/mbed-client-cli) -add_subdirectory(frameworks/greentea-client) add_subdirectory(frameworks/unity) add_subdirectory(frameworks/utest) diff --git a/features/frameworks/greentea-client/README.md b/features/frameworks/greentea-client/README.md index e77b21a7bfa..d67e41ac38f 100644 --- a/features/frameworks/greentea-client/README.md +++ b/features/frameworks/greentea-client/README.md @@ -9,6 +9,10 @@ # greentea-client +*Note*: This copy of greentea-client is used only with Mbed CLI 1. Mbed CLI 2 +will use the standalone greentea-client, automatically fetched by CMake [in the +`extern/` directory](../../../extern/README.md). + `greentea-client` is a client library for [the Greentea test tool](https://github.com/ARMmbed/mbed-os-tools/tree/master/packages/mbed-greentea) when used in an [Mbed OS](https://os.mbed.com/) project. This package implements the client side of the key-value protocol used for communication between the device under test (DUT) and the host. The `Greentea` tool implements the protocol's host behavior. We use [utest](https://github.com/ARMmbed/mbed-os/blob/master/features/frameworks/utest/README.md) as our test harness. diff --git a/features/frameworks/unity/CMakeLists.txt b/features/frameworks/unity/CMakeLists.txt index 3bc86c72695..96974259d2e 100644 --- a/features/frameworks/unity/CMakeLists.txt +++ b/features/frameworks/unity/CMakeLists.txt @@ -1,13 +1,13 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -target_include_directories(mbed-greentea +target_include_directories(mbed-unity INTERFACE . unity ) -target_sources(mbed-greentea +target_sources(mbed-unity INTERFACE source/unity.c ) diff --git a/features/frameworks/utest/CMakeLists.txt b/features/frameworks/utest/CMakeLists.txt index a17a2dadfd1..6af46a763dd 100644 --- a/features/frameworks/utest/CMakeLists.txt +++ b/features/frameworks/utest/CMakeLists.txt @@ -1,13 +1,13 @@ # Copyright (c) 2020 ARM Limited. All rights reserved. # SPDX-License-Identifier: Apache-2.0 -target_include_directories(mbed-greentea +target_include_directories(mbed-utest INTERFACE . utest ) -target_sources(mbed-greentea +target_sources(mbed-utest INTERFACE mbed-utest-shim.cpp source/unity_handler.cpp diff --git a/tools/cmake/mbed_greentea.cmake b/tools/cmake/mbed_greentea.cmake index a493ea1f6ee..77b64f092b3 100644 --- a/tools/cmake/mbed_greentea.cmake +++ b/tools/cmake/mbed_greentea.cmake @@ -61,7 +61,7 @@ macro(mbed_greentea_add_test) list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-os) endif() - list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-greentea) + list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS greentea::client mbed-unity mbed-utest) target_link_libraries(${MBED_GREENTEA_TEST_NAME} PRIVATE