Fortran getting errors when generating build environment with EXERCISM_RUN_ALL_TESTS

When trying to generate the build environment for a (any?) fortran track exercise, I get an error about a *_build_all.f90 source file not being found.

I can manually run the resulting test executable and it appears all the tests do run even when I don’t create the build environment with the EXERCISM_RUN_ALL_TESTS variable set, running ctest -V does seem to run all the tests, make test will only run the first one.

Steps to reproduce:

exercism download --exercise=hamming --track=fortran mkdir build cd build cmake -DEXERCISM_RUN_ALL_TESTS=y -G ‘Unix Makefiles’ …


-- The Fortran compiler identification is GNU 13.1.0
-- Checking whether Fortran compiler has -isysroot
-- Checking whether Fortran compiler has -isysroot - yes
-- Checking whether Fortran compiler supports OSX deployment target flag
-- Checking whether Fortran compiler supports OSX deployment target flag - yes
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /usr/local/bin/gfortran - skipped
-- Configuring done (4.9s)
CMake Error at CMakeLists.txt:61 (add_executable):
  Cannot find source file:


  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc

CMake Error at CMakeLists.txt:61 (add_executable):
  No SOURCES given to target: hamming

CMake Generate step failed.  Build files cannot be regenerated correctly.

I couldn’t find anything in the track documentation about these _build_all.f90 files, not sure if I’m missing something or not.

Thanks for any help

# Configure to run all the tests?
    set(exercise_f90 ${file}_build_all.f90)
  # [...]

Seems that this is doing exactly what you experience, and is meant to be used with this root level CMAKE.

I believe this setting is meant to run all the exercises, not all the tests in one exercise. Thus, what you’re doing isn’t meant for what you’re trying to accomplish.

Instead, from the docs, I can see that you’re supposed to:

Working through each exercise is a process of:

  • Creating the initial build with CMake
  • For each unit test:
    • Satisfy compile errors to make the test fail.
    • Implement just enough to make the test pass.
    • Refactor your implementation to enhance readability, reduce duplication, etc.
    • Uncomment the next test

So this is a manual step you have to take. This is common on Exercism.