Skip to content

Commit

Permalink
let templates use the orocos cmake macros
Browse files Browse the repository at this point in the history
Signed-off-by: Ruben Smits <[email protected]>
  • Loading branch information
Ruben Smits committed Dec 19, 2013
1 parent 227b2a9 commit e6c2b91
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 74 deletions.
27 changes: 7 additions & 20 deletions lib/orogen/templates/typekit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ project("<%= typekit.name %>-typekit")
cmake_minimum_required(VERSION 2.6)

SET (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/config")
include(OrogenPkgCheckModules)

# In Orogen components, the build target is specified at generation time
# But we allow to override in case of typegen/USE_OROCOS_RTT:
Expand Down Expand Up @@ -43,8 +44,8 @@ IF ( NOT CMAKE_BUILD_TYPE )
SET( CMAKE_BUILD_TYPE Debug )
ENDIF ( NOT CMAKE_BUILD_TYPE )

include(OrogenPkgCheckModules)
orogen_pkg_check_modules(OrocosRTT REQUIRED "orocos-rtt-${OROCOS_TARGET}>=1.99.4")
find_package(Orocos-RTT 2 REQUIRED)
include(${OROCOS-RTT_USE_FILE})

ADD_CUSTOM_TARGET(<%= typekit.name %>-regen
<% ruby_bin = RbConfig::CONFIG['RUBY_INSTALL_NAME']
Expand All @@ -56,23 +57,13 @@ ADD_CUSTOM_TARGET(<%= typekit.name %>-regen
# END if typekit.standalone?
##

# Manually define '-DIS_ROS_PACKAGE' or include the UseOrocos.cmake file to automatically detect&set this flag.
if ( IS_ROS_PACKAGE )
# When we import a typekit in a ROS package, we expect it to be in the package/lib directory
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${${CMAKE_PROJECT_NAME}_SOURCE_DIR}/lib/orocos${OROCOS_SUFFIX}/types)
endif( IS_ROS_PACKAGE )

execute_process(COMMAND cmake -E create_symlink
${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/<%= typekit.name %>)

include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/types)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})

include_directories(${OrocosRTT_INCLUDE_DIRS})
add_definitions(${OrocosRTT_CFLAGS_OTHER})
link_directories(${OrocosRTT_LIBRARY_DIRS})

<% if typekit.has_opaques_with_templates? %>
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/typekit)
<% end %>
Expand All @@ -90,7 +81,7 @@ string(REPLACE ";" "\" \"" PKG_CFLAGS "\"${PKG_CFLAGS}\"")

