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
Copy file name to clipboardExpand all lines: README.md
+23-28Lines changed: 23 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,13 @@
1
1
# RTEMS CMake Build Support
2
2
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.
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.
6
11
The compilation of simple applications was tested on Windows 10 and Ubuntu 20.04
7
12
8
13
## How to use
@@ -23,62 +28,52 @@ set(RTEMS_CONFIG_DIR
23
28
)
24
29
```
25
30
26
-
It is also recommended (and necessary on Windows) to add the following lines before
27
-
the `project()` call in the application `CMakeLists.txt`:
31
+
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.
32
+
Add the following lines of code before the `project` call in your `CMakeLists.txt`
33
+
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.
37
-
40
+
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:
38
41
39
-
If this repository was cloned inside the application root, the path can be
40
-
set to `${CMAKE_CURRENT_SOURCE_DIRECTORY}/rtems-cmake`.
41
-
42
-
After that, include the general configuration file with the following line:
42
+
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,
55
-
and the RTEMS BSP (e.g. sparc/erc32) to this function.
56
+
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.
56
57
57
-
It is recommended to either hardcode mandatory values like the prefix and BSP path in the application `CMakeLists.txt`
58
-
(especially when using the CMake GUI) or to supply them via command line and write scripts to ease this process.
58
+
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.
59
59
60
-
After that, it will call the the function `rtems_hw_config` which will assign necessary compiler and linker flags to the provided target.
61
60
62
61
## Optional configuration of the CMake support
63
62
64
63
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
65
64
66
65
-`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.
69
67
-`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.
70
68
-`RTEMS_PATH`: Folder containing the RTEMS installation (BSPs). Can be different from the prefix but will be equal to the prefix for most users.
71
69
72
70
## Extending the build system support
73
71
74
72
It is possible to read the pkfconfig files now, so extending the manual build configuration might not be necessary in the future.
75
73
76
-
Extending the build support is relatively easy:
77
-
78
-
Extract the necessary compiler and linker flags for the RTEMS build from the pkgconfig file
79
-
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.
74
+
If this becomes necessary after all, follow these steps:
80
75
81
-
When building with CMake, `-v` can be added to verify the flags.
76
+
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.
0 commit comments