Skip to content

Commit

Permalink
Merge pull request #5 from rmspacefish/develop
Browse files Browse the repository at this point in the history
Minor improvements
  • Loading branch information
robamu authored Dec 14, 2020
2 parents fdfdf5b + 1158eac commit 812a3c8
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RTEMS CMake Build Support

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

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.

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


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

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

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

```sh
rtems_general_config(${CMAKE_PROJECT_NAME} ${RTEMS_PREFIX} ${RTEMS_BSP})
rtems_general_config(<TargetName> <RTEMS Prefix> <RTEMS BSP>)
```

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,
Expand Down
3 changes: 1 addition & 2 deletions RTEMSConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

function(rtems_general_config TARGET_NAME RTEMS_PREFIX RTEMS_BSP_PAIR)

message(STATUS ${RTEMS_CONFIG_DIR})
if(NOT RTEMS_CONFIG_DIR)
message(STATUS
"RTEMS_CONFIG_DIR not set. Assuming the CMake support was "
Expand All @@ -63,7 +62,7 @@ function(rtems_general_config TARGET_NAME RTEMS_PREFIX RTEMS_BSP_PAIR)
set(CMAKE_CXX_COMPILER ${CMAKE_CXX_COMPILER} PARENT_SCOPE)
set(CMAKE_ASM_COMPILER ${CMAKE_ASM_COMPILER} PARENT_SCOPE)
set(CMAKE_LINKER ${CMAKE_LINKER} PARENT_SCOPE)

# I don't know what this is used for yet, but it might become handy
if(NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR})
set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR} PARENT_SCOPE)
Expand Down
35 changes: 34 additions & 1 deletion RTEMSGeneric.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,20 @@ if (${NUM_EXTRA_RTEMS_ARGS} EQUAL 1)
set(RTEMS_PATH ${EXTRA_RTEMS_ARGS})
endif()

if(NOT RTEMS_PREFIX)
status(WARNING "No RTEMS prefix supplied!")
endif()


set(RTEMS_PREFIX ${RTEMS_PREFIX} CACHE FILEPATH "RTEMS prefix")
get_filename_component(RTEMS_PREFIX "${RTEMS_PREFIX}" ABSOLUTE)
set(RTEMS_PREFIX_ABS ${RTEMS_PREFIX} CACHE FILEPATH
"RTEMS prefix (absolute path)"
)

set(RTEMS_BSP ${RTEMS_BSP} CACHE STRING "RTEMS BSP pair")


option(RTEMS_VERBOSE "Verbose output for the RTEMS CMake support" FALSE)

set(RTEMS_INSTALL
Expand Down Expand Up @@ -174,7 +186,23 @@ if(NOT EXISTS "${RTEMS_LINKER}")
"${RTEMS_BIN_PATH}/${RTEMS_ARCH_VERSION_NAME}-ld")
endif()

message(STATUS "Checking done")
message(STATUS "Checking for RTEMS objcopy utility..")
set(RTEMS_OBJCOPY "${RTEMS_BIN_PATH}/${RTEMS_ARCH_VERSION_NAME}-objcopy")
if(NOT EXISTS "${RTEMS_OBJCOPY}")
message(WARNING
"RTEMS ld linker not found at "
"${RTEMS_BIN_PATH}/${RTEMS_ARCH_VERSION_NAME}-objcopy")
endif()

message(STATUS "Checking for RTEMS size utility..")
set(RTEMS_SIZE "${RTEMS_BIN_PATH}/${RTEMS_ARCH_VERSION_NAME}-size")
if(NOT EXISTS "${RTEMS_SIZE}")
message(WARNING
"RTEMS ld linker not found at "
"${RTEMS_BIN_PATH}/${RTEMS_ARCH_VERSION_NAME}-size")
endif()

message(STATUS "Checking done.")

############################################
# Info output
Expand All @@ -194,6 +222,9 @@ message(STATUS "RTEMS gcc compiler: ${RTEMS_GCC}")
message(STATUS "RTEMS g++ compiler: ${RTEMS_GXX}")
message(STATUS "RTEMS assembler: ${RTEMS_ASM}")
message(STATUS "RTEMS linker: ${RTEMS_LINKER}")
message(STATUS "RTEMS objcopy: ${RTEMS_OBJCOPY}")
message(STATUS "RTEMS objcopy: ${RTEMS_SIZE}")


if(${RTEMS_ARCH_NAME} STREQUAL "arm")
set(CMAKE_SYSTEM_PROCESSOR arm PARENT_SCOPE)
Expand All @@ -207,6 +238,8 @@ set(CMAKE_C_COMPILER ${RTEMS_GCC} PARENT_SCOPE)
set(CMAKE_CXX_COMPILER ${RTEMS_GXX} PARENT_SCOPE)
set(CMAKE_ASM_COMPILER ${RTEMS_ASM} PARENT_SCOPE)
set(CMAKE_LINKER ${RTEMS_LINKER} PARENT_SCOPE)
set(RTEMS_OBJCOPY ${RTEMS_OBJCOPY} CACHE FILEPATH "RTEMS objcopy utilits")
set(RTEMS_SIZE ${RTEMS_SIZE} CACHE FILEPATH "RTEMS size utility")

# Variables set in the cache so they can be used everywhere.
set(RTEMS_ARCH_NAME ${RTEMS_ARCH_NAME} CACHE FILEPATH "Architecture name")
Expand Down
15 changes: 15 additions & 0 deletions RTEMSHardware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,22 @@ if(${RTEMS_SCAN_PKG_CONFIG})
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${RTEMS_PKG_FILE_PATH}")
pkg_check_modules(RTEMS_BSP_CONFIG "${RTEMS_PKG_MODULE_NAME}")

pkg_get_variable(RTEMS_BSP_CONFIG_PREFIX
"${RTEMS_PKG_MODULE_NAME}" "prefix"
)
if(NOT "${RTEMS_BSP_CONFIG_PREFIX}" MATCHES "${RTEMS_PREFIX_ABS}")
message(WARNING
"Specified RTEMS prefix and prefix read from "
"pkgconfig are different!"
)
message(WARNING
"Consider adapting the pkg-config file manually if "
"the toolchain has moved and the build fails."
)
endif()

if(${RTEMS_VERBOSE})
message(STATUS "PKG prefix: ${RTEMS_BSP_CONFIG_PREFIX}")
message(STATUS "PKG configuration file found: ${RTEMS_BSP_CONFIG_FOUND}")
message(STATUS "Libraries: ${RTEMS_BSP_CONFIG_LIBRARIES}")
message(STATUS "Link libraries: ${_RTEMS_BSP_CONFIGLINK_LIBRARIES}")
Expand Down

0 comments on commit 812a3c8

Please sign in to comment.