The code for this recipe is available at https://github.com/dev-cafe/cmake-cookbook/tree/v1.0/chapter-07/recipe-09 and has a Fortran example. The recipe is valid with CMake version 3.5 (and higher) and has been tested on GNU/Linux, macOS, and Windows with MSYS Makefiles.
We devote one recipe to the discussion of how to structure and organize Fortran projects for two reasons:
- There are still many Fortran projects out there, in particular in numerical software (for a more comprehensive list of general purpose Fortran software projects, see http://fortranwiki.org/fortran/show/Libraries).
- Fortran 90 (and later) can be more difficult to build for projects not using CMake, since Fortran module files impose a compilation order. In other words, for manually written Makefiles one typically needs to program a dependency scanner for Fortran module files.
As...