Skip to content

Commit 812a3c8

Browse files
authored
Merge pull request #5 from rmspacefish/develop
Minor improvements
2 parents fdfdf5b + 1158eac commit 812a3c8

File tree

4 files changed

+53
-6
lines changed

4 files changed

+53
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# RTEMS CMake Build Support
22

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.
3+
This repository 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 build their RTEMS application with CMake. The support has been written as generic as possible.
44

55
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.
66

@@ -36,7 +36,7 @@ This will disable the compiler checks for the standard C/C++ compiler.
3636

3737

3838
If this repository was cloned inside the application root, the path can be
39-
set to `${CMAKE_CURRENT_SOURCE_DIRECTORY}`.
39+
set to `${CMAKE_CURRENT_SOURCE_DIRECTORY}/rtems-cmake`.
4040

4141
After that, include the general configuration file with the following line:
4242

@@ -47,7 +47,7 @@ include("${RTEMS_CONFIG_DIR}/RTEMSConfig.cmake")
4747
And then call the configuration function:
4848

4949
```sh
50-
rtems_general_config(${CMAKE_PROJECT_NAME} ${RTEMS_PREFIX} ${RTEMS_BSP})
50+
rtems_general_config(<TargetName> <RTEMS Prefix> <RTEMS BSP>)
5151
```
5252

5353
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,

RTEMSConfig.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040

4141
function(rtems_general_config TARGET_NAME RTEMS_PREFIX RTEMS_BSP_PAIR)
4242

43-
message(STATUS ${RTEMS_CONFIG_DIR})
4443
if(NOT RTEMS_CONFIG_DIR)
4544
message(STATUS
4645
"RTEMS_CONFIG_DIR not set. Assuming the CMake support was "
@@ -63,7 +62,7 @@ function(rtems_general_config TARGET_NAME RTEMS_PREFIX RTEMS_BSP_PAIR)
6362
set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER} PARENT_SCOPE)
6463
set(CMAKE_ASM_COMPILER ${CMAKE_ASM_COMPILER} PARENT_SCOPE)
6564
set(CMAKE_LINKER ${CMAKE_LINKER} PARENT_SCOPE)
66-
65+
6766
# I don't know what this is used for yet, but it might become handy
6867
if(NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR})
6968
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} PARENT_SCOPE)

RTEMSGeneric.cmake

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,20 @@ if (${NUM_EXTRA_RTEMS_ARGS} EQUAL 1)
3939
set(RTEMS_PATH ${EXTRA_RTEMS_ARGS})
4040
endif()
4141

42+
if(NOT RTEMS_PREFIX)
43+
status(WARNING "No RTEMS prefix supplied!")
44+
endif()
45+
46+
4247
set(RTEMS_PREFIX ${RTEMS_PREFIX} CACHE FILEPATH "RTEMS prefix")
48+
get_filename_component(RTEMS_PREFIX "${RTEMS_PREFIX}" ABSOLUTE)
49+
set(RTEMS_PREFIX_ABS ${RTEMS_PREFIX} CACHE FILEPATH
50+
"RTEMS prefix (absolute path)"
51+
)
52+
4353
set(RTEMS_BSP ${RTEMS_BSP} CACHE STRING "RTEMS BSP pair")
54+
55+
4456
option(RTEMS_VERBOSE "Verbose output for the RTEMS CMake support" FALSE)
4557

4658
set(RTEMS_INSTALL
@@ -174,7 +186,23 @@ if(NOT EXISTS "${RTEMS_LINKER}")
174186
"${RTEMS_BIN_PATH}/${RTEMS_ARCH_VERSION_NAME}-ld")
175187
endif()
176188

