949600
commit a22eeca3fd7fe022e06001428d5e903913467fa0
949600
Author: Brad King <brad.king@kitware.com>
949600
Date:   Fri Feb 7 16:45:10 2014 -0500
949600
949600
    FindBoost: Search next to MPI libraries for boost_mpi (#14739)
949600
    
949600
    Some distributions place boost_mpi next to the MPI libraries against
949600
    which it was built instead of next to the other Boost libraries.  If
949600
    find_package(MPI) has already been run prior to find_package(Boost) then
949600
    MPI_CXX_LIBRARIES or MPI_C_LIBRARIES may be set to the location of the
949600
    MPI libraries.  Teach FindBoost.cmake to look there for boost_mpi and
949600
    boost_mpi_python after looking next to the other Boost libraries but
949600
    not consider the location to be Boost_LIBRARY_DIR.
949600
949600
diff -Nrup a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
949600
--- a/Modules/FindBoost.cmake	2014-01-16 12:15:08.000000000 -0500
949600
+++ b/Modules/FindBoost.cmake	2016-03-02 16:10:18.252811225 -0500
949600
@@ -279,10 +279,15 @@ endmacro()
949600
 macro(_Boost_FIND_LIBRARY var)
949600
   find_library(${var} ${ARGN})
949600
 
949600
-  # If we found the first library save Boost_LIBRARY_DIR.
949600
-  if(${var} AND NOT Boost_LIBRARY_DIR)
949600
-    get_filename_component(_dir "${${var}}" PATH)
949600
-    set(Boost_LIBRARY_DIR "${_dir}" CACHE PATH "Boost library directory" FORCE)
949600
+  if(${var})
949600
+    # If this is the first library found then save Boost_LIBRARY_DIR.
949600
+    if(NOT Boost_LIBRARY_DIR)
949600
+      get_filename_component(_dir "${${var}}" PATH)
949600
+      set(Boost_LIBRARY_DIR "${_dir}" CACHE PATH "Boost library directory" FORCE)
949600
+    endif()
949600
+  elseif(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
949600
+    # Try component-specific hints but do not save Boost_LIBRARY_DIR.
949600
+    find_library(${var} HINTS ${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT} ${ARGN})
949600
   endif()
949600
 
949600
   # If Boost_LIBRARY_DIR is known then search only there.
949600
@@ -906,6 +911,28 @@ foreach(COMPONENT ${Boost_FIND_COMPONENT
949600
   set( _boost_docstring_release "Boost ${COMPONENT} library (release)")
949600
   set( _boost_docstring_debug   "Boost ${COMPONENT} library (debug)")
949600
 
949600
+  # Compute component-specific hints.
949600
+  set(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT "")
949600
+  if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python")
949600
+    foreach(lib ${MPI_CXX_LIBRARIES} ${MPI_C_LIBRARIES})
949600
+      if(IS_ABSOLUTE "${lib}")
949600
+        get_filename_component(libdir "${lib}" PATH)
949600
+        string(REPLACE "\\" "/" libdir "${libdir}")
949600
+        list(APPEND _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT ${libdir})
949600
+      endif()
949600
+    endforeach()
949600
+  endif()
949600
+
949600
+  # Consolidate and report component-specific hints.
949600
+  if(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
949600
+    list(REMOVE_DUPLICATES _Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT)
949600
+    if(Boost_DEBUG)
949600
+      message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
949600
+        "Component-specific library search paths for ${COMPONENT}: "
949600
+        "${_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT}")
949600
+    endif()
949600
+  endif()
949600
+
949600
   #
949600
   # Find RELEASE libraries
949600
   #