You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository contains the first version of a possible RTEMS CMake build support. 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 build their RTEMS application with CMake. The support has been written as generic as possible.
3
+
This repository contains the first version of a possible RTEMS CMake build support. 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 build their RTEMS application with CMake. The support has been written as generic as possible and only required a few lines of code is the application `CMakeLists.txt` file and some necessary variables set to determine compiler information.
4
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.
5
+
It is assumed that the RTEMS tools and the BSPs have already been built. If you are a beginner and this is not the case, it is recommended to have a look at [this demo](https://github.com/rmspacefish/rtems-demo) or the [QuickStart](https://docs.rtems.org/branches/master/user/start/index.html) to get started with RTEMS.
6
+
7
+
The usual way to set up a cross-compile project in CMake is to specify a CMake toolchain file. The CMake RTEMS support uses a combination of the supplied RTEMS BSP,
8
+
RTEMS version, RTEMS prefix and the `pkgconfig` utility to set up the RTEMS environment properly so that application developers can focus on their application.
9
+
10
+
This is still a prototype. Simple applications have been tested, but no larger projects have been compiled with this build support yet.
11
+
The compilation of simple applications was tested on Windows 10 and Ubuntu 20.04.
12
+
Improvements, suggestions and pull requests are welcome :-)
6
13
7
14
## How to use
8
15
@@ -22,61 +29,59 @@ set(RTEMS_CONFIG_DIR
22
29
)
23
30
```
24
31
25
-
It is also recommended to add the following lines before the `project()` call in
26
-
the application `CMakeLists.txt`:
32
+
We need to prepare some internal environmental variables for the CMake toolchain file and we also need to process information like the supplied `RTEMS_BSP` and `RTEMS_PREFIX` for the PKG config utility.
33
+
Add the following lines of code before the `project` call in your `CMakeLists.txt`
34
+
to call `rtems_pre_project_config` and pass `RTEMS_PREFIX` and `RTEMS_BSP` into the function call.
This will disable the compiler checks for the standard C/C++ compiler.
36
-
37
-
38
-
If this repository was cloned inside the application root, the path can be
39
-
set to `${CMAKE_CURRENT_SOURCE_DIRECTORY}/rtems-cmake`.
41
+
Now the CMake environment is prepared for the toolchan file. We set the `CMAKE_TOOLCHAIN_FILE` to CMake can set up the compilers and required RTEMS flags properly in the `project` call:
40
42
41
-
After that, include the general configuration file with the following line:
43
+
Add the following lines of code before the `project` call:
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,
54
-
and the RTEMS BSP (e.g. sparc/erc32) to this function.
57
+
This is not mandatory yet, but is useful for additional debug information (if `RTEMS_VERBOSE` is set to `TRUE`) and might become useful in the future if some additional target specific properties need to be set for RTEMS.
58
+
59
+
It is recommended to either hardcode mandatory values like the prefix and BSP path in the application `CMakeLists.txt` (especially when using the CMake GUI) or to supply them via command line and write scripts to ease this process.
55
60
56
-
After that, it will call the the function `rtems_hw_config` which will assign necessary compiler and linker flags to the provided target.
57
61
58
62
## Optional configuration of the CMake support
59
63
60
64
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
61
65
62
66
-`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!
-`RTEMS_SCAN_PKG_CONFIG`: The RTEMS CMake support will try to read the pkgconfig files to extract compile and link flag options.
65
68
-`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.
66
69
-`RTEMS_PATH`: Folder containing the RTEMS installation (BSPs). Can be different from the prefix but will be equal to the prefix for most users.
67
70
71
+
## CMake build configuration helper
72
+
73
+
A small python script is provided in the build support to allow easier configuration of the CMake build systems when using RTEMS. Call `cmake_build_config.py --help` to get
74
+
some information how to configure a build. Python 3 has to be installed to use this script.
75
+
68
76
## Extending the build system support
69
77
70
78
It is possible to read the pkfconfig files now, so extending the manual build configuration might not be necessary in the future.
71
79
72
-
Extending the build support is relatively easy:
73
-
74
-
Extract the necessary compiler and linker flags for the RTEMS build from the pkgconfig file
75
-
for the specific BSP. This file will generally be located inside the `lib/pkgconfig` folder of the RTEMS tools folder. Add these flags in the `RTEMSHardware.cmake` file for your specific BSP.
80
+
If this becomes necessary after all, follow these steps:
76
81
77
-
When building with CMake, `-v` can be added to verify the flags.
82
+
Extract the necessary compiler and linker flags for the RTEMS build from the pkgconfig file for the specific BSP. This file will generally be located inside the `lib/pkgconfig` folder of the RTEMS tools folder. Add these flags manually before the `project` file call (see `RTEMSToolchain.cmake` for examples) for your specific BSP.
78
83
79
-
## Example
84
+
## Examples
80
85
81
86
See https://github.com/rmspacefish/rtems-demo/tree/master/applications/hello for an example. This is the Hello World project taken from the RTEMS quick start guide,
82
-
but compiled using RTEMS. The repository also contains instructions on how to build the RTEMS tools if required and all specific steps to build with CMake.
87
+
but compiled using RTEMS. The repository also contains instructions on how to build the RTEMS tools if required and all specific steps to build with CMake and a blinky example for the STM32H743ZI-Nucleo board.
0 commit comments