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

Looks like @ErikSchierboom and I both missed this - sorry, and as we don’t have a fortran maintainer it often comes down to us to spot things.

If you’d like to resubmit that PR, we’ll happily take a look (I can’t reopen it as it looks like the branch has been removed)

Will do a bit later, okay! I’ll be busy right now.

1 Like

Easy fix first: Fix GFortran spelling in comments by avysk · Pull Request #237 · exercism/fortran · GitHub
Ping @iHiD @ErikSchierboom

Thanks. I’ve invited you to the org so your PRs won’t get closed. If you request review from @ErikSchierboom on them, he’ll review/merge them (or tell us who else should be assigned to them). He’s next working on Wednesday :slight_smile: