mirror of https://github.com/ARMmbed/mbed-os.git
CMake: Replace MBED_TEST_LINK_LIBRARIES with MBED_TEST_BAREMETAL
Currently we have `MBED_TEST_LINK_LIBRARIES` for specifying * Whether to link `mbed-os` or `mbed-baremetal` * Any additional libraries we want tests to link It's not fit for purpose anymore, because * No flavor of Mbed OS is selected by default, but we should've really defaulted to `mbed-os`, the full RTOS version. Build doesn't work unless `-DMBED_TEST_LINK_LIBRARIES=<...>` is passed, which is redundant. * A test should never need additional libraries passed via command line - its `CMakeLists.txt` should specify what it links. This commit replaces `MBED_TEST_LINK_LIBRARIES` with a new option `MBED_TEST_BAREMETAL` to build a test with either RTOS (default) or without it (by passing `-DMBED_TEST_BAREMETAL=ON`).pull/14874/head
parent
2a1d50f0fa
commit
f4d551e80e
|
|
@ -87,25 +87,17 @@ cmake -S <source-dir> -B <build-dir> -DCMAKE_BUILD_TYPE=debug
|
|||
Install prerequisites suggested in the previous section and follow the below steps to build:
|
||||
* Set your current directory to the test suite directory
|
||||
|
||||
* 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.
|
||||
|
||||
For example:
|
||||
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.
|
||||
* Run the following command for the configuration CMake module to be generated
|
||||
```
|
||||
mbedtools configure -t <TOOLCHAIN> -m <MBED_TARGET> --mbed-os-path /path/to/mbed-os
|
||||
```
|
||||
* Build the test binary with the full profile
|
||||
```
|
||||
cd cmake_build/<MBED_TARGET>/<PROFILE>/<TOOLCHAIN>/ && cmake ../../../.. -G Ninja -DMBED_TEST_LINK_LIBRARIES=mbed-os && cmake --build .
|
||||
cd cmake_build/<MBED_TARGET>/<PROFILE>/<TOOLCHAIN>/ && cmake ../../../.. -G Ninja && cmake --build .
|
||||
```
|
||||
To build the test binary with the baremetal profile
|
||||
Or build the test binary with the baremetal profile
|
||||
```
|
||||
cd cmake_build/<MBED_TARGET>/<PROFILE>/<TOOLCHAIN>/ && cmake ../../../.. -G Ninja -DMBED_TEST_LINK_LIBRARIES=mbed-baremetal && cmake --build .
|
||||
```
|
||||
To build the test binary with the full profile and a "XYZ" library
|
||||
```
|
||||
cd cmake_build/<MBED_TARGET>/<PROFILE>/<TOOLCHAIN>/ && cmake ../../../.. -G Ninja -D"MBED_TEST_LINK_LIBRARIES=mbed-os XYZ" && cmake --build .
|
||||
cd cmake_build/<MBED_TARGET>/<PROFILE>/<TOOLCHAIN>/ && cmake ../../../.. -G Ninja -DMBED_TEST_BAREMETAL=ON && cmake --build .
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
# Copyright (c) 2020-2021 ARM Limited. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
option(MBED_TEST_BAREMETAL OFF)
|
||||
|
||||
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/app.cmake)
|
||||
|
|
@ -52,19 +55,14 @@ macro(mbed_greentea_add_test)
|
|||
${MBED_GREENTEA_TEST_SOURCES}
|
||||
)
|
||||
|
||||
# The CMake MBED_TEST_LINK_LIBRARIES command-line argument is to get greentea test all dependent libraries.
|
||||
# For example:
|
||||
# - To select mbed-os library, use cmake with -DMBED_TEST_LINK_LIBRARIES=mbed-os
|
||||
# - To select baremetal library, use cmake with -DMBED_TEST_LINK_LIBRARIES=mbed-baremetal
|
||||
# - To select baremetal with extra external error logging library to the test, use cmake with
|
||||
# -D "MBED_TEST_LINK_LIBRARIES=mbed-baremetal ext-errorlogging"
|
||||
if (DEFINED MBED_TEST_LINK_LIBRARIES)
|
||||
separate_arguments(MBED_TEST_LINK_LIBRARIES)
|
||||
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS ${MBED_TEST_LINK_LIBRARIES} mbed-greentea)
|
||||
if(MBED_TEST_BAREMETAL)
|
||||
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-baremetal)
|
||||
else()
|
||||
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-greentea)
|
||||
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-os)
|
||||
endif()
|
||||
|
||||
list(APPEND MBED_GREENTEA_TEST_REQUIRED_LIBS mbed-greentea)
|
||||
|
||||
target_link_libraries(${MBED_GREENTEA_TEST_NAME}
|
||||
PRIVATE
|
||||
${MBED_GREENTEA_TEST_REQUIRED_LIBS}
|
||||
|
|
|
|||
Loading…
Reference in New Issue