Skip to content

Commit 55b2c22

Browse files
committed
Add top-level CMakeLists.txt, configure script and Makefile
1 parent 6bd7314 commit 55b2c22

File tree

5 files changed

+360
-0
lines changed

5 files changed

+360
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/
2+
install/

CMakeLists.txt

+207
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
##
2+
## Top-level CMakeLists.txt to build and install the whole Orocos Toolchain
3+
##
4+
5+
cmake_minimum_required(VERSION 2.8)
6+
7+
# capture CMake arguments specified at the command-line
8+
# (taken from https://stackoverflow.com/a/48555098)
9+
10+
# MUST be done before call to 'project'
11+
get_cmake_property(vars CACHE_VARIABLES)
12+
foreach(var ${vars})
13+
if(NOT var MATCHES "^(CMAKE_INSTALL_PREFIX|CMAKE_BUILD_TYPE|GIT_BASE_URL|GIT_TAG|OROCOS_TARGET|BUILD_STATIC|ENABLE_CORBA|CORBA_IMPLEMENTATION)$")
14+
get_property(currentHelpString CACHE "${var}" PROPERTY HELPSTRING)
15+
if("${currentHelpString}" MATCHES "No help, variable specified on the command line." OR "${currentHelpString}" STREQUAL "")
16+
#message("${var} = [${${var}}] -- ${currentHelpString}") # uncomment to see the variables being processed
17+
list(APPEND CL_ARGS "-D${var}=${${var}}")
18+
endif()
19+
endif()
20+
endforeach()
21+
22+
project(orocos_toolchain)
23+
24+
######################
25+
# Build-time options #
26+
######################
27+
28+
# get absolute CMAKE_INSTALL_PREFIX
29+
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
30+
set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/install")
31+
endif()
32+
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH "Install path prefix, prepended onto install directories" FORCE)
33+
message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
34+
35+
# (copied from rtt/orocos-rtt.default.cmake)
36+
37+
#
38+
# Sets the CMAKE_BUILD_TYPE to Release by default. This is not a normal
39+
# CMake flag which is not readable during configuration time.
40+
if (NOT CMAKE_BUILD_TYPE)
41+
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
42+
endif()
43+
44+
#
45+
# Set the target operating system. One of [lxrt gnulinux xenomai macosx win32]
46+
# You may leave this as-is or force a certain target by removing the if... logic.
47+
#
48+
set(DOC_STRING "The Operating System target. One of [gnulinux lxrt macosx win32 xenomai]")
49+
set(OROCOS_TARGET_ENV $ENV{OROCOS_TARGET}) # MUST use helper variable, otherwise not picked up !!!
50+
if( OROCOS_TARGET_ENV )
51+
set(OROCOS_TARGET ${OROCOS_TARGET_ENV} CACHE STRING "${DOC_STRING}" FORCE)
52+
message(STATUS "Detected OROCOS_TARGET environment variable. Using: ${OROCOS_TARGET}")
53+
else()
54+
if(NOT DEFINED OROCOS_TARGET )
55+
if(MSVC)
56+
set(OROCOS_TARGET win32 CACHE STRING "${DOC_STRING}")
57+
elseif(APPLE AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
58+
set(OROCOS_TARGET macosx CACHE STRING "${DOC_STRING}")
59+
else()
60+
set(OROCOS_TARGET gnulinux CACHE STRING "${DOC_STRING}")
61+
endif()
62+
endif()
63+
message(STATUS "No OROCOS_TARGET environment variable set. Using: ${OROCOS_TARGET}")
64+
endif()
65+
66+
# (copied from rtt/config/check_depend.cmake)
67+
68+
#
69+
# Build static libraries?
70+
#
71+
option(BUILD_STATIC "Build Orocos RTT as a static library." OFF)
72+
73+
#
74+
# CORBA
75+
#
76+
option(ENABLE_CORBA "Enable CORBA" OFF)
77+
if(NOT CORBA_IMPLEMENTATION)
78+
set(CORBA_IMPLEMENTATION "TAO" CACHE STRING "The implementation of CORBA to use (allowed values: TAO or OMNIORB )" )
79+
else()
80+
set(CORBA_IMPLEMENTATION ${CORBA_IMPLEMENTATION} CACHE STRING "The implementation of CORBA to use (allowed values: TAO or OMNIORB )" )
81+
endif()
82+
83+
#############
84+
# Git magic #
85+
#############
86+
87+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
88+
set(IS_GIT TRUE)
89+
else()
90+
set(IS_GIT FALSE)
91+
endif()
92+
93+
set(GIT_BASE_URL "https://github.com/orocos-toolchain/")
94+
#set(GIT_TAG "" CACHE STRING "Git branch or tag to checkout in submodules. Default to current branch (update) or default branch (clone).")
95+
96+
# Find current branch if this is a git tree and use it as a default.
97+
if(IS_GIT)
98+
execute_process(
99+
COMMAND git --git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git symbolic-ref --short HEAD
100+
OUTPUT_VARIABLE CURRENT_GIT_BRANCH
101+
OUTPUT_STRIP_TRAILING_WHITESPACE
102+
ERROR_QUIET
103+
)
104+
if(CURRENT_GIT_BRANCH)
105+
message(STATUS "Current orocos_toolchain branch: ${CURRENT_GIT_BRANCH}")
106+
if(NOT DEFINED GIT_TAG)
107+
set(GIT_TAG ${CURRENT_GIT_BRANCH}) # not cached!
108+
endif()
109+
endif()
110+
endif()
111+
if(GIT_TAG)
112+
message(STATUS "Building branch or tag ${GIT_TAG} for all submodules.")
113+
endif()
114+
115+
#################################
116+
# Build and install subprojects #
117+
#################################
118+
119+
include(ExternalProject)
120+
function(build_external_project project)
121+
cmake_parse_arguments(ARG "" "" "CMAKE_ARGS" ${ARGN})
122+
123+
set(${project}_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${project})
124+
set(${project}_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${project})
125+
126+
if(IS_GIT)
127+
# Use the submodules...
128+
set(DOWNLOAD_AND_UPDATE_OPTIONS
129+
DOWNLOAD_COMMAND
130+
cd "${CMAKE_CURRENT_SOURCE_DIR}" && test -e ${project}/.git || git submodule update --init ${project}
131+
)
132+
133+
# Specific branch/tag?
134+
if(GIT_TAG)
135+
list(APPEND DOWNLOAD_AND_UPDATE_OPTIONS
136+
UPDATE_COMMAND
137+
cd "${CMAKE_CURRENT_SOURCE_DIR}/${project}" && git checkout "${GIT_TAG}"
138+
)
139+
endif()
140+
141+
else()
142+
# Clone from remote repository...
143+
set(DOWNLOAD_AND_UPDATE_OPTIONS
144+
GIT_REPOSITORY "${GIT_BASE_URL}${project}.git"
145+
GIT_TAG "${GIT_TAG}"
146+
)
147+
endif()
148+
149+
# Set PKG_CONFIG_PATH to be used by subprojects
150+
set(PKG_CONFIG_PATH "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}")
151+
152+
ExternalProject_Add(${project}
153+
PREFIX ${project}
154+
TMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/tmp"
155+
STAMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/stamp"
156+
DOWNLOAD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${project}"
157+
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${project}"
158+
BINARY_DIR "${${project}_BINARY_DIR}"
159+
INSTALL_DIR "${CMAKE_INSTALL_PREFIX}"
160+
161+
${DOWNLOAD_AND_UPDATE_OPTIONS}
162+
PATCH_COMMAND #nothing
163+
BUILD_ALWAYS ON
164+
165+
CMAKE_COMMAND
166+
${CMAKE_COMMAND} -E env "PKG_CONFIG_PATH=${PKG_CONFIG_PATH}" ${CMAKE_COMMAND}
167+
168+
CMAKE_ARGS
169+
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
170+
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
171+
-DOROCOS_TARGET=${OROCOS_TARGET}
172+
${ARG_CMAKE_ARGS}
173+
174+
${ARG_UNPARSED_ARGUMENTS}
175+
)
176+
endfunction()
177+
178+
build_external_project(log4cpp)
179+
build_external_project(rtt
180+
CMAKE_ARGS
181+
-DENABLE_CORBA=${ENABLE_CORBA}
182+
-DCORBA_IMPLEMENTATION=${CORBA_IMPLEMENTATION}
183+
-DBUILD_STATIC=${BUILD_STATIC}
184+
)
185+
build_external_project(ocl
186+
DEPENDS log4cpp rtt
187+
)
188+
189+
build_external_project(utilrb)
190+
build_external_project(typelib
191+
DEPENDS utilrb
192+
)
193+
build_external_project(rtt_typelib
194+
DEPENDS typelib
195+
)
196+
build_external_project(orogen
197+
DEPENDS rtt rtt_typelib utilrb
198+
)
199+
200+
#######################################
201+
# Build orocos_toolchain meta package #
202+
#######################################
203+
204+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/orocos_toolchain)
205+
add_subdirectory(orocos_toolchain)
206+
endif()
207+

