Skip to content

Commit 737153b

Browse files
authored
Merge pull request #14328 from hugueskamba/hk_cmake_fix_greentea_tests
CMake: Fix Greentea tests
2 parents 8340ea2 + 1ba3b73 commit 737153b

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

tools/cmake/README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,30 +88,31 @@ cmake -S <source-dir> -B <build-dir> -DCMAKE_BUILD_TYPE=debug
8888
## How to build a greentea test
8989
9090
Install prerequisites suggested in the previous section and follow the below steps to build:
91-
* Generate the `.mbedbuild/` configuration directory for the Mbed target you want to run the test on using [mbed-os-example-blinky](https://github.com/ARMmbed/mbed-os-example-blinky)
92-
```
93-
$ mbedtools configure -t <TOOLCHAIN> -m <MBED_TARGET>
94-
```
95-
* Copy `.mbedbuild/` into the test suite directory.
9691
* Set your current directory to the test suite directory
9792
98-
* Cmake `MBED_TEST_LINK_LIBRARIES` command-line argument config must be passed either `mbed-os` or `mbed-baremetal` when you are building a greentea test. In addition to that, you must pass any extra library along if that library source is not maintained as part of mbed os source tree.
93+
* CMake `MBED_TEST_LINK_LIBRARIES` command-line argument config must be passed either `mbed-os` or `mbed-baremetal` when you are building a greentea test. In addition to that, you must pass any extra library along if that library source is not maintained as part of mbed os source tree.
9994
10095
For example:
10196
kvstore greentea test is dependent on `mbed-storage` and `mbed-storage-filesystemstore` library however you don't need to pass it via `MBED_TEST_LINK_LIBRARIES` as it is already target linked in greentea test CMakeLists.txt, at the same time some libraries and test cases are private to the application and if you want to use it with kvstore test then pass it with `MBED_TEST_LINK_LIBRARIES` command-line argument.
102-
103-
* Run the following command to build the test binary with the full profile
104-
97+
* Run the following command for the test suite to be recognised as a valid Mbed application
98+
```
99+
touch mbed-os.lib && ln -s /path/to/mbed-os mbed-os
100+
```
101+
* Run the following command for the configuration CMake module to be generated
102+
```
103+
mbedtools configure -t <TOOLCHAIN> -m <MBED_TARGET>
104+
```
105+
* Build the test binary with the full profile
105106
```
106-
mkdir cmake_build && cd cmake_build && cmake .. -G Ninja -DMBED_TEST_LINK_LIBRARIES=mbed-os && cmake --build .
107+
cd cmake_build/<MBED_TARGET>/<PROFILE>/<TOOLCHAIN>/ && cmake ../../../.. -G Ninja -DMBED_TEST_LINK_LIBRARIES=mbed-os && cmake --build .
107108
```
108-
* Run the following command to build the test binary with the baremetal profile
109+
To build the test binary with the baremetal profile
109110
```
110-
mkdir cmake_build && cd cmake_build && cmake .. -G Ninja -DMBED_TEST_LINK_LIBRARIES=mbed-baremetal && cmake --build .
111+
cd cmake_build/<MBED_TARGET>/<PROFILE>/<TOOLCHAIN>/ && cmake ../../../.. -G Ninja -DMBED_TEST_LINK_LIBRARIES=mbed-baremetal && cmake --build .
111112
```
112-
* Run the following command to build the test binary with the full profile and XYZ library
113+
To build the test binary with the full profile and a "XYZ" library
113114
```
114-
mkdir cmake_build && cd cmake_build && cmake .. -G Ninja -D"MBED_TEST_LINK_LIBRARIES=mbed-os XYZ" && cmake --build .
115+
cd cmake_build/<MBED_TARGET>/<PROFILE>/<TOOLCHAIN>/ && cmake ../../../.. -G Ninja -D"MBED_TEST_LINK_LIBRARIES=mbed-os XYZ" && cmake --build .
115116
```
116117
117118
Notes:

tools/cmake/mbed_greentea.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Copyright (c) 2020 ARM Limited. All rights reserved.
1+
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4-
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_SOURCE_DIR}/.mbedbuild CACHE INTERNAL "")
4+
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
55

66
include(${MBED_PATH}/tools/cmake/app.cmake)
77

0 commit comments

Comments
 (0)