[Bug 843] New: Boost library selection fails on Mac OSX

http://bugs.orocos.org/show_bug.cgi?id=843

Summary: Boost library selection fails on Mac OSX
Product: Toolchain
Version: master
Platform: All
OS/Version: Mac OS X
Status: NEW
Severity: enhancement
Priority: P3
Component: RTT
AssignedTo: orocos-dev [..] ...
ReportedBy: ruben [dot] smits [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

Hi,

when trying to build RTT on Mac OSX I bumped into the following problem:

-- CMAKE_VERSION: 2.8.4
Boost found in /opt/local/include
-- Could NOT find Xerces (missing: XERCES_C_LIBRARY XERCES_INCLUDE_DIR)
Orocos target is macosx
CMake Error at config/check_depend.cmake:36 (MESSAGE):
Found multiple libraries for Boost_THREAD_LIBRARY, but not one specific to
the current build type 'RELWITHDEBINFO'. Libraries are:

optimized;/opt/local/lib/libboost_thread-mt.dylib;debug;/opt/local/lib/libboost_thread-mt.dylib
Call Stack (most recent call first):
config/check_depend.cmake:223 (SELECT_ONE_LIBRARY_FOR_PKGCONFIG)
CMakeLists.txt:103 (INCLUDE)

How can I tell cmake to take one of the available libraries (At this point I
don't care which one.)

--Ruben

[Bug 843] Boost library selection fails on Mac OSX

http://bugs.orocos.org/show_bug.cgi?id=843

--- Comment #1 from Peter Soetens <peter [..] ...> 2011-03-15 11:59:45 CET ---
(In reply to comment #0)
> Hi,
>
> when trying to build RTT on Mac OSX I bumped into the following problem:
>
> -- CMAKE_VERSION: 2.8.4
> Boost found in /opt/local/include
> -- Could NOT find Xerces (missing: XERCES_C_LIBRARY XERCES_INCLUDE_DIR)
> Orocos target is macosx
> CMake Error at config/check_depend.cmake:36 (MESSAGE):
> Found multiple libraries for Boost_THREAD_LIBRARY, but not one specific to
> the current build type 'RELWITHDEBINFO'. Libraries are:
>
> optimized;/opt/local/lib/libboost_thread-mt.dylib;debug;/opt/local/lib/libboost_thread-mt.dylib
> Call Stack (most recent call first):
> config/check_depend.cmake:223 (SELECT_ONE_LIBRARY_FOR_PKGCONFIG)
> CMakeLists.txt:103 (INCLUDE)
>
>
> How can I tell cmake to take one of the available libraries (At this point I
> don't care which one.)
>
> --Ruben

The macro causing this is in the config/check_depend.cmake file of RTT:

# Select one library from a list of libraries
#
# Commonly used when dealing with Boost_XXX_LIBRARY values, which typically
# encode "optimized" and "debug" versions of the libraries. CMake can deal
# with these lists, however, we can't pass that list to pkgconfig as it will
# write it directly to file, and then when it reads it in in the dependant
# package _then_ pkgconfig gets confused and errors out.
#
# As _libraries may be a list of libraries, and we can't deal
# with that in pkgconfig, we take 1) the library for this build type, or
# 2) the library if only one is listed, or 3) we error out.
#
# _library is the name of the library variable (e.g. Boost_THREAD_LIBRARY)
# _output is the selected library
#
MACRO(SELECT_ONE_LIBRARY_FOR_PKGCONFIG _library _output)

STRING(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UPPER)
if (DEFINED ${_library}_${CMAKE_BUILD_TYPE_UPPER})
SET(${_output} ${${_library}_${CMAKE_BUILD_TYPE_UPPER}})
else (DEFINED ${_library}_${CMAKE_BUILD_TYPE_UPPER})
LIST(LENGTH ${_library} count)
if (1 LESS count)
MESSAGE(FATAL_ERROR "Found multiple libraries for ${_library}, but not
one specific to the current build type '${CMAKE_BUILD_TYPE_UPPER}'. Libraries
are: ${${_library}}")
endif (1 LESS count)
SET(${_output} ${${_library}})
endif (DEFINED ${_library}_${CMAKE_BUILD_TYPE_UPPER})

ENDMACRO(SELECT_ONE_LIBRARY_FOR_PKGCONFIG)

I would fall back to optimized instead of erroring out. Ironically, both
optimized and debug point to the same dylib :-)

Peter