summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--config/cmake_ext_mod/FindMPI.cmake287
-rw-r--r--src/CMakeLists.txt12
3 files changed, 171 insertions, 129 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e22ac2e..6165b35 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -631,6 +631,7 @@ if (HDF5_ENABLE_PARALLEL)
# Used by Fortran + MPI
CHECK_SYMBOL_EXISTS (MPI_Comm_c2f "${MPI_C_INCLUDE_DIRS}/mpi.h" H5_HAVE_MPI_MULTI_LANG_Comm)
CHECK_SYMBOL_EXISTS (MPI_Info_c2f "${MPI_C_INCLUDE_DIRS}/mpi.h" H5_HAVE_MPI_MULTI_LANG_Info)
+ INCLUDE_DIRECTORIES (${MPI_C_INCLUDE_DIRS})
else ()
message (STATUS "Parallel libraries not found")
endif ()
diff --git a/config/cmake_ext_mod/FindMPI.cmake b/config/cmake_ext_mod/FindMPI.cmake
index 8084472..d01dd35 100644
--- a/config/cmake_ext_mod/FindMPI.cmake
+++ b/config/cmake_ext_mod/FindMPI.cmake
@@ -347,7 +347,7 @@ function (_MPI_check_compiler LANG QUERY_FLAG OUTPUT_VARIABLE RESULT_VARIABLE)
# library that has invalid or missing version information there would be warning
# messages emitted by ld.so in the compiler output. In either case, we'll treat
# the output as invalid.
- if("${WRAPPER_OUTPUT}" MATCHES "undefined reference|unrecognized|need to set|no version information available")
+ if("${WRAPPER_OUTPUT}" MATCHES "undefined reference|unrecognized|need to set|no version information available|command not found")
set(WRAPPER_RETURN 255)
endif()
# Ensure that no error output might be passed upwards.
@@ -615,6 +615,16 @@ function (_MPI_interrogate_compiler lang)
endif()
endif()
+ if(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS)
+ list(APPEND MPI_COMPILE_DEFINITIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS}")
+ endif()
+ if(MPI_${LANG}_EXTRA_COMPILE_OPTIONS)
+ list(APPEND MPI_COMPILE_OPTIONS_WORK "${MPI_${LANG}_EXTRA_COMPILE_OPTIONS}")
+ endif()
+ if(MPI_${LANG}_EXTRA_LIB_NAMES)
+ list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${MPI_${LANG}_EXTRA_LIB_NAMES}")
+ endif()
+
# If we found MPI, set up all of the appropriate cache entries
if(NOT MPI_${LANG}_COMPILE_OPTIONS)
set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_COMPILE_OPTIONS_WORK} CACHE STRING "MPI ${LANG} compilation options" FORCE)
@@ -823,33 +833,43 @@ endfunction()
macro(_MPI_assemble_libraries LANG)
set(MPI_${LANG}_LIBRARIES "")
- foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES)
- list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY})
- endforeach()
+ # Only for libraries do we need to check whether the compiler's linking stage is separate.
+ if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS_IMPLICIT)
+ foreach(mpilib IN LISTS MPI_${LANG}_LIB_NAMES)
+ list(APPEND MPI_${LANG}_LIBRARIES ${MPI_${mpilib}_LIBRARY})
+ endforeach()
+ endif()
endmacro()
macro(_MPI_assemble_include_dirs LANG)
- 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}")
+ 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}_MODULE_DIR AND NOT "${MPI_${LANG}_MODULE_DIR}" IN_LIST MPI_${LANG}_INCLUDE_DIRS)
- list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${LANG}_MODULE_DIR}")
+ 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()
- if(MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
- foreach(mpiadditionalinclude IN LISTS MPI_${LANG}_ADDITIONAL_INCLUDE_VARS)
- list(APPEND MPI_${LANG}_INCLUDE_DIRS "${MPI_${mpiadditionalinclude}_INCLUDE_DIR}")
- endforeach()
- endif()
endmacro()
function(_MPI_split_include_dirs LANG)
+ if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
+ return()
+ endif()
# Backwards compatibility: Search INCLUDE_PATH if given.
if(MPI_${LANG}_INCLUDE_PATH)
list(APPEND MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "${MPI_${LANG}_INCLUDE_PATH}")
@@ -885,6 +905,13 @@ 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)
+ foreach(MPI_IMPLICIT_INC_DIR IN LISTS CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES)
+ 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()
@@ -1014,7 +1041,7 @@ elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
elseif("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "FreeBSD")
# FreeBSD ships mpich under the normal system paths - but available openmpi implementations
# will be found in /usr/local/mpi/<name>
- MPI_search_mpi_prefix_folder("/usr/local/mpi/")
+ MPI_search_mpi_prefix_folder("/usr/local/mpi")
endif()
# Most MPI distributions have some form of mpiexec or mpirun which gives us something we can look for.
@@ -1050,48 +1077,54 @@ mark_as_advanced(MPIEXEC_EXECUTABLE MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXE
#
# Once we find the new variables, we translate them back into their old
# equivalents below.
-foreach (LANG IN ITEMS C CXX)
- # Old input variables.
- set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS)
-
- # Set new vars based on their old equivalents, if the new versions are not already set.
- foreach (var ${_MPI_OLD_INPUT_VARS})
- if (NOT MPI_${LANG}_${var} AND MPI_${var})
- set(MPI_${LANG}_${var} "${MPI_${var}}")
- endif()
- endforeach()
-
- # Chop the old compile flags into options and definitions
- if(MPI_${LANG}_COMPILE_FLAGS)
- unset(MPI_${LANG}_COMPILE_OPTIONS)
- unset(MPI_${LANG}_COMPILE_DEFINITIONS)
- separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}")
- foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS)
- if("${_MPI_FLAG}" MATCHES "^ *[-/D]([^ ]+)")
- list(APPEND MPI_${LANG}_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}")
- else()
- list(APPEND MPI_${LANG}_COMPILE_FLAGS "${_MPI_FLAG}")
+if(NOT MPI_IGNORE_LEGACY_VARIABLES)
+ foreach (LANG IN ITEMS C CXX)
+ # Old input variables.
+ set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS)
+
+ # Set new vars based on their old equivalents, if the new versions are not already set.
+ foreach (var ${_MPI_OLD_INPUT_VARS})
+ if (NOT MPI_${LANG}_${var} AND MPI_${var})
+ set(MPI_${LANG}_${var} "${MPI_${var}}")
endif()
endforeach()
- unset(MPI_SEPARATE_FLAGS)
- endif()
- # If a list of libraries was given, we'll split it into new-style cache variables
- if(NOT MPI_${LANG}_LIB_NAMES)
- foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY)
- get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE)
- get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME)
- get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY)
- list(APPEND MPI_PLAIN_LIB_NAMES_WORK "${_MPI_PLAIN_LIB_NAME}")
- find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY
- NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}"
- HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB}
- DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI"
- )
- mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY)
- endforeach()
- endif()
-endforeach()
+ # Chop the old compile flags into options and definitions
+
+ unset(MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS)
+ unset(MPI_${LANG}_EXTRA_COMPILE_OPTIONS)
+ if(MPI_${LANG}_COMPILE_FLAGS)
+ separate_arguments(MPI_SEPARATE_FLAGS NATIVE_COMMAND "${MPI_${LANG}_COMPILE_FLAGS}")
+ foreach(_MPI_FLAG IN LISTS MPI_SEPARATE_FLAGS)
+ if("${_MPI_FLAG}" MATCHES "^ *[-/D]([^ ]+)")
+ list(APPEND MPI_${LANG}_EXTRA_COMPILE_DEFINITIONS "${CMAKE_MATCH_1}")
+ else()
+ list(APPEND MPI_${LANG}_EXTRA_COMPILE_OPTIONS "${_MPI_FLAG}")
+ endif()
+ endforeach()
+ unset(MPI_SEPARATE_FLAGS)
+ endif()
+
+ # If a list of libraries was given, we'll split it into new-style cache variables
+ unset(MPI_${LANG}_EXTRA_LIB_NAMES)
+ if(NOT MPI_${LANG}_LIB_NAMES)
+ foreach(_MPI_LIB IN LISTS MPI_${LANG}_LIBRARIES MPI_LIBRARY MPI_EXTRA_LIBRARY)
+ if(_MPI_LIB)
+ get_filename_component(_MPI_PLAIN_LIB_NAME "${_MPI_LIB}" NAME_WE)
+ get_filename_component(_MPI_LIB_NAME "${_MPI_LIB}" NAME)
+ get_filename_component(_MPI_LIB_DIR "${_MPI_LIB}" DIRECTORY)
+ list(APPEND MPI_${LANG}_EXTRA_LIB_NAMES "${_MPI_PLAIN_LIB_NAME}")
+ find_library(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY
+ NAMES "${_MPI_LIB_NAME}" "lib${_MPI_LIB_NAME}"
+ HINTS ${_MPI_LIB_DIR} $ENV{MPI_LIB}
+ DOC "Location of the ${_MPI_PLAIN_LIB_NAME} library for MPI"
+ )
+ mark_as_advanced(MPI_${_MPI_PLAIN_LIB_NAME}_LIBRARY)
+ endif()
+ endforeach()
+ endif()
+ endforeach()
+endif()
#=============================================================================
unset(MPI_VERSION)
@@ -1100,6 +1133,11 @@ unset(MPI_VERSION_MINOR)
unset(_MPI_MIN_VERSION)
+# If the user specified a library name we assume they prefer that library over a wrapper. If not, they can disable skipping manually.
+if(NOT DEFINED MPI_SKIP_COMPILER_WRAPPER AND MPI_GUESS_LIBRARY_NAME)
+ set(MPI_SKIP_COMPILER_WRAPPER TRUE)
+endif()
+
# This loop finds the compilers and sends them off for interrogation.
foreach(LANG IN ITEMS C CXX Fortran)
if(CMAKE_${LANG}_COMPILER_LOADED)
@@ -1121,6 +1159,8 @@ foreach(LANG IN ITEMS C CXX Fortran)
mark_as_advanced(MPI_CXX_SKIP_MPICXX)
endif()
if(NOT (MPI_${LANG}_LIB_NAMES AND (MPI_${LANG}_INCLUDE_PATH OR MPI_${LANG}_INCLUDE_DIRS OR MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS)))
+ set(MPI_${LANG}_TRIED_IMPLICIT FALSE)
+ set(MPI_${LANG}_WORKS_IMPLICIT FALSE)
if(NOT MPI_${LANG}_COMPILER AND NOT MPI_ASSUME_NO_BUILTIN_MPI)
# Should the imported targets be empty, we effectively try whether the compiler supports MPI on its own, which is the case on e.g.
# Cray PrgEnv.
@@ -1130,80 +1170,90 @@ foreach(LANG IN ITEMS C CXX Fortran)
# If the compiler can build MPI code on its own, it functions as an MPI compiler and we'll set the variable to point to it.
if(MPI_${LANG}_WORKS)
set(MPI_${LANG}_COMPILER "${CMAKE_${LANG}_COMPILER}" CACHE FILEPATH "MPI compiler for ${LANG}" FORCE)
+ set(MPI_${LANG}_WORKS_IMPLICIT TRUE)
endif()
+ set(MPI_${LANG}_TRIED_IMPLICIT TRUE)
endif()
- # If the user specified a library name we assume they prefer that library over a wrapper. If not, they can disable skipping manually.
- if(NOT DEFINED MPI_SKIP_COMPILER_WRAPPER AND MPI_GUESS_LIBRARY_NAME)
- set(MPI_SKIP_COMPILER_WRAPPER TRUE)
- endif()
- if(NOT MPI_SKIP_COMPILER_WRAPPER)
- if(MPI_${LANG}_COMPILER)
- # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler.
- if (NOT IS_ABSOLUTE "${MPI_${LANG}_COMPILER}")
- # Get rid of our default list of names and just search for the name the user wants.
- set(_MPI_${LANG}_COMPILER_NAMES "${MPI_${LANG}_COMPILER}")
- unset(MPI_${LANG}_COMPILER CACHE)
+ if(NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}" OR NOT MPI_${LANG}_WORKS)
+ set(MPI_${LANG}_WRAPPER_FOUND FALSE)
+ set(MPI_PINNED_COMPILER FALSE)
+
+ if(NOT MPI_SKIP_COMPILER_WRAPPER)
+ if(MPI_${LANG}_COMPILER)
+ # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler.
+ if (NOT IS_ABSOLUTE "${MPI_${LANG}_COMPILER}")
+ # Get rid of our default list of names and just search for the name the user wants.
+ set(_MPI_${LANG}_COMPILER_NAMES "${MPI_${LANG}_COMPILER}")
+ unset(MPI_${LANG}_COMPILER CACHE)
+ endif()
+ # If the user specifies a compiler, we don't want to try to search libraries either.
+ set(MPI_PINNED_COMPILER TRUE)
+ endif()
+
+ # If we have an MPI base directory, we'll try all compiler names in that one first.
+ # This should prevent mixing different MPI environments
+ if(_MPI_BASE_DIR)
+ find_program(MPI_${LANG}_COMPILER
+ NAMES ${_MPI_${LANG}_COMPILER_NAMES}
+ PATH_SUFFIXES bin sbin
+ HINTS ${_MPI_BASE_DIR}
+ NO_DEFAULT_PATH
+ DOC "MPI compiler for ${LANG}"
+ )
endif()
- # If the user specifies a compiler, we don't want to try to search libraries either.
- set(MPI_PINNED_COMPILER TRUE)
- else()
- set(MPI_PINNED_COMPILER FALSE)
- endif()
- # If we have an MPI base directory, we'll try all compiler names in that one first.
- # This should prevent mixing different MPI environments
- if(_MPI_BASE_DIR)
+ # If the base directory did not help (for example because the mpiexec isn't in the same directory as the compilers),
+ # we shall try searching in the default paths.
find_program(MPI_${LANG}_COMPILER
NAMES ${_MPI_${LANG}_COMPILER_NAMES}
PATH_SUFFIXES bin sbin
- HINTS ${_MPI_BASE_DIR}
- NO_DEFAULT_PATH
DOC "MPI compiler for ${LANG}"
)
- endif()
- # If the base directory did not help (for example because the mpiexec isn't in the same directory as the compilers),
- # we shall try searching in the default paths.
- find_program(MPI_${LANG}_COMPILER
- NAMES ${_MPI_${LANG}_COMPILER_NAMES}
- PATH_SUFFIXES bin sbin
- DOC "MPI compiler for ${LANG}"
- )
-
- if(MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER)
- set(MPI_SKIP_GUESSING TRUE)
- elseif(MPI_${LANG}_COMPILER)
- _MPI_interrogate_compiler(${LANG})
- else()
- set(MPI_${LANG}_WRAPPER_FOUND FALSE)
+ if("${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
+ set(MPI_PINNED_COMPILER TRUE)
+
+ # If we haven't made the implicit compiler test yet, perform it now.
+ if(NOT MPI_${LANG}_TRIED_IMPLICIT)
+ _MPI_create_imported_target(${LANG})
+ _MPI_check_lang_works(${LANG})
+ endif()
+
+ # Should the MPI compiler not work implicitly for MPI, still interrogate it.
+ # Otherwise, MPI compilers for which CMake has separate linking stages, e.g. Intel MPI on Windows where link.exe is being used
+ # directly during linkage instead of CMAKE_<LANG>_COMPILER will not work.
+ if(NOT MPI_${LANG}_WORKS)
+ set(MPI_${LANG}_WORKS_IMPLICIT FALSE)
+ _MPI_interrogate_compiler(${LANG})
+ else()
+ set(MPI_${LANG}_WORKS_IMPLICIT TRUE)
+ endif()
+ elseif(MPI_${LANG}_COMPILER)
+ _MPI_interrogate_compiler(${LANG})
+ endif()
endif()
- else()
- set(MPI_${LANG}_WRAPPER_FOUND FALSE)
- set(MPI_PINNED_COMPILER FALSE)
- endif()
- if(NOT MPI_${LANG}_WRAPPER_FOUND AND NOT MPI_PINNED_COMPILER)
- # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the
- # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI.
- if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND)
- set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" )
- set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" )
- set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories")
- set(MPI_${LANG}_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING "MPI ${LANG} linker flags" )
- set(MPI_${LANG}_LIB_NAMES ${MPI_C_LIB_NAMES} CACHE STRING "MPI ${LANG} libraries to link against" )
- set(MPI_${LANG}_WRAPPER_FOUND TRUE)
- elseif(NOT MPI_SKIP_GUESSING)
- _MPI_guess_settings(${LANG})
+ if(NOT MPI_SKIP_GUESSING AND NOT MPI_${LANG}_WRAPPER_FOUND AND NOT MPI_PINNED_COMPILER)
+ # For C++, we may use the settings for C. Should a given compiler wrapper for C++ not exist, but one for C does, we copy over the
+ # settings for C. An MPI distribution that is in this situation would be IBM Platform MPI.
+ if("${LANG}" STREQUAL "CXX" AND MPI_C_WRAPPER_FOUND)
+ set(MPI_${LANG}_COMPILE_OPTIONS ${MPI_C_COMPILE_OPTIONS} CACHE STRING "MPI ${LANG} compilation options" )
+ set(MPI_${LANG}_COMPILE_DEFINITIONS ${MPI_C_COMPILE_DEFINITIONS} CACHE STRING "MPI ${LANG} compilation definitions" )
+ set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS ${MPI_C_INCLUDE_DIRS} CACHE STRING "MPI ${LANG} additional include directories")
+ set(MPI_${LANG}_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING "MPI ${LANG} linker flags" )
+ set(MPI_${LANG}_LIB_NAMES ${MPI_C_LIB_NAMES} CACHE STRING "MPI ${LANG} libraries to link against" )
+ else()
+ _MPI_guess_settings(${LANG})
+ endif()
endif()
endif()
endif()
_MPI_split_include_dirs(${LANG})
- if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER)
- _MPI_assemble_include_dirs(${LANG})
- _MPI_assemble_libraries(${LANG})
- endif()
+ _MPI_assemble_include_dirs(${LANG})
+ _MPI_assemble_libraries(${LANG})
+
_MPI_adjust_compile_definitions(${LANG})
# We always create imported targets even if they're empty
_MPI_create_imported_target(${LANG})
@@ -1217,7 +1267,9 @@ foreach(LANG IN ITEMS C CXX Fortran)
set(MPI_${LANG}_COMPILE_DEFINITIONS "" CACHE STRING "MPI ${LANG} compilation definitions" )
set(MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS "" CACHE STRING "MPI ${LANG} additional include directories")
set(MPI_${LANG}_LINK_FLAGS "" CACHE STRING "MPI ${LANG} linker flags" )
- set(MPI_${LANG}_LIB_NAMES "" CACHE STRING "MPI ${LANG} libraries to link against" )
+ if(NOT MPI_${LANG}_COMPILER STREQUAL CMAKE_${LANG}_COMPILER)
+ set(MPI_${LANG}_LIB_NAMES "" CACHE STRING "MPI ${LANG} libraries to link against" )
+ endif()
mark_as_advanced(MPI_${LANG}_COMPILE_OPTIONS MPI_${LANG}_COMPILE_DEFINITIONS MPI_${LANG}_LINK_FLAGS
MPI_${LANG}_LIB_NAMES MPI_${LANG}_ADDITIONAL_INCLUDE_DIRS MPI_${LANG}_COMPILER)
@@ -1337,7 +1389,7 @@ foreach(LANG IN ITEMS C CXX Fortran)
set(MPI_${LANG}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT})
unset(MPI_${LANG}_REQUIRED_VARS)
- if (MPI_${LANG}_WRAPPER_FOUND OR MPI_${LANG}_GUESS_FOUND)
+ if (NOT "${MPI_${LANG}_COMPILER}" STREQUAL "${CMAKE_${LANG}_COMPILER}")
foreach(mpilibname IN LISTS MPI_${LANG}_LIB_NAMES)
list(APPEND MPI_${LANG}_REQUIRED_VARS "MPI_${mpilibname}_LIBRARY")
endforeach()
@@ -1448,6 +1500,7 @@ if (MPI_NUMLIBS GREATER 1)
else()
set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND")
endif()
+set(MPI_IGNORE_LEGACY_VARIABLES TRUE)
#=============================================================================
# unset these vars to cleanup namespace
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1d217c6..0552244 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -849,9 +849,6 @@ endif ()
#-----------------------------------------------------------------------------
add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c)
TARGET_C_PROPERTIES (H5detect STATIC " " " ")
-if (H5_HAVE_PARALLEL AND MPI_C_FOUND)
- target_include_directories (H5detect PUBLIC ${MPI_C_INCLUDE_DIRS})
-endif ()
if (MSVC OR MINGW)
target_link_libraries (H5detect "ws2_32.lib")
endif ()
@@ -866,9 +863,6 @@ add_custom_command (
add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c)
TARGET_C_PROPERTIES (H5make_libsettings STATIC " " " ")
-if (H5_HAVE_PARALLEL AND MPI_C_FOUND)
- target_include_directories (H5make_libsettings PUBLIC ${MPI_C_INCLUDE_DIRS})
-endif ()
if (MSVC OR MINGW)
target_link_libraries (H5make_libsettings "ws2_32.lib")
endif ()
@@ -893,9 +887,6 @@ target_link_libraries (${HDF5_LIB_TARGET} PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS}
if (NOT WIN32)
target_link_libraries (${HDF5_LIB_TARGET} PUBLIC ${CMAKE_DL_LIBS})
endif ()
-if (H5_HAVE_PARALLEL AND MPI_C_FOUND)
- target_include_directories (${HDF5_LIB_TARGET} PUBLIC ${MPI_C_INCLUDE_DIRS})
-endif ()
set_global_variable (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET})
H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} STATIC)
set_target_properties (${HDF5_LIB_TARGET} PROPERTIES
@@ -937,9 +928,6 @@ if (BUILD_SHARED_LIBS)
if (NOT WIN32)
target_link_libraries (${HDF5_LIBSH_TARGET} PUBLIC ${CMAKE_DL_LIBS})
endif ()
- if (H5_HAVE_PARALLEL AND MPI_C_FOUND)
- target_include_directories (${HDF5_LIBSH_TARGET} PUBLIC ${MPI_C_INCLUDE_DIRS})
- endif ()
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_LIBSH_TARGET}")
H5_SET_LIB_OPTIONS (${HDF5_LIBSH_TARGET} ${HDF5_LIB_NAME} SHARED ${HDF5_PACKAGE_SOVERSION})
set_target_properties (${HDF5_LIBSH_TARGET} PROPERTIES