summaryrefslogtreecommitdiff
path: root/Modules/FindMPI.cmake
diff options
context:
space:
mode:
authorChuck Atkins <chuck.atkins@kitware.com>2019-12-19 12:18:48 -0500
committerBrad King <brad.king@kitware.com>2020-01-10 14:13:44 -0500
commit5861c6d450937a38cd3c5ab9aa878427a50b069d (patch)
tree1ecfbcba92505611ba537d9a6d72b572678e402f /Modules/FindMPI.cmake
parent5ba141e5ff99eddf5c959724a251b0b7a1b3f8e8 (diff)
downloadcmake-5861c6d450937a38cd3c5ab9aa878427a50b069d.tar.gz
FindMPI: Preserve include order when extracting component directories
Fixes: #20098
Diffstat (limited to 'Modules/FindMPI.cmake')
-rw-r--r--Modules/FindMPI.cmake36
1 files changed, 8 insertions, 28 deletions
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 6b1da4b03c..d1257c945b 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -1059,32 +1059,7 @@ macro(_MPI_assemble_libraries LANG)
endif()
endmacro()
-macro(_MPI_assemble_include_dirs LANG)
- if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
- set(MPI_${LANG}_INCLUDE_DIRS "")
- else()
- set(MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS}")
- 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 AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS)
- list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}")
- endif()
- endif()
- if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
- foreach(MPI_ADDITIONAL_INC_DIR IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
- list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${MPI_ADDITIONAL_INC_DIR}_INCLUDE_DIR}")
- endforeach()
- endif()
- endif()
-endmacro()
-
-function(_MPI_split_include_dirs LANG)
+macro(_MPI_split_include_dirs LANG)
if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
return()
endif()
@@ -1093,6 +1068,9 @@ function(_MPI_split_include_dirs LANG)
list(APPEND MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_INCLUDE_PATH}")
endif()
+ # Preserve the include dirs before stripping out the components
+ set(MPI_${LANG}_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS})
+
# We try to find the headers/modules among those paths (and system paths)
# For C/C++, we just need to have a look for mpi.h.
if("${LANG}" MATCHES "(C|CXX)")
@@ -1103,6 +1081,7 @@ function(_MPI_split_include_dirs LANG)
if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_HEADER_DIR}")
endif()
+
# Fortran is more complicated here: An implementation could provide
# any of the Fortran 77/90/2008 APIs for MPI. For example, MSMPI
# only provides Fortran 77 and - if mpi.f90 is built - potentially
@@ -1123,6 +1102,7 @@ function(_MPI_split_include_dirs LANG)
endif()
mark_as_advanced(MPI_${LANG}_F77_HEADER_DIR MPI_${LANG}_MODULE_DIR)
endif()
+
# Remove duplicates and default system directories from the list.
if(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
list(REMOVE_DUPLICATES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)
@@ -1130,8 +1110,9 @@ function(_MPI_split_include_dirs LANG)
list(REMOVE_ITEM MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_IMPLICIT_INC_DIR})
endforeach()
endif()
+
set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories" FORCE)
-endfunction()
+endmacro()
macro(_MPI_create_imported_target LANG)
if(NOT TARGET MPI::MPI_${LANG})
@@ -1495,7 +1476,6 @@ foreach(LANG IN ITEMS C CXX Fortran)
endif()
_MPI_split_include_dirs(${LANG})
- _MPI_assemble_include_dirs(${LANG})
_MPI_assemble_libraries(${LANG})
_MPI_adjust_compile_definitions(${LANG})