summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Pfeiffer <cpfeiffer@live.de>2018-01-25 15:43:13 (GMT)
committerChristian Pfeiffer <cpfeiffer@live.de>2018-01-30 17:23:45 (GMT)
commite7c0298d5c53471ffd21dac695ce5795affddfe8 (patch)
tree57a15da2caca1e6803441ca146bb420723bd8314
parent8cddc89926edaf9d87c1b763749af337d30fed5f (diff)
downloadCMake-e7c0298d5c53471ffd21dac695ce5795affddfe8.zip
CMake-e7c0298d5c53471ffd21dac695ce5795affddfe8.tar.gz
CMake-e7c0298d5c53471ffd21dac695ce5795affddfe8.tar.bz2
FindMPI: Retain unused link paths
If our ``find_library`` step hasn't used a particular link directory at all, it's best to retain it in order to prevent issues from secondary dependencies not being found.
-rw-r--r--Modules/FindMPI.cmake24
1 files changed, 18 insertions, 6 deletions
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 891446e..c644815 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -606,12 +606,7 @@ function (_MPI_interrogate_compiler LANG)
foreach(_MPI_LIB_NAME IN LISTS MPI_LIBNAMES)
string(REGEX REPLACE "^ ?${CMAKE_LINK_LIBRARY_FLAG}" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}")
string(REPLACE "\"" "" _MPI_LIB_NAME "${_MPI_LIB_NAME}")
- get_filename_component(_MPI_LIB_PATH "${_MPI_LIB_NAME}" DIRECTORY)
- if(NOT "${_MPI_LIB_PATH}" STREQUAL "")
- list(APPEND MPI_LIB_FULLPATHS_WORK "${_MPI_LIB_NAME}")
- else()
- list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}")
- endif()
+ list(APPEND MPI_LIB_NAMES_WORK "${_MPI_LIB_NAME}")
endforeach()
endif()
@@ -641,6 +636,9 @@ function (_MPI_interrogate_compiler LANG)
endif()
endforeach()
+ # Save the explicitly given link directories
+ set(MPI_LINK_DIRECTORIES_LEFTOVER "${MPI_LINK_DIRECTORIES_WORK}")
+
# An MPI compiler wrapper could have its MPI libraries in the implictly
# linked directories of the compiler itself.
if(DEFINED CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES)
@@ -659,6 +657,20 @@ function (_MPI_interrogate_compiler LANG)
DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI"
)
mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY)
+ # Remove the directory from the remainder list.
+ if(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY)
+ get_filename_component(_MPI_TAKEN_DIRECTORY "${MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY}" DIRECTORY)
+ list(REMOVE_ITEM MPI_LINK_DIRECTORIES_LEFTOVER "${_MPI_TAKEN_DIRECTORY}")
+ endif()
+ endforeach()
+
+ # Add the link directories given explicitly that we haven't used back as linker directories.
+ foreach(_MPI_LINK_DIRECTORY IN LISTS MPI_LINK_DIRECTORIES_LEFTOVER)
+ if(MPI_LINK_FLAGS_WORK)
+ string(APPEND MPI_LINK_FLAGS_WORK " ${CMAKE_LIBRARY_PATH_FLAG}${_MPI_LINK_DIRECTORY}")
+ else()
+ set(MPI_LINK_FLAGS_WORK "${CMAKE_LIBRARY_PATH_FLAG}${_MPI_LINK_DIRECTORY}")
+ endif()
endforeach()
# Deal with the libraries given with full path next