Make cmake find the selected compiler when using Lmod PrgEnv
Some niche OSS compilers in Linux sets the symlink CC to point to the CXX compiler. This contrast to the more general-use compilers such as LLVM and GNU compiler which uses the symlink named c++. This is the case for the lmod module PrgEnv which is ubiquitous in HPC systems (such as DoE supercomputers) which does not event set the c++ symlink.
In the case that CMake detects that we are in a Lmod PrgEnv environment we should prioritize the CC symlink vs the c++ since the precesense of a PrgEnv environment implies a purpose since it is very probably that it would have been explicitly enabled/installed.
In particular, this was needed since in NERSC Perlmutter when loading the Cray compiler suite it adds to the PATH the links cc for C and CC for C++. It does not add a binary named c++ as it is customary in other compiler vendors.
I proposed the following PRs with different approaches to resolve this: !8638 (closed) and !8631 (closed), however, those approaches were flawed one way or another. I wonder if it might be a good idea for cmake to test that it is in PrgEnv through a test for a env var such as $LMOD_FAMILY_PRGENV
and ifso consider CC before c++ when determine the C++ Compiler
Links to PrgEnv environments in: