diff options
author | Brad King <brad.king@kitware.com> | 2020-01-13 15:32:11 +0000 |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-01-13 10:32:42 -0500 |
commit | 320ad3f31f7184e82e6fe38afa69d0066d796788 (patch) | |
tree | 3efe71be401316d9b95630dbb0d73330a3759ba2 | |
parent | 1631db97ec3fd82483bf13c06cd980d2b78acd26 (diff) | |
parent | 5861c6d450937a38cd3c5ab9aa878427a50b069d (diff) | |
download | cmake-320ad3f31f7184e82e6fe38afa69d0066d796788.tar.gz |
Merge topic 'findmpi-preserve-include-order'
5861c6d450 FindMPI: Preserve include order when extracting component directories
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4153
-rw-r--r-- | Modules/FindMPI.cmake | 36 |
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}) |