CESM must come with some build system(s) (e.g., CMake, fpm, etc.) with instructions as to how to use them.
Use the same system(s) and follow the exact steps in such instructions.
Colloquially this is known as RTFM.
https://escomp.github.io/CESM/versions/cesm2.2/html/