From e221039e11fb4961b8cbbdbd2fd8f1af99534893 Mon Sep 17 00:00:00 2001 From: Keith Ballard Date: Wed, 20 Nov 2019 09:34:40 -0500 Subject: 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 --- Modules/FindMPI.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 2779032..6b1da4b 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -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) #============================================================================= -- cgit v0.12