I am trying to configure a Fortran 2008 project to use CMake; the files in the project have the ".f08" extension. However, I cannot get CMake to work even with a "hello world" example. Here are the relevant parts of my CMakeLists.txt file:
cmake_minimum_required(VERSION 2.8)
project (hello)
enable_language (Fortran)
set (CMAKE_Fortran_SOURCE_FILE_EXTENSIONS ${CMAKE_Fortran_SOURCE_FILE_EXTENSIONS} "f08;F08")
add_executable ("hello-world" "hello-world.f08")
set_target_properties (hello-world PROPERTIES LINKER_LANGUAGE Fortran)
Three notes:
- The Makefile generated does not compile "hello-world.f08" into an object file.
- The "set_target_properties" is needed. Otherwise, CMake reports that it "can not determine linker language for target:hello-world".
- Renaming the file to "hello-world.f95" along with the corresponding change in CMakeLists.txt makes things work. Even the "set_target_properties" command is no longer needed.
.f90
extension. Using the extension to indicate the language standard level is generally regarded as a mistake. – Penileifort
will complain withld:testf08.f08: file format not recognized; treating as linker script
and fail without even trying to compile. Use.f90
and use your FFLAGS to put in the-std=f2008
(gfortran) which will actually use the F2008 standard, unlike counting on the extension to do so. – Dulci