177-
message(STATUS "Checking done")
189+
message(STATUS "Checking for RTEMS objcopy utility..")
190+
set(RTEMS_OBJCOPY "${RTEMS_BIN_PATH}/${RTEMS_ARCH_VERSION_NAME}-objcopy")
191+
if(NOT EXISTS "${RTEMS_OBJCOPY}")
192+
message(WARNING
193+
"RTEMS ld linker not found at "
194+
"${RTEMS_BIN_PATH}/${RTEMS_ARCH_VERSION_NAME}-objcopy")
195+
endif()
196+
197+
message(STATUS "Checking for RTEMS size utility..")
198+
set(RTEMS_SIZE "${RTEMS_BIN_PATH}/${RTEMS_ARCH_VERSION_NAME}-size")
199+
if(NOT EXISTS "${RTEMS_SIZE}")
200+
message(WARNING
201+
"RTEMS ld linker not found at "
202+
"${RTEMS_BIN_PATH}/${RTEMS_ARCH_VERSION_NAME}-size")
203+
endif()
204+
205+
message(STATUS "Checking done.")
178206

179207
############################################
180208
# Info output
@@ -194,6 +222,9 @@ message(STATUS "RTEMS gcc compiler: ${RTEMS_GCC}")
194222
message(STATUS "RTEMS g++ compiler: ${RTEMS_GXX}")
195223
message(STATUS "RTEMS assembler: ${RTEMS_ASM}")
196224
message(STATUS "RTEMS linker: ${RTEMS_LINKER}")
225+
message(STATUS "RTEMS objcopy: ${RTEMS_OBJCOPY}")
226+
message(STATUS "RTEMS objcopy: ${RTEMS_SIZE}")
227+
197228

198229
if(${RTEMS_ARCH_NAME} STREQUAL "arm")
199230
set(CMAKE_SYSTEM_PROCESSOR arm PARENT_SCOPE)
@@ -207,6 +238,8 @@ set(CMAKE_C_COMPILER ${RTEMS_GCC} PARENT_SCOPE)
207238
set(CMAKE_CXX_COMPILER ${RTEMS_GXX} PARENT_SCOPE)
208239
set(CMAKE_ASM_COMPILER ${RTEMS_ASM} PARENT_SCOPE)
209240
set(CMAKE_LINKER ${RTEMS_LINKER} PARENT_SCOPE)
241+
set(RTEMS_OBJCOPY ${RTEMS_OBJCOPY} CACHE FILEPATH "RTEMS objcopy utilits")
242+
set(RTEMS_SIZE ${RTEMS_SIZE} CACHE FILEPATH "RTEMS size utility")
210243

211244
# Variables set in the cache so they can be used everywhere.
212245
set(RTEMS_ARCH_NAME ${RTEMS_ARCH_NAME} CACHE FILEPATH "Architecture name")

RTEMSHardware.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,22 @@ if(${RTEMS_SCAN_PKG_CONFIG})
5353
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${RTEMS_PKG_FILE_PATH}")
5454
pkg_check_modules(RTEMS_BSP_CONFIG "${RTEMS_PKG_MODULE_NAME}")
5555

56+
pkg_get_variable(RTEMS_BSP_CONFIG_PREFIX
57+
"${RTEMS_PKG_MODULE_NAME}" "prefix"
58+
)
59+
if(NOT "${RTEMS_BSP_CONFIG_PREFIX}" MATCHES "${RTEMS_PREFIX_ABS}")
60+
message(WARNING
61+
"Specified RTEMS prefix and prefix read from "
62+
"pkgconfig are different!"
63+
)
64+
message(WARNING
65+
"Consider adapting the pkg-config file manually if "
66+
"the toolchain has moved and the build fails."
67+
)
68+
endif()
69+
5670
if(${RTEMS_VERBOSE})
71+
message(STATUS "PKG prefix: ${RTEMS_BSP_CONFIG_PREFIX}")
5772
message(STATUS "PKG configuration file found: ${RTEMS_BSP_CONFIG_FOUND}")
5873
message(STATUS "Libraries: ${RTEMS_BSP_CONFIG_LIBRARIES}")
5974
message(STATUS "Link libraries: ${_RTEMS_BSP_CONFIGLINK_LIBRARIES}")

0 commit comments

Comments
 (0)