Skip to content

Commit

Permalink
env-hooks: install env-hook to etc/orocos/OROCOS_TARGET/profile.d
Browse files Browse the repository at this point in the history
The env-hook sets the OROCOS_TARGET environment variable if not set and adds the lib/orocos directory
of the install-space and all entries of the CMAKE_PREFIX_PATH (for catkin workspaces) to the
RTT_COMPONENT_PATH.

The scripts in etc/orocos/OROCOS_TARGET/profile.de will be sourced in lexical order by a new setup.sh
script located in the orocos_toolchain repository.

Signed-off-by: Johannes Meyer <[email protected]>
  • Loading branch information
meyerj committed Nov 11, 2016
1 parent 9c46c95 commit a437e40
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,14 @@ INSTALL(FILES UseOROCOS-RTT.cmake UseOROCOS-RTT-helpers.cmake config/cmake_unins
# Install package.xml
INSTALL(FILES package.xml DESTINATION share/rtt)

# Install an env-hook if catkin is found
# Install an env-hook in etc/orocos/${OROCOS_TARGET}/profile.d
configure_file(env-hooks/00.rtt.sh.in ${CMAKE_CURRENT_BINARY_DIR}/env-hooks/00.rtt.sh @ONLY)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/env-hooks/00.rtt.sh
DESTINATION etc/orocos/${OROCOS_TARGET}/profile.d
)

# Install a catkin env-hook if catkin is installed
find_package(catkin QUIET)
if(catkin_FOUND)
catkin_add_env_hooks(00.rtt SHELLS sh DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/env-hooks)
Expand Down
16 changes: 14 additions & 2 deletions env-hooks/00.rtt.sh.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
#!/bin/sh
export OROCOS_TARGET=@OROCOS_TARGET@
export RTT_COMPONENT_PATH=`echo $CMAKE_PREFIX_PATH | sed 's!:!/lib/orocos:!g' | sed 's!$!/lib/orocos!'`

: ${OROCOS_TARGET:=@OROCOS_TARGET@}

for path in `echo $CMAKE_PREFIX_PATH | tr : ' '` "@CMAKE_INSTALL_PREFIX@"; do
if [ ! -d "$path/lib/orocos" ]; then
continue
elif [ -z "$RTT_COMPONENT_PATH" ]; then
RTT_COMPONENT_PATH="$path/lib/orocos"
elif ! echo "$RTT_COMPONENT_PATH" | grep -q "$path/lib/orocos"; then
RTT_COMPONENT_PATH="$RTT_COMPONENT_PATH:$path/lib/orocos"
fi
done

export OROCOS_TARGET
export RTT_COMPONENT_PATH

0 comments on commit a437e40

Please sign in to comment.