From 8251b62ba0165526eaca9e949ee28860af82521f Mon Sep 17 00:00:00 2001 From: Axel Huebl Date: Wed, 10 Feb 2021 19:06:45 -0800 Subject: FindMPI: Fix reason for a non-enabled non-requested language In pure C/CXX projects, when doing an optional search for C/CXX MPI APIs, I keep getting a reason appended of the form: ``` -- Could NOT find MPI_C (missing: MPI_C_LIB_NAMES MPI_C_HEADER_DIR MPI_C_WORKS) -- Could NOT find MPI_CXX (missing: MPI_CXX_LIB_NAMES MPI_CXX_HEADER_DIR MPI_CXX_WORKS) -- Could NOT find MPI (missing: MPI_C_FOUND MPI_CXX_FOUND) Reason given by package: MPI component 'Fortran' was requested, but language Fortran is not enabled. ``` The reason makes no sense since I did not request Fortran and thus confuses the reader. It is now only added if the component was truly requested. --- Modules/FindMPI.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 8cc39ac..195ca49 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -1428,7 +1428,9 @@ 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. ") + if(${LANG} IN_LIST MPI_FIND_COMPONENTS) + string(APPEND _MPI_FAIL_REASON "MPI component '${LANG}' was requested, but language ${LANG} is not enabled. ") + endif() endif() if(_MPI_FIND_${LANG}) if( ${LANG} STREQUAL CXX AND NOT MPICXX IN_LIST MPI_FIND_COMPONENTS ) -- cgit v0.12