FindMPI _MPI_adjust_compile_definitions too late
In FindMPI, it first tries to see if compilers can compile MPI program directly.
https://gitlab.kitware.com/cmake/cmake/-/blob/b8a32aef3ff19834fb46de42fc045bb37683151c/Modules/FindMPI.cmake#L1453
cmake -DCMAKE_CXX_COMPILER=mpicxx
passes this check.
However if user use cmake -DCMAKE_CXX_COMPILER=mpicxx -DCMAKE_CXX_FLAGS="-Werror -Wsuggest-override" ..
L1453 check fails although a later _MPI_interrogate_compiler
still finds the compiler valid for compiling MPI program. The failure was cased by MPI-2 C++ binding included via mpi.h
.
This failure was unexpected because user CMakeLists already requested to skip MPICXX
set(MPI_CXX_SKIP_MPICXX TRUE CACHE BOOL "Must be TRUE for QMCPACK. Cached for working around CMake FindMPI issue.")
find_package(MPI COMPONENTS CXX)
However the skipping is done at https://gitlab.kitware.com/cmake/cmake/-/blob/b8a32aef3ff19834fb46de42fc045bb37683151c/Modules/FindMPI.cmake#L1550 which is too late.
So it is better to move _MPI_adjust_compile_definitions
before L1453 as !6303 (merged) shown and then L1453 check passes.