From cae780f1223aaffb41e7755afebc9158d7e840cf Mon Sep 17 00:00:00 2001 From: Peter Soetens Date: Fri, 26 Nov 2010 12:08:38 +0100 Subject: [PATCH 1/3] typelib: support typelibs built in ros package trees. The patch is minimally intrusive for letting both typelib and the cmake system know that we're building in a ros package tree. This means that it should also work without installing the package. Signed-off-by: Peter Soetens --- lib/orogen/templates/typekit/CMakeLists.txt | 9 +++++++++ lib/orogen/templates/typekit/manifest.xml | 3 +-- .../templates/typekit/typelib/CMakeLists.txt | 9 +++++++++ .../templates/typekit/typelib/TransportPlugin.cpp | 18 ++++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/lib/orogen/templates/typekit/CMakeLists.txt b/lib/orogen/templates/typekit/CMakeLists.txt index deea6cf..9f17b33 100644 --- a/lib/orogen/templates/typekit/CMakeLists.txt +++ b/lib/orogen/templates/typekit/CMakeLists.txt @@ -45,6 +45,15 @@ ADD_CUSTOM_TARGET(regen # END if typekit.standalone? ## +set(ROS_ROOT $ENV{ROS_ROOT}) +if ( ROS_ROOT ) + if ( NOT ROSPACK_EXE ) + include(${ROS_ROOT}/core/rosbuild/rosbuild.cmake) + rosbuild_init() + endif( NOT ROSPACK_EXE ) + set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${${CMAKE_PROJECT_NAME}_SOURCE_DIR}/lib/orocos/types) +endif( ROS_ROOT ) + execute_process(COMMAND cmake -E create_symlink ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/<%= typekit.name %>) diff --git a/lib/orogen/templates/typekit/manifest.xml b/lib/orogen/templates/typekit/manifest.xml index 2c3395d..e7dbe26 100644 --- a/lib/orogen/templates/typekit/manifest.xml +++ b/lib/orogen/templates/typekit/manifest.xml @@ -8,7 +8,6 @@ http://ros.org/wiki/<%=typekit.name %>-typekit - - + diff --git a/lib/orogen/templates/typekit/typelib/CMakeLists.txt b/lib/orogen/templates/typekit/typelib/CMakeLists.txt index 35166b6..fb589e6 100644 --- a/lib/orogen/templates/typekit/typelib/CMakeLists.txt +++ b/lib/orogen/templates/typekit/typelib/CMakeLists.txt @@ -21,6 +21,15 @@ target_link_libraries(${libname_typelib} target_link_libraries(${libname_typelib} LINK_INTERFACE_LIBRARIES) +# rospack support +if ( ROS_ROOT ) + rosbuild_find_ros_package( roslib ) + include_directories( ${roslib_PACKAGE_PATH}/include ) + find_library(ROS_LIB roslib ${roslib_PACKAGE_PATH}/lib ) + TARGET_LINK_LIBRARIES( ${libname} ${ROS_LIB} ) + ADD_DEFINITIONS( -DHAS_ROSLIB ) +endif( ROS_ROOT ) + SET(PKG_CONFIG_FILE_TYPELIB ${CMAKE_CURRENT_BINARY_DIR}/<%= typekit.name %>-transport-typelib-${OROCOS_TARGET}.pc) CONFIGURE_FILE(<%= typekit.name %>-transport-typelib.pc.in ${PKG_CONFIG_FILE_TYPELIB} @ONLY) diff --git a/lib/orogen/templates/typekit/typelib/TransportPlugin.cpp b/lib/orogen/templates/typekit/typelib/TransportPlugin.cpp index e828bda..703d27f 100644 --- a/lib/orogen/templates/typekit/typelib/TransportPlugin.cpp +++ b/lib/orogen/templates/typekit/typelib/TransportPlugin.cpp @@ -9,6 +9,9 @@ #include #include using namespace RTT; +#ifdef HAS_ROSLIB +#include +#endif #define TYPEKIT_PACKAGE_NAME_aux0(target) #target #define TYPEKIT_PACKAGE_NAME_aux(target) "<%= typekit.name %>-typekit-" TYPEKIT_PACKAGE_NAME_aux0(target) @@ -17,6 +20,21 @@ using namespace RTT; orogen_typekits::<%= typekit.name %>TypelibTransportPlugin::<%= typekit.name %>TypelibTransportPlugin() : m_registry(0) { +#ifdef HAS_ROSLIB + using namespace ros::package; + try { + bool all_good = true, found = false; + std::string ppath = getPath( "<%= typekit.name %>" ); + if ( !ppath.empty() ) { + std::string tkpath = ppath + "/typekit" + "/<%= typekit.name %>.tlb"; + m_registry = Typelib::PluginManager::load("tlb", tkpath); + return; + } else + log(Error) << "Not a ros package: " << "<%= typekit.name %>" << endlog(); + } catch(...) { + log(Error) << "Not a ros package: " << "<%= typekit.name %>" << endlog(); + } +#endif try { m_registry = Typelib::PluginManager::load("tlb", TYPEKIT_REGISTRY); } -- 1.7.0.4