Skip to content

Commit 9133a5d

Browse files
authored
Merge pull request #3 from rmspacefish/develop
documentation improved significantly
2 parents dfc102c + 1f57973 commit 9133a5d

File tree

2 files changed

+69
-12
lines changed

2 files changed

+69
-12
lines changed

README.md

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,60 @@
1-
# rtems-cmake
1+
# RTEMS CMake Build Support
22

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

57
## How to use
68

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,
841
and the RTEMS BSP (e.g. sparc/erc32) to this function.
942

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+
1055
## Extending the build system support
1156

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

1459
Extending the build support is relatively easy:
1560

RTEMSConfig.cmake

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,42 @@
1414
# the RTEMS_BSP variable.
1515
#
1616
# Other variables which can be provided by the developer via command line
17-
# as well:
17+
# or in the application CMake file as well:
1818
#
19-
# 1. RTEMS_VERSION:
19+
# 1. RTEMS_CONFIG_DIR: The application will assume that all other configuration
20+
# files are located in this path or relative to this path. If this is not set
21+
# it will be set to the ${CMAKE_CURRENT_SOURCE_DIR}/rtems-cmake
22+
# 2. RTEMS_VERSION:
2023
# The user can supply RTEMS_VERSION to specify the RTEMS version
2124
# manually. This is required to determine the toolchains to use. If no
2225
# RTEMS_VERSION is supplied, this CMake file will try to autodetermine the
2326
# RTEMS version from the supplied tools path.
24-
# 2. RTEMS_TOOLS:
27+
# 3. RTEMS_TOOLS:
2528
# The user can provide this filepath variable if the RTEMS tools path is
2629
# not equal to the RTEMS prefix.
27-
# 3. RTEMS_PATH:
30+
# 4. RTEMS_PATH:
2831
# The user can provide this filepath variable if the RTEMS path (containg
2932
# the BSPs) is not equal to the RTEMS prefix.
30-
# 4. RTEMS_VERBOSE:
33+
# 5. RTEMS_VERBOSE:
3134
# Verbose debug output for the CMake handling.
32-
# 5. RTEMS_SCAN_PKG_CONFIG:
35+
# 6. RTEMS_SCAN_PKG_CONFIG:
3336
# CMake will try to scan the pkgconfig file for the specified Architecture-
3437
# Version-BSP combination to find the compiler and linker flags.
3538
#
3639
# Any additional arguments will be passed on to the subfunctions here.
3740

3841
function(rtems_general_config TARGET_NAME RTEMS_PREFIX RTEMS_BSP_PAIR)
3942

40-
include(${RTEMS_CONFIG_DIRECTORY}/RTEMSGeneric.cmake)
43+
message(STATUS ${RTEMS_CONFIG_DIR})
44+
if(NOT RTEMS_CONFIG_DIR)
45+
message(STATUS
46+
"RTEMS_CONFIG_DIR not set. Assuming the CMake support was "
47+
"cloned in the application source directory.."
48+
)
49+
set(RTEMS_CONFIG_DIR ${CMAKE_CURRENT_SOURCE_DIR}/rtems-cmake)
50+
endif()
51+
52+
include(${RTEMS_CONFIG_DIR}/RTEMSGeneric.cmake)
4153
rtems_generic_config(${TARGET_NAME} ${RTEMS_PREFIX} ${RTEMS_BSP_PAIR} ${ARGN})
4254

4355
# Not an ideal solution but it will do for now because the number of
@@ -57,7 +69,7 @@ function(rtems_general_config TARGET_NAME RTEMS_PREFIX RTEMS_BSP_PAIR)
5769
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} PARENT_SCOPE)
5870
endif()
5971

60-
include(${RTEMS_CONFIG_DIRECTORY}/RTEMSHardware.cmake)
72+
include(${RTEMS_CONFIG_DIR}/RTEMSHardware.cmake)
6173
rtems_hw_config(${TARGET_NAME} ${RTEMS_PREFIX} ${RTEMS_BSP_PAIR} ${ARGN})
6274

6375
# No propagation necessary here because we can use target specific settings.

0 commit comments

Comments
 (0)