# Generate the base typekit shared library
set(libname <%= typekit.name %>-typekit-${OROCOS_TARGET})
add_library(${libname} SHARED
orocos_typekit(${libname}
<%= relatives = []
implementation_files.each do |file|
relatives << typekit.cmake_relative_path(file)
Expand All @@ -100,17 +91,11 @@ add_library(${libname} SHARED
${TOOLKIT_ADDITIONAL_SOURCES})

<%= Generation.cmake_pkgconfig_link_noncorba('${libname}', typekit_deps) %>
target_link_libraries(${libname} ${OrocosRTT_LIBRARIES} ${TYPEKIT_ADDITIONAL_LIBRARIES} ${TOOLKIT_ADDITIONAL_LIBRARIES})
target_link_libraries(${libname} ${TYPEKIT_ADDITIONAL_LIBRARIES} ${TOOLKIT_ADDITIONAL_LIBRARIES})
target_link_libraries(${libname} LINK_INTERFACE_LIBRARIES ${OrocosRTT_LIBRARIES})
if(WITH_RPATH AND APPLE)
set_target_properties( ${libname} PROPERTIES
INSTALL_NAME_DIR "@rpath"
LINK_FLAGS "-Wl,-rpath ${CMAKE_INSTALL_PREFIX}/lib -rpath ${CMAKE_INSTALL_PREFIX}/lib/orocos -rpath ${CMAKE_INSTALL_PREFIX}/lib/orocos${OROCOS_PKG_DIR}/types")
endif()
set(PKG_CONFIG_FILE ${CMAKE_CURRENT_BINARY_DIR}/<%= typekit.name %>-typekit-${OROCOS_TARGET}.pc)
configure_file(<%= typekit.name %>-typekit.pc.in ${PKG_CONFIG_FILE} @ONLY)

install(TARGETS ${libname} LIBRARY DESTINATION lib/orocos${OROCOS_PKG_DIR}/types)
install(FILES
Types.hpp
<% if typekit.has_opaques_with_templates? %>
Expand All @@ -129,8 +114,10 @@ install(FILES
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/<%= (Pathname.new( typekit.base_dir ) + path).relative_path_from(Pathname.new(typekit.automatic_dir)) %>
DESTINATION include/orocos/<%= typekit.name %>/types/<%= typekit.name %>/<%= File.dirname(dest_path) %>)
<% end %>

install(FILES ${PKG_CONFIG_FILE}
DESTINATION lib/pkgconfig)

install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/<%= typekit.name %>.tlb
${CMAKE_CURRENT_SOURCE_DIR}/<%= typekit.name %>.typelist
DESTINATION share/orogen)
Expand Down
28 changes: 8 additions & 20 deletions lib/orogen/templates/typekit/corba/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,13 @@

<% typekit_deps = typekit.plugin('corba').dependencies(typekit); %>

find_package(OrocosCORBA REQUIRED COMPONENTS Typekit)
INCLUDE_DIRECTORIES(${OrocosCORBA_INCLUDE_DIRS})
ADD_DEFINITIONS(${OrocosCORBA_DEFINES})

include_directories(${OrocosCORBA_INCLUDE_DIRS})
add_definitions(${OrocosCORBA_CFLAGS_OTHER})
link_directories(${OrocosCORBA_LIBRARY_DIRS})
find_package(Orocos-RTT 2 REQUIRED)

if(NOT OROCOS-RTT_CORBA_FOUND)
message(FATAL "Could not find Orocos RTT Corba bindings")
endif()
<%= Generation.cmake_pkgconfig_require(typekit_deps, 'corba') %>

# Set up generation of IDL files for CORBA support
IF (NOT OrocosCORBA_Typekit_FOUND)
MESSAGE(FATAL_ERROR "could not find development files for Orocos/CORBA")
ENDIF(NOT OrocosCORBA_Typekit_FOUND)

set(CORBA_FILES ${CMAKE_CURRENT_BINARY_DIR}/<%= typekit.name %>TypesC.cpp)
if(CORBA_IMPLEMENTATION STREQUAL "OMNIORB")
list(APPEND CORBA_FILES ${CMAKE_CURRENT_BINARY_DIR}/<%= typekit.name %>TypesDynSK.cpp)
Expand All @@ -28,30 +20,26 @@ add_custom_command(OUTPUT ${CORBA_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/<%= typekit.name %>Types.idl
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/<%= typekit.name %>Types.idl)

add_definitions(${OrocosCORBA_Typekit_DEFINES})
include_directories(${OrocosCORBA_Typekit_INCLUDE_DIRS})

# Generate the CORBA transport
set(libname_corba <%= typekit.name %>-transport-corba-${OROCOS_TARGET})
add_library(${libname_corba} SHARED
orocos_typekit(${libname_corba}
<%= impl.join("\n ") %>
${CORBA_FILES})
target_link_libraries(${libname_corba}
<%= typekit.name %>-typekit-${OROCOS_TARGET}
${OrocosCORBA_LIBRARIES})
<%= typekit.name %>-typekit-${OROCOS_TARGET} ${OROCOS-RTT_CORBA_LIBRARIES})

if(WITH_RPATH AND APPLE)
set_target_properties( ${libname_corba} PROPERTIES
INSTALL_NAME_DIR "@rpath"
LINK_FLAGS "-Wl,-rpath ${CMAKE_INSTALL_PREFIX}/lib -rpath ${CMAKE_INSTALL_PREFIX}/lib/orocos -rpath ${CMAKE_INSTALL_PREFIX}/lib/orocos${OROCOS_PKG_DIR}/types")
endif()

<%= Generation.cmake_pkgconfig_link('corba', '${libname_corba}', typekit_deps) %>
target_link_libraries(${libname_corba} LINK_INTERFACE_LIBRARIES ${OrocosCORBA_LIBRARIES})
target_link_libraries(${libname_corba} LINK_INTERFACE_LIBRARIES ${OROCOS-RTT_CORBA_LIBRARIES})

SET(PKG_CONFIG_FILE_CORBA ${CMAKE_CURRENT_BINARY_DIR}/<%= typekit.name %>-transport-corba-${OROCOS_TARGET}.pc)
CONFIGURE_FILE(<%= typekit.name %>-transport-corba.pc.in ${PKG_CONFIG_FILE_CORBA} @ONLY)

install(TARGETS ${libname_corba} LIBRARY DESTINATION lib/orocos${OROCOS_PKG_DIR}/types)
install(FILES ${PKG_CONFIG_FILE_CORBA} DESTINATION lib/pkgconfig)
install(FILES
<%= headers.join("\n ") %>
Expand Down
39 changes: 5 additions & 34 deletions lib/orogen/templates/typekit/typelib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,29 @@ cmake_policy(VERSION 2.6)

<% typekit_deps = typekit.plugin('typelib').dependencies(typekit); %>
<%= Generation.cmake_pkgconfig_require(typekit_deps, 'typelib') %>

orogen_pkg_check_modules(TYPELIB REQUIRED typelib)
include_directories(${TYPELIB_INCLUDE_DIRS})
link_directories(${TYPELIB_LIBRARY_DIRS})

orogen_pkg_check_modules(RTT_Typelib REQUIRED rtt_typelib-${OROCOS_TARGET})
include_directories(${RTT_Typelib_INCLUDE_DIRS})
link_directories(${RTT_Typelib_LIBRARY_DIRS})
orocos_find_package(rtt_typelib REQUIRED)
include_directories(${rtt_typelib_INCLUDE_DIRS})
link_directories(${rtt_typelib_LIBRARY_DIRS})

set(TYPEKIT_REGISTRY ${CMAKE_INSTALL_PREFIX}/share/orogen/<%= typekit.name %>.tlb)
add_definitions(-DTYPEKIT_REGISTRY="${TYPEKIT_REGISTRY}")
set(libname_typelib <%= typekit.name %>-transport-typelib-${OROCOS_TARGET})
add_library(${libname_typelib} SHARED
orocos_typekit(${libname_typelib}
<%= impl.join("\n ") %>)

target_link_libraries(${libname_typelib}
${TYPELIB_LIBRARIES}
${OrocosRTT_LIBRARIES}
${RTT_Typelib_LIBRARIES}
${rtt_typelib_LIBRARIES}
<% if !typekit.opaques.empty? %>
<%= typekit.name %>-typekit-${OROCOS_TARGET}
<% end %>)

<%= Generation.cmake_pkgconfig_link('typelib', '${libname_typelib}', typekit_deps) %>

# rospack support: if we're a ROS package, use rospack to return the location of our .tlb file.
if ( IS_ROS_PACKAGE )
set(ROS_ROOT $ENV{ROS_ROOT})
# Catkin style of fetching ROS deps
FIND_PACKAGE( ROS QUIET COMPONENTS roslib )

IF(NOT ROS_FOUND) # pre-Fuerte or Groovy
# TODO: This block to get roslib is deprecated as of ROS Fuerte, but is left in for pre-Fuerte compatibility
set(roslib_PACKAGE_PATH ${ROS_ROOT}/core/roslib) ### XXX hardcoded
message("Falling back to roslib in: ${roslib_PACKAGE_PATH}")
find_library(ROS_LIBRARIES roslib ${roslib_PACKAGE_PATH}/lib )
if ( NOT ROS_LIBRARIES )
find_package( ROS COMPONENTS roslib ) # Yells at user (non-QUIET !)
else()
set(ROS_FOUND TRUE)
set(ROS_INCLUDE_DIRS ${roslib_PACKAGE_PATH}/include)
endif()
ENDIF(NOT ROS_FOUND)

IF(ROS_FOUND)
include_directories( ${ROS_INCLUDE_DIRS} )
add_definitions( -DHAS_ROSLIB )
target_link_libraries( ${libname_typelib} ${ROS_LIBRARIES} )
ENDIF(ROS_FOUND)

endif( IS_ROS_PACKAGE )

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)

Expand Down

0 comments on commit e6c2b91

Please sign in to comment.