Makefile

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.PHONY: all install
2+
all: build/CMakeCache.txt
3+
$(MAKE) -C build $@
4+
5+
build/CMakeCache.txt: configure
6+
7+
configure:
8+
./configure
9+
.PHONY: configure
10+
11+
install: all
12+
.PHONY: install
13+
14+
.DEFAULT: build/CMakeCache.txt
15+
$(MAKE) -C build $@
16+

README.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# The Orocos Toolchain
2+
3+
The Open RObot COntrol Software ([Orocos](http://www.orocos.org/)) Toolchain is a bundle of multiple packages, which need to be build and installed separately.
4+
5+
- [Orocos Real-Time Toolkit (rtt)](https://github.com/orocos-toolchain/rtt) - a component framework that allows us to write real-time components in C++
6+
- [Orocos Log4cpp (log4cpp)](https://github.com/orocos-toolchain/log4cpp) -
7+
a patched version of the [Log4cpp](http://log4cpp.sourceforge.net/) library for flexible logging to files, syslog, IDSA and other destinations
8+
- [Orocos Component Library (ocl)](https://github.com/orocos-toolchain/ocl) - the necessary components to start an application and interact with it at run-time
9+
10+
Futhermore the Orocos Toolchain comes with [oroGen](http://www.rock-robotics.org/stable/documentation/orogen/) and some of its dependencies,
11+
a specification language and code generator for the Orocos Realtime Toolkit. Also check the installation instructions of the
12+
[Rock - the Robot Construction Kit](http://www.rock-robotics.org/stable/index.html) project for further details.
13+
14+
You might also want to have a look at the following sister projects, which are out of the scope of this manual:
15+
- [Orocos Kinematics Dynamics Library (KDL)](http://www.orocos.org/kdl) - an application independent framework for modeling and computation of kinematic chains
16+
- [Orocos Bayesian Filtering Library (BFL)](http://www.orocos.org/bfl) - an application independent framework for inference in Dynamic Bayesian Networks, i.e., recursive information processing and estimation algorithms based on Bayes' rule
17+
- [Reduced Finite State Machine (rFSM)](https://orocos.github.io/rFSM/README.html) - a small and powerful statechart implementation in Lua
18+
19+
## Documentation
20+
21+
The latest documentation and API reference is currently available at https://orocos-toolchain.github.io/.
22+
23+
## Get Started?
24+
25+
### Install binary packages
26+
27+
The Orocos project provides binary packages as part of the [ROS distribution](http://www.ros.org) for various platforms.
28+
Check and follow the [ROS installation instructions](http://wiki.ros.org/ROS/Installation), then run
29+
```sh
30+
sudo apt-get install ros-${ROS_DISTRO}-orocos-toolchain
31+
```
32+
33+
to install the Orocos Toolchain packages.
34+
35+
As a ROS user, you might also be interested in the [rtt_ros_integration](http://wiki.ros.org/rtt_ros_integration) project:
36+
```sh
37+
sudo apt-get install ros-${ROS_DISTRO}-rtt-ros-integration
38+
```
39+
40+
### Build the toolchain from source
41+
42+
First, clone this repository and its submodules with the command
43+
```sh
44+
git clone https://github.com/orocos-toolchain/orocos_toolchain.git --recursive
45+
```
46+
47+
If you already have a working copy, make sure that all submodules are up-to-date:
48+
```sh
49+
git submodule update --init --recursive
50+
```
51+
52+
The next step is to configure the toolchain according to your needs:
53+
```sh
54+
./configure --prefix=<installation prefix> [<options>]
55+
```
56+
57+
```sh
58+
Usage: ./configure [<options>] [<additional cmake arguments>]
59+
60+
Available options:
61+
62+
--prefix <prefix> Installation prefix (-DCMAKE_INSTALL_PREFIX)
63+
64+
--{en|dis}able-corba Enable/Disable CORBA transport plugin (-DENABLE_CORBA)
65+
--omniorb Select CORBA implementation OmniORB
66+
--tao Select CORBA implementation TAO
67+
```
68+
69+
`configure` is nothing else than a simple wrapper around [CMake](https://cmake.org/).
70+
Check `./configure --help` for the latest available options.
71+
72+
Last but not least, build the toolchain by running
73+
```sh
74+
make install [-j<parallel jobs>]
75+
```
76+

configure

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
##
4+
usage() {
5+
cat <<USAGE >&2
6+
Usage: $0 [<options>] [<additional cmake arguments>]
7+
8+
Available options:
9+
10+
--prefix <prefix> Installation prefix (-DCMAKE_INSTALL_PREFIX)
11+
12+
--{en|dis}able-corba Enable/Disable CORBA transport plugin (-DENABLE_CORBA)
13+
--omniorb Select CORBA implementation OmniORB
14+
--tao Select CORBA implementation TAO
15+
16+
USAGE
17+
exit 1
18+
}
19+
20+
## Parse command line arguments
21+
CMAKE_ARGS=()
22+
while (( "$#" )); do
23+
case "$1" in
24+
--help|-h)
25+
usage ;;
26+
27+
--prefix=*)
28+
# set as two separate options
29+
prefix=${1#--prefix=}
30+
shift
31+
set -- --prefix "${prefix}" "$@"
32+
;;
33+
34+
--prefix)
35+
CMAKE_ARGS+=("-DCMAKE_INSTALL_PREFIX=$2")
36+
shift 2 ;;
37+
38+
--enable-corba)
39+
CMAKE_ARGS+=("-DENABLE_CORBA=ON")
40+
shift ;;
41+
--disable-corba)
42+
CMAKE_ARGS+=("-DENABLE_CORBA=OFF")
43+
shift ;;
44+
--omniorb)
45+
CMAKE_ARGS+=("-DCORBA_IMPLEMENTATION=OMNIORB")
46+
shift ;;
47+
--tao)
48+
CMAKE_ARGS+=("-DCORBA_IMPLEMENTATION=TAO")
49+
shift ;;
50+
51+
*)
52+
CMAKE_ARGS+=("$1")
53+
shift ;;
54+
esac
55+
done
56+
57+
## Invoke cmake
58+
mkdir -p build && cd build && cmake .. "${CMAKE_ARGS[@]}"
59+

0 commit comments

Comments
 (0)