FindMPI: Restore re-construction of include directories

The fix in commit 5861c6d450 (FindMPI: Preserve include order when
extracting component directories, 2019-12-19) only works on the first
run of CMake in which we find MPI.  It preserves the include directories
on the first run but still splits them up and saves the pieces in the
cache.  On future runs the pieces are not re-assembled, and we do not
know the order anyway.

Restore the re-assembly step so that at least all the include dirs are
available.  Leave preservation of the original order to later work.

Issue: #20338
This commit is contained in:
Brad King 2020-02-10 09:06:33 -05:00
parent fbd20759be
commit 8261ee3a9c

View File

@ -1059,6 +1059,24 @@ macro(_MPI_assemble_libraries LANG)
endif()
endmacro()
macro(_MPI_assemble_include_dirs LANG)
if("${LANG}" MATCHES "(C|CXX)")
if(MPI_${LANG}_HEADER_DIR)
list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}")
endif()
else() # Fortran
if(MPI_${LANG}_F77_HEADER_DIR)
list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_F77_HEADER_DIR}")
endif()
if(MPI_${LANG}_MODULE_DIR)
list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}")
endif()
endif()
if(MPI_${LANG}_INCLUDE_DIRS)
list(REMOVE_DUPLICATES MPI_${LANG}_INCLUDE_DIRS)
endif()
endmacro()
macro(_MPI_split_include_dirs LANG)
# Backwards compatibility: Search INCLUDE_PATH if given.
if(MPI_${LANG}_INCLUDE_PATH)
@ -1474,6 +1492,9 @@ foreach(LANG IN ITEMS C CXX Fortran)
if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
_MPI_split_include_dirs(${LANG})
_MPI_assemble_include_dirs(${LANG})
else()
set(MPI_${LANG}_INCLUDE_DIRS "")
endif()
_MPI_assemble_libraries(${LANG})