Skip to content

Commit 12dddbe

Browse files
committed
updated readme
1 parent 4e85e14 commit 12dddbe

File tree

2 files changed

+24
-29
lines changed

2 files changed

+24
-29
lines changed

README.md

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# RTEMS CMake Build Support
22

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.
44

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.
611
The compilation of simple applications was tested on Windows 10 and Ubuntu 20.04
712

813
## How to use
@@ -23,62 +28,52 @@ set(RTEMS_CONFIG_DIR
2328
)
2429
```
2530

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.
2834

2935
```sh
30-
set(CMAKE_SYSTEM_NAME Generic)
31-
set(CMAKE_C_COMPILER_WORKS 1)
32-
set(CMAKE_CXX_COMPILER_WORKS 1)
33-
set(CMAKE_CROSSCOMPILING 1)
36+
include(${RTEMS_CONFIG_DIR}/RTEMSPreProjectConfig.cmake)
37+
rtems_pre_project_config(${RTEMS_PREFIX} ${RTEMS_BSP})
3438
```
3539

36-
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:
3841

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:
4343

4444
```sh
45-
include("${RTEMS_CONFIG_DIR}/RTEMSConfig.cmake")
45+
set(CMAKE_TOOLCHAIN_FILE ${RTEMS_CONFIG_DIR}/RTEMSToolchain.cmake)
4646
```
4747

48-
And then call the configuration function:
48+
Finally, you can add the following lines to call the post-project configuration,
49+
passing the target name into the function call
4950

5051
```sh
51-
rtems_general_config(<TargetName> <RTEMS Prefix> <RTEMS BSP>)
52+
include("${RTEMS_CONFIG_DIR}/RTEMSPostProjectConfig.cmake")
53+
rtems_post_project_config(${TARGET_NAME})
5254
```
5355

54-
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.
5657

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.
5959

60-
After that, it will call the the function `rtems_hw_config` which will assign necessary compiler and linker flags to the provided target.
6160

6261
## Optional configuration of the CMake support
6362

6463
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
6564

6665
- `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!
6766
- `RTEMS_VERBOSE`: Enable additional diagnostic output.
68-
- `RTEMS_SCAN_PKG_CONFIG`: The RTEMS CMake support will try to read the pkgconfig files to extract compile and link flag options.
6967
- `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.
7068
- `RTEMS_PATH`: Folder containing the RTEMS installation (BSPs). Can be different from the prefix but will be equal to the prefix for most users.
7169

7270
## Extending the build system support
7371

7472
It is possible to read the pkfconfig files now, so extending the manual build configuration might not be necessary in the future.
7573

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:
8075

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.
8277

8378
## Example
8479

RTEMSPostProjectConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function(rtems_post_project_config)
1+
function(rtems_post_project_config TARGET_NAME)
22

33
if(RTEMS_VERBOSE)
44
message(STATUS "########################################################")

0 commit comments

Comments
 (0)