From 8261ee3a9c641d8e3843bfc0751a9bc49409e0f2 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 10 Feb 2020 09:06:33 -0500 Subject: 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 --- Modules/FindMPI.cmake | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index cb52056..97b050e 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -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}) -- cgit v0.12