From 903f157785658450c42a624163c8a1e7acc375ba Mon Sep 17 00:00:00 2001 From: Stephen Roderick Date: Mon, 29 Mar 2010 16:46:32 -0400 Subject: [PATCH] cmake: Add toolkit component support to CMake config file --- KDLConfig.cmake.in | 40 +++++++++++++++++++++++++++++++++++----- 1 files changed, 35 insertions(+), 5 deletions(-) diff --git a/KDLConfig.cmake.in b/KDLConfig.cmake.in index ee51c3f..26b854d 100644 --- a/KDLConfig.cmake.in +++ b/KDLConfig.cmake.in @@ -8,13 +8,16 @@ INCLUDE (FindPkgConfig) IF ( PKG_CONFIG_FOUND ) + # set flag for whether items are required or not + SET(IS_REQUIRED) + IF (Orocos-KDL_FIND_REQUIRED) + SET(IS_REQUIRED "REQUIRED") + ENDIF (Orocos-KDL_FIND_REQUIRED) + + # find KDL itself set(ENV{PKG_CONFIG_PATH} "@CMAKE_INSTALL_PREFIX@/lib/pkgconfig/") message( "Looking for KDL in: @CMAKE_INSTALL_PREFIX@") - if(Orocos-KDL_FIND_REQUIRED) - pkg_search_module(KDL REQUIRED orocos-kdl) - else(Orocos-KDL_FIND_REQUIRED) - pkg_search_module(KDL orocos-kdl) - endif(Orocos-KDL_FIND_REQUIRED) + pkg_search_module(KDL ${IS_REQUIRED} orocos-kdl) IF( KDL_FOUND ) IF(NOT Orocos-KDL_FIND_QUIETLY) @@ -25,6 +28,33 @@ IF ( PKG_CONFIG_FOUND ) message(" Linker flags : ${KDL_LD_FLAGS}") message(" Defines: ${KDL_DEFINES}") ENDIF(NOT Orocos-KDL_FIND_QUIETLY) + + # find requested components (if any) + foreach (COMPONENT ${Orocos-KDL_FIND_COMPONENTS}) + string(TOUPPER ${COMPONENT} UCOMPONENT) + + # we only handle toolkits (for now) + if (${COMPONENT} MATCHES "kdltk.*") + + # ensure we have any required variables + IF (NOT OROCOS_TARGET) + MESSAGE(FATAL_ERROR "For toolkit support you must set OROCOS_TARGET (e.g. gnulinux, macosx, lxrt)") + ENDIF (NOT OROCOS_TARGET) + + # variable names for this component (eg "KDLTK") + SET(COMP_PREFIX "${UCOMPONENT}") + + # module name to search for (eg "orocos-kdltk-gnulinux") + string(TOLOWER "orocos-${COMPONENT}-${OROCOS_TARGET}" COMP_MODULE) + + pkg_search_module(${COMP_PREFIX} ${IS_REQUIRED} ${COMP_MODULE}) + + else (${COMPONENT} MATCHES "kdltk.*") + MESSAGE(FATAL_ERROR "Unsupported component '${COMPONENT}'") + endif (${COMPONENT} MATCHES "kdltk.*") + + endforeach (COMPONENT ${Orocos-KDL_FIND_COMPONENTS}) + ELSE(KDL_FOUND) IF(Orocos-KDL_FIND_REQUIRED) MESSAGE(FATAL_ERROR "Could not find KDL") -- 1.7.0.2