cmake Could NOT find MPI_CXX (missing: MPI_CXX_WORKS)

But I can build Gromacs successfully by using the same openmpi/5.0_cuda12.9_gcc13 compiler combination. PATH or any other ENVs are all the same. Cmake of Gromacs said:

– MPI is not compatible with thread-MPI. Disabling thread-MPI.
– Found MPI_CXX: /opt/openmpi/5.0.9_cuda12.9_gcc13/bin/mpicxx (found version “3.1”)
– Found MPI: TRUE (found version “3.1”) found components: CXX
– GROMACS library will use OpenMPI 5.0.9

I also read this post. And try to set a lot of cmake-variables just like CMAKE_CXX_COMPILER CMAKE_CUDA_COMPILER and so on, but nothing help.

Finally, as the post said, I comment the silence nvcc warnings in cmake/CMakeLists.txt. Building of lammps successed. I did’t know why set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xcudafe --diag_suppress=unrecognized_pragma,--diag_suppress=128") can cause a Could NOT find MPI_CXX (missing: MPI_CXX_WORKS) error. Anyway, it’s worked.