|
1 | | -# rtems-cmake |
| 1 | +# RTEMS CMake Build Support |
2 | 2 |
|
3 | | -This repostiory contains the first version of a possible RTEMS CMake build aupport. The intention is to export the RTEMS specific configuration of the cross compiler toolchain and the flags to external `*.cmake` files so the application `CMakeLists.txt` can stay clean, similarly to the `rtems_waf` support. |
| 3 | +This repostiory contains the first version of a possible RTEMS CMake build aupport. The intention is to provide most CMake configuration to perform cross-compiling of RTEMS applications and provide a decent starting point for developers which would like to use RTEMS. The support has been written as generic as possible. |
| 4 | + |
| 5 | +This is still a prototype. Simple applications have been tested, but it has not been attempted to link an additional library for an application yet. |
4 | 6 |
|
5 | 7 | ## How to use |
6 | 8 |
|
7 | | -Include the `RTEMSGeneric.cmake` file in CMake and call the `rtems_generic_config` function, passing the RTEMS installation path (also commonly called prefix) |
| 9 | +Clone this repository. This does not necesarilly have to be in the application root path, but the RTEMS configuration path (the folder containing the `*.cmake` files) needs to be specified in this case. |
| 10 | + |
| 11 | +```sh |
| 12 | +git clone https://github.com/rmspacefish/rtems-cmake.git |
| 13 | +``` |
| 14 | + |
| 15 | +After that, it is recommended to set the path to the RTEMS CMake support with the |
| 16 | +following line in the application `CMakeLists.txt` |
| 17 | + |
| 18 | +```sh |
| 19 | +set(RTEMS_CONFIG_DIR |
| 20 | + "<Path to RTEMS CMake support folder>" |
| 21 | + CACHE FILEPATH "Directory containing the RTEMS *.cmake files" |
| 22 | +) |
| 23 | +``` |
| 24 | + |
| 25 | +If this repository was cloned inside the application root, the path can be |
| 26 | +set to `${CMAKE_CURRENT_SOURCE_DIRECTORY}`. |
| 27 | + |
| 28 | +After that, include the general configuration file with the following line: |
| 29 | + |
| 30 | +```sh |
| 31 | +include("${RTEMS_CONFIG_DIR}/RTEMSConfig.cmake") |
| 32 | +``` |
| 33 | + |
| 34 | +And then call the configuration function: |
| 35 | + |
| 36 | +```sh |
| 37 | +rtems_general_config(${CMAKE_PROJECT_NAME} ${RTEMS_PREFIX} ${RTEMS_BSP}) |
| 38 | +``` |
| 39 | + |
| 40 | +This function will call the the `rtems_generic_config` function internally to set up the cross-compiler, using the provided RTEMS prefix and the BSP name, |
8 | 41 | and the RTEMS BSP (e.g. sparc/erc32) to this function. |
9 | 42 |
|
| 43 | +After that, it will call the the function `rtems_hw_config` which will assign necessary compiler and linker flags to the provided target. |
| 44 | + |
| 45 | +## Optional configuration of the CMake support |
| 46 | + |
| 47 | +The RTEMS CMake build support can be configured either by passing configuration options prepended with `-D` to the build command or by setting these build variables in the application `CMakeLists.txt` before calling the build support. Following options are available |
| 48 | + |
| 49 | + - `RTEMS_VERSION`: Can be specified manually. If this is not specified, the CMake build support will attempt to extract the version number from the RTEMS prefix (last letter of path). This variable needs to be valid for the RTEMS support to work! |
| 50 | + - `RTEMS_VERBOSE`: Enable additional diagnostic output. |
| 51 | + - `RTEMS_SCAN_PKG_CONFIG`: The RTEMS CMake support will try to read the pkgconfig files to extract compile and link flag options. |
| 52 | + - `RTEMS_TOOLS`: Can be specified if the RTEMS tools folder. Can be different from the prefix but will be equal to the prefix for most users. |
| 53 | + - `RTEMS_PATH`: Folder containing the RTEMS installation (BSPs). Can be different from the prefix but will be equal to the prefix for most users. |
| 54 | + |
10 | 55 | ## Extending the build system support |
11 | 56 |
|
12 | | -This is still a prototype. It has been tested for the Hello World demo from the RTEMS quick start guide which uses the `sparc/erc32` BSP and for a STM32 blinky using the `arm/stm32h7` BSP. |
| 57 | +It is possible to read the pkfconfig files now, so extending the manual build configuration might not be necessary in the future. |
13 | 58 |
|
14 | 59 | Extending the build support is relatively easy: |
15 | 60 |
|
|
0 commit comments