From 56cc34e0e0637f5b17a3b924b5e1f5473fb14914 Mon Sep 17 00:00:00 2001 Message-Id: <56cc34e0e0637f5b17a3b924b5e1f5473fb14914.1392046753.git.brad.king@kitware.com> From: Brad King Date: Fri, 7 Feb 2014 16:45:10 -0500 Subject: [PATCH] FindBoost: Search next to MPI libraries for boost_mpi (#14739) Some distributions place boost_mpi next to the MPI libraries against which it was built instead of next to the other Boost libraries. If find_package(MPI) has already been run prior to find_package(Boost) then MPI_CXX_LIBRARIES or MPI_C_LIBRARIES may be set to the location of the MPI libraries. Teach FindBoost.cmake to look there for boost_mpi after looking next to the other Boost libraries. --- Modules/FindBoost.cmake | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index ae8baab..8dc60b9 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -935,6 +935,28 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) set( _boost_docstring_release "Boost ${COMPONENT} library (release)") set( _boost_docstring_debug "Boost ${COMPONENT} library (debug)") + # Compute component-specific hints. + set(_boost_COMPONENT_LIBRARY_SEARCH_DIRS "") + if(${UPPERCOMPONENT} STREQUAL "MPI") + foreach(lib ${MPI_CXX_LIBRARIES} ${MPI_C_LIBRARIES}) + if(IS_ABSOLUTE "${lib}") + get_filename_component(libdir "${lib}" PATH) + string(REPLACE "\\" "/" libdir "${libdir}") + list(APPEND _boost_COMPONENT_LIBRARY_SEARCH_DIRS ${libdir}) + endif() + endforeach() + endif() + + # Consolidate and report component-specific hints. + if(_boost_COMPONENT_LIBRARY_SEARCH_DIRS) + list(REMOVE_DUPLICATES _boost_COMPONENT_LIBRARY_SEARCH_DIRS) + if(Boost_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "Appending library search paths for ${UPPERCOMPONENT}: " + "${_boost_COMPONENT_LIBRARY_SEARCH_DIRS}") + endif() + endif() + # # Find RELEASE libraries # @@ -966,6 +988,7 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_RELEASE NAMES ${_boost_RELEASE_NAMES} HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp} + HINTS ${_boost_COMPONENT_LIBRARY_SEARCH_DIRS} NAMES_PER_DIR DOC "${_boost_docstring_release}" ) @@ -1002,6 +1025,7 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS}) _Boost_FIND_LIBRARY(Boost_${UPPERCOMPONENT}_LIBRARY_DEBUG NAMES ${_boost_DEBUG_NAMES} HINTS ${_boost_LIBRARY_SEARCH_DIRS_tmp} + HINTS ${_boost_COMPONENT_LIBRARY_SEARCH_DIRS} NAMES_PER_DIR DOC "${_boost_docstring_debug}" ) -- 1.8.5.2