FindMPI fails if suffix is limited to .a and .lib

Dear experts.

find_package(MPI) “fails” (resulting in MPI_FOUND=FALSE) if CMAKE_FIND_LIBRARY_SUFFIXES is set to “.a;.lib” although it finds libmpichfort.a and libmpich.a (as reported in MPI_Fortran_LIBRARIES).

OS: Linux (Ubuntu 24.04.3 LTS)

CMake version: 4.2.3

MPI: mpich 4.1 (mpich-4.2.0-5build3 and libmpich12-4.2.0-5build3)

p.s. setting MPI_USE_STATIC_LIBS to TRUE seems to have no effect in selecting static libraries, right?

Intel oneAPI ifx runs OK, but GNU gfortran fails…

It seems that TryCompile-s fail because of undefined references to the symbols in PMIx, UCX, and so on…

mpifort -show (MPICH on Ubuntu 24.04.3 LTS) prints the following:

furutaka@ubuntu:~/practices/MPI$ mpifort -show -static
gfortran -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/build/mpich-C3oteG/mpich-4.2.0=. -flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection -fcf-protection -fdebug-prefix-map=/build/mpich-C3oteG/mpich-4.2.0=/usr/src/mpich-4.2.0-5build3 -fallow-invalid-boz -fallow-argument-mismatch -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -L/usr/lib -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu/pmix2/lib -static -I/usr/lib/x86_64-linux-gnu/mpich/include -I/usr/lib/x86_64-linux-gnu/mpich/include -L/usr/lib/x86_64-linux-gnu/mpich/lib -lmpichfort -lmpich -L/usr/lib -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu/pmix2/lib -lhwloc -lpmix -lucp -lucs -lpthread

furutaka@ubuntu:~/practices/MPI$ mpifort -show -shared
gfortran -O2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -ffile-prefix-map=/build/mpich-C3oteG/mpich-4.2.0=. -flto=auto -ffat-lto-objects -fstack-protector-strong -fstack-clash-protection -fcf-protection -fdebug-prefix-map=/build/mpich-C3oteG/mpich-4.2.0=/usr/src/mpich-4.2.0-5build3 -fallow-invalid-boz -fallow-argument-mismatch -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -Wl,-z,relro -shared -I/usr/lib/x86_64-linux-gnu/mpich/include -I/usr/lib/x86_64-linux-gnu/mpich/include -L/usr/lib/x86_64-linux-gnu/mpich/lib -lmpichfort -lmpich

I’ve tried to attach an example output of try_compile (MPI_RESULT_Fortran_test_mpi_F77_HEADER_NOKIND), but as a new user I couldn’t do so (and I couldn’t paste it here because of the limit on the number of characters…).
How can I show it???

My ultimate question is, HOW CAN I DO STATIC LINKING OF MPI LIBRARIES???