CMakeLists.txt in Fortran exercises seems to be broken

I have tried to create both PR and issue, but they are autoclosed, so I’m posting here.

if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") # Intel fortran
  if(WIN32)
   set (CCMAKE_Fortran_FLAG ${CCMAKE_Fortran_FLAGS} "/warn:all")
  else()
  set (CMAKE_Fortran_FLAGS ${CCMAKE_Fortran_FLAGS} "-warn all")
endif()
  1. CCMAKE should be CMAKE, in three places.
  2. FLAG should be FLAGS .
  3. But: the code should really use FFLAGS instead of internal cmake CMAKE_Fortran_FLAGS. Setting the latter effectively blocks FFLAGS from being used at all.

Lower in the file there is a comment which reads GFrotran (yes, with a typo). Should be fixed as well.

Background: I was trying to do exercises with gfortran13 on FreeBSD, so I had to pass -Wl,-rpath=/usr/local/lib/gcc13 option. Inspired by the fact that the FC environment variable is honored, I’ve defined FFLAGS – and it did not work. So I have started to look into what cmake does.

Relevant link: FFLAGS — CMake 3.26.4 Documentation

And it seems that the proper way is to use add_compile_options — CMake 3.26.4 Documentation