FindMPI: Improve error when a component's language is not enabled

Previously, if a CMake project requests a component for a language that is
not enabled, it would simply give an error with the message

    Could NOT find MPI (missing: MPI_${LANG}_FOUND)

which is not indicative that the language was not enabled.  This change
provides an error message indicating that it failed to find the
particular MPI component because no compiler was available for the
language and the language might need to be enabled for the project.

Closes: #19996
This commit is contained in:
Keith Ballard
2019-11-20 09:34:40 -05:00
committed by Brad King
parent 5f630a934a
commit e221039e11

View File

@@ -1391,6 +1391,7 @@ foreach(LANG IN ITEMS C CXX Fortran)
endif()
else()
set(_MPI_FIND_${LANG} FALSE)
string(APPEND _MPI_FAIL_REASON "MPI component '${LANG}' was requested, but language ${LANG} is not enabled. ")
endif()
if(_MPI_FIND_${LANG})
if( ${LANG} STREQUAL CXX AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS )
@@ -1688,6 +1689,7 @@ endif()
find_package_handle_standard_args(MPI
REQUIRED_VARS ${_MPI_REQ_VARS}
VERSION_VAR ${_MPI_MIN_VERSION}
REASON_FAILURE_MESSAGE "${_MPI_FAIL_REASON}"
HANDLE_COMPONENTS)
#=============================================================================