Topic: Problem Using CMake with the Simply Fortran GNU compilers v14.1.0

I am trying to use CMake to build the open source NJOY 2016 code from Los Alamos National Laboratory on my Windows 10 Professional v22H2 system. It comes with a CMakeLists.txt file and CMake will search for the Fortran compiler on a system. The GNU compilers from the Simply Fortran package are in their standard locations as reflected in the Windows path. I also have Visual Studio 2022 Community version installed but it is not in the path. I also have Python 3.13 installed and in the path. CMake finds the Python installation correctly but cannot find the GNU Fortran. It does find the Visual Studio installation but there is no Fortran associated with that so the build fails. The NJOY developers at Los Alamos advised me to add the following line to the CMake command line:
-DCMAKE_Fortran_COMPILER=/my/path/to/fortran/compiler.exe, which for me is
-DCMAKE_Fortran_COMPILER="C:\Program Files (x86)\Simply Fortran 3\mingw-w64\bin\gfortran.exe".
This does not help. I have tried this command line option with and without double and single quotes and with both backward and forward slashes to no avail.

So far neither the developers nor anyone at the CMake Discourse web site has suggested a solution that works. I don't expect anyone here to give advice on CMake since it is not your product. However, I suspect the problem may have something to do with the spaces in the path to the GNU compilers. If I install Simply Fortran to a location that has no spaces in the path, for example
C:\SimplyFortran\mingw-w64\..., will that adversely affect the normal operation of Simply Fortran with your GUI interface?

Re: Problem Using CMake with the Simply Fortran GNU compilers v14.1.0

In my experience, CMake does tend to have major issues when the compiler path contains spaces and/or parentheses.  I'm somewhat surprised that both characters continue to be an issue in build systems in 2025, but here we are.

Simply Fortran will work in whatever directory you choose to install it.  You may have to take two steps:

1. Uninstall the previous instance of Simply Fortran first

2. Once installed in a path without spaces, start Simply Fortran, select Compiler and Support Programs in the Options menu, and click Restore Defaults

The combination of the above two steps should ensure that the freshly installed, spaceless-path copy of Simply Fortran does not have any old settings pointing at the Windows default location of "C:\Program Files (x86)\Simply Fortran 3."  Our software should continue working fine after that, and the compiler location should be compatible with CMake at that point.

Jeff Armstrong
Approximatrix, LLC

3 (edited by rymanjc 2025-04-14 04:01:49)

Re: Problem Using CMake with the Simply Fortran GNU compilers v14.1.0

I was finally able to get Cmake to work with the compilers in the Simply Fortran default folders after some other changes recommended on the CMake forum.

1) I had to change the Cmake generator to the one for MinGW Makefiles by adding -G "MinGW Makefiles" on the CMake command line because the default generator on Windows is Nmake from Visual Studio.

2) I also had to add a binary executable for the GNU make utility to the same folder as the compiler and specify
-DCMAKE_MAKE_PROGRAM="C:\Program Files (x86)\Simply Fortran 3\mingw-w64\bin\make.exe" on the CMake command line.

3) I had to specify the Fortran compiles as -DCMAKE_Fortran_COMPILER="C:\Program Files (x86)\Simply Fortran 3\mingw-w64\bin\gfortran.exe" on the CMake command line.

So spaces are allowed in CMake arguments if they are enclosed in double quotes.