mbed-os/tools/cmake
Robert Walton 0e491cc0cf cmake: Refactor mbed_set_mbed_target_linker_script
Move the mbed_set_mbed_target_linker_script function into its own file
and make it set the linkerscript on the target passed in, rather than
setting the linkerscript on the top level mbed-core target. We use
CMake's automatic forwarding of usage requirements to forward the linker
script to the top level target.

This commit also adds a condition to check whether the MBED_TARGET is a
CMake buildsystem target. If it is we will just link to it in the
idiomatic CMake way, if it's not then we use the 'old' mechanism of
setting the linkerscript for the mbed-core target. This check will be
useful when we refactor MBED_TARGETS to be CMake buildsystem targets as
it will allow us to do the refactoring incrementally.
2021-02-04 15:26:33 +00:00
..
cores Merge pull request #14190 from 0xc0170/fix_ns_cores 2021-02-03 10:17:21 +00:00
profiles Fix variable name conflict with toolchain file 2020-12-03 10:58:41 -08:00
toolchains Fix some formatting issues. 2020-12-08 02:28:50 -08:00
README.md CMake: Add support for Mbed TLS Greentea tests 2021-01-25 10:48:15 +00:00
app.cmake Add newline 2021-01-29 09:00:35 -08:00
mbed_greentea.cmake cmake: Refactor mbed_set_mbed_target_linker_script 2021-02-04 15:26:33 +00:00
profile.cmake CMake: Rename Mbed OS path variable for consistency 2020-11-06 17:25:23 +00:00
requirements.txt CMake: Add requirements.txt file for required Python modules 2020-12-16 13:45:57 +00:00
set_linker_script.cmake cmake: Refactor mbed_set_mbed_target_linker_script 2021-02-04 15:26:33 +00:00
toolchain.cmake Add cortex-m55 to CMake support 2021-01-28 16:46:18 +00:00

README.md

CMake for Mbed OS

In order to replace the traditional Mbed tools, we are adding CMake support to allow the generation of build systems instructions to build Mbed OS as a library.

This is still at the experimental stage and still in development. It does not yet completely replace our current build tools. If you find a bug, please report it or raise a pull request as contributions are welcome!

Mbed OS is built as collection of all core libraries. Application project executables can be linked with the mbed-os library (which includes the core libraries of Mbed OS) and optional mbed-os- prefixed libraries depending on the additional features required by the projects and supported by the Mbed target.

The list of optional libraries for each component can be seen in the CMake input source file at the root of each component directory.

The following features are not yet supported and will be progressively added:

  • Application profile selection (bare metal)
  • Features that require altering compiler/linker command line options (except for printf library and C selections)

The full profile with the selected printf and C libraries.

Supported targets

Only a limited set of targets is supported at the moment.

The following targets are supported:

  • Ambiq Micro targets
  • Analog Devices targets
  • ARM FM targets
  • ARM SSG targets
  • Cypress targets
  • Freescale targets
  • GigaDevice targets
  • MAXIM targets
  • Nordic targets
  • NXP targets
  • Renesas targets
  • Samsung targets
  • Silicon Labs targets
  • STM targets
  • Toshiba targets
  • WICED targets

Supported toolchains

Arm Compiler 6 and GNU Arm Embedded toolchains are supported.

Examples

Supported examples can be identified by the presence of a top level CMakeLists.txt input source file.

Known issues

How to build an application

Prerequisities:

From the application root or wherever mbed-os.lib is found, run the following command to:

  • create the Mbed OS configuration CMake module

  • create a build directory

  • generate the project configuration

  • build the project using the Ninja build system

    mbedtools compile -m <mbed-target> -t <toolchain>
    

CMAKE_BUILD_TYPE can overridden with Mbed specific values: Develop (default value), Release and Debug.

mbed-tools will pass -DCMAKE_BUILD_TYPE=<supported-build-type> for you when using the --build-type optional argument of the build subcommand as follows:

mbedtools compile -m <mbed-target> -t <toolchain> -b <supported-build-type>

If you're running CMake directly, you may need to pass it in yourself as follows:

cmake -S <source-dir> -B <build-dir> -DCMAKE_BUILD_TYPE=debug

How to build a greentea test

Install prerequisites suggested in the previous section and follow the below steps to build:

  • Generate the .mbedbuild/ configuration directory for the Mbed target you want to run the test on using mbed-os-example-blinky
$ mbedtools configure -t <TOOLCHAIN> -m <MBED_TARGET> 
  • Copy .mbedbuild/ into the test suite directory.

  • Set your current directory to the test suite directory

  • Run the following command to build the test binary with the full profile

    touch mbed-os.lib && mkdir cmake_build && cd cmake_build && cmake .. -G Ninja && cmake --build .
    
  • Run the following command to build the test binary with the baremetal profile

    touch mbed-os.lib && mkdir cmake_build && cd cmake_build && cmake .. -G Ninja -DMBED_BAREMETAL_GREENTEA_TEST=ON && cmake --build .
    

Notes:

  • These steps will change when mbedtools implements a sub-command to invoke Greentea tests
  • Some Greentea tests require specific application configuration files in order to build and run successfully. For example, the connectivity/mbedtls/tests/TESTS/mbedtls/sanity test requires the configuration file found at TESTs/configs/experimental.json.