From c56dba7a0cac8529ddc7bbee51a9f9e7f88161a4 Mon Sep 17 00:00:00 2001 From: Stephen Roderick Date: Tue, 20 Jul 2010 11:47:28 -0400 Subject: [PATCH] cmake: Deal with boost-style multiple library lists when adding libraries to components --- config/component_rules.cmake | 30 +++++++++++++++++++++++++++++- 1 files changed, 29 insertions(+), 1 deletions(-) diff --git a/config/component_rules.cmake b/config/component_rules.cmake index e62a603..f23806a 100644 --- a/config/component_rules.cmake +++ b/config/component_rules.cmake @@ -49,12 +49,40 @@ ENDMACRO( GLOBAL_ADD_INCLUDE COMPONENT_LOCATION ) # Link a component library with an external library (qt3, gl, readline,....) # Usage: COMPONENT_ADD_LIBS( orocos-taskbrowser readline ncurses ) +# +# Explicitly deal with library lists of the form "optimized;xxx;debug;xxx-d" +# These lists can be chained e.g. "optimized;xxx;debug;xxx-d;optimized;yyy;debug;yyy-d" +# MACRO( COMPONENT_ADD_LIBS COMPONENT_NAME ) + + UNSET(previous) foreach( lib ${ARGN} ) - TARGET_LINK_LIBRARIES( ${COMPONENT_NAME}-${OROCOS_TARGET} ${lib} ) + if (DEFINED previous) + # assume that previous is either "optimized" or "debug" + # TODO enforce the above assumption + TARGET_LINK_LIBRARIES( ${COMPONENT_NAME}-${OROCOS_TARGET} ${previous} ${lib}) + UNSET(previous) + else (DEFINED previous) + if ("${lib}" STREQUAL "optimized" OR "${lib}" STREQUAL "debug") + # store value for next arg + SET(previous "${lib}") + else ("${lib}" STREQUAL "optimized" OR "${lib}" STREQUAL "debug") + TARGET_LINK_LIBRARIES( ${COMPONENT_NAME}-${OROCOS_TARGET} "${lib}") + endif ("${lib}" STREQUAL "optimized" OR "${lib}" STREQUAL "debug") + endif (DEFINED previous) endforeach( lib ${ARGN} ) + + # TODO check that we don't have a "previous" waiting for a next library + ENDMACRO( COMPONENT_ADD_LIBS COMPONENT_NAME ) +# Link a component library with a list of external libraries (qt3, gl, readline,....) +# Usage: COMPONENT_ADD_LIBS( orocos-taskbrowser ${Boost_FILESYSTEM_LIBRARIES} ) +MACRO( COMPONENT_ADD_LIB_LIST COMPONENT_NAME ) + MESSAGE("ADD_LIB_LIST '${ARGN}'") + TARGET_LINK_LIBRARIES( ${COMPONENT_NAME}-${OROCOS_TARGET} ${ARGN} ) +ENDMACRO( COMPONENT_ADD_LIB_LIST COMPONENT_NAME ) + # Link a component library with another component library # Usage: COMPONENT_ADD_DEPS( orocos-taskbrowser orocos-reporting ) MACRO( COMPONENT_ADD_DEPS COMPONENT_NAME ) -- 1.7.1