Building RTEMS hello world image using CMake

Chris Johns chrisj at rtems.org
Fri Mar 11 01:02:01 UTC 2016


  [ Please excuse the delay. It took a while to get
    something worth posting sorted out. ]

On 04/03/2016 14:46, Sambeet Panigrahi wrote:
> I wanted to build a hello world image of RTEMS using cmake. Can someone
> provide me steps for doing so or point me to the right resources ?

I attach a couple of files from a friend of mine, Andi, who knows and 
works with cmake. I have not tried them and I do not know if they work.

If you have any questions please feel free to ask.

Chris
-------------- next part --------------
cmake_minimum_required(VERSION 2.8.11)

set(RTEMS_ROOT_PATH             "/home/andi/development/rtems")
set(RTEMS_TOOLS_INSTALL_DIR     "${RTEMS_ROOT_PATH}/4.12")
set(RTEMS_TOOLS_BSP_LIB_DIR     "${RTEMS_ROOT_PATH}/4.12/sparc-rtems4.12/lib")
set(RTEMS_KERNEL_INSTALL_DIR    "${RTEMS_ROOT_PATH}/sparc-sis")
set(RTEMS_KERNEL_BSP_LIB_DIR    "${RTEMS_ROOT_PATH}/sparc-sis/sparc-rtems4.12/sis/lib")

set(ENV{PATH} "${RTEMS_TOOLS_INSTALL_DIR}/bin:$ENV{PATH}")
set(RTEMS_TOOLS_BSP_INCLUDE_DIR       "${RTEMS_TOOLS_BSP_LIB_DIR}/include")
set(RTEMS_KERNEL_BSP_INCLUDE_DIR      "${RTEMS_KERNEL_BSP_LIB_DIR}/include")
set(RTEMS_COMPILE_OPTIONS             "-B${RTEMS_KERNEL_BSP_LIB_DIR} -B${RTEMS_TOOLS_BSP_LIB_DIR} -specs bsp_specs -qrtems -mcpu=cypress") 

include(CMakeForceCompiler)
set(CMAKE_SYSTEM_NAME         Generic)
set(CMAKE_SYSTEM_PROCESSOR    sparc)
cmake_force_c_compiler("${RTEMS_TOOLS_INSTALL_DIR}/bin/sparc-rtems4.12-gcc"     GNU)

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE          "RelWithDebInfo"     CACHE STRING "")
endif()
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug RelWithDebInfo Release)

set(CMAKE_C_FLAGS_DEBUG             "${RTEMS_COMPILE_OPTIONS} -g"              CACHE STRING "")
set(CMAKE_C_FLAGS_RELWITHDEBINFO    "${RTEMS_COMPILE_OPTIONS} -g -O2"          CACHE STRING "")
set(CMAKE_C_FLAGS_RELEASE           "${RTEMS_COMPILE_OPTIONS} -O2 -DNDEBUG"    CACHE STRING "")

project(hello)

add_executable(HELLO hello.c)
target_include_directories(HELLO BEFORE PRIVATE                           
                           ${RTEMS_TOOLS_BSP_INCLUDE_DIR}
                           ${RTEMS_KERNEL_BSP_INCLUDE_DIR})
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hello.c
Type: text/x-csrc
Size: 691 bytes
Desc: not available
URL: <http://lists.rtems.org/pipermail/devel/attachments/20160311/f1732c09/attachment-0002.bin>


More information about the devel mailing list