From a1abc5ca2d8feb3f030f28ba34f8932158de31a1 Mon Sep 17 00:00:00 2001 From: Markus Blatt <markus@dr-blatt.de> Date: Tue, 9 Jul 2013 16:19:28 +0200 Subject: [PATCH] [CMake] Stops linking Boost_LIBRARIES by default (Fixes FS#1312) Previously, when adding boost flags, we always linked all Boost_LIBRARIES. At least for the core modules this not needed and resulted in errors on some systems. This patch changes the add_dune_boost_flags function. By default no libraries are linked, but one can either provide the libraries using the LIBRARIES option or request linkage of all boost libraries with the LINK_ALL_BOOST_LIBRARIES option. --- cmake/modules/DuneBoost.cmake | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cmake/modules/DuneBoost.cmake b/cmake/modules/DuneBoost.cmake index 636dda326..8e5bf9760 100644 --- a/cmake/modules/DuneBoost.cmake +++ b/cmake/modules/DuneBoost.cmake @@ -1,17 +1,27 @@ # Searches for boost and provides the following function: # -# add_dune_boost_flags(targets) +# add_dune_boost_flags(targets [LINK_ALL_BOOST_LIBRARIES] +# LIBRARIES lib1 lib2 ...) # # Adds boost compiler flags and libraries, and activates -# Boost for the specified targets. +# Boost for the specified targets. Libraries can either be +# provided by listing them after the LIBRARIES keyword or one +# can request linking with all available boost libraries by +# passing the LINK_ALL_BOOST_LIBRARIES option to the function +# call. find_package(Boost) set(HAVE_DUNE_BOOST ${Boost_FOUND}) function(add_dune_boost_flags _targets) + cmake_parse_arguments(DUNE_BOOST LINK_ALL_BOOST_LIBRARIES "" LIBRARIES ${ARGN}) if(Boost_FOUND) include_directories("${Boost_INCLUDE_DIRS}") foreach(_target ${_targets}) - target_link_libraries(${_target} ${Boost_LIBRARIES}) + if(DUNE_BOOST_LINK_ALL_BOOST_LIBRARIES) + target_link_libraries(${_target} "${DUNE_Boost_LIBRARIES}") + else(DUNE_BOOST_LINK_ALL_BOOST_LIBRARIES) + target_link_libraries(${_target} "${DUNE_BOOST_LIBRARIES}") + endif(DUNE_BOOST_LINK_ALL_BOOST_LIBRARIES) # The definitions are a hack as we do not seem to know which MPI implementation was # found. GET_TARGET_PROPERTY(_props ${_target} COMPILE_FLAGS) -- GitLab