Compilation output messages with Ninja+Fortran
I am using CMake with the Ninja generator on these two files:
# CMakeLists.txt
cmake_minimum_required(VERSION 3.0)
project(test Fortran)
add_executable(main main.f90)
# main.f90
implicit none
a = 5
end program
The problem is that the output, after running ninja, looks like this:
[3/4] Building Fortran object CMakeFiles/main.dir/main.f90.o
FAILED: CMakeFiles/main.dir/main.f90.o
/usr/bin/f95 -I../ -c CMakeFiles/main.dir/main.f90-pp.f90 -o CMakeFiles/main.dir/main.f90.o
CMakeFiles/main.dir/main.f90-pp.f90:2:3:
# 1 "<built-in>"
1
Error: Symbol ‘a’ at (1) has no IMPLICIT type
ninja: build stopped: subcommand failed.
The error message refers to a preprocessed file, main.f90-pp.f90, and not the original source file, main.f90. Also, the line and column numbers are shown incorrectly. Using the make
generator, I get the correct output:
[ 50%] Building Fortran object CMakeFiles/main.dir/main.f90.o
/home/raul/tmp/ninja/fortran/main.f90:4:3:
a = 5
1
Error: Symbol ‘a’ at (1) has no IMPLICIT type
make[2]: *** [CMakeFiles/main.dir/build.make:63: CMakeFiles/main.dir/main.f90.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:69: CMakeFiles/main.dir/all] Error 2
make: *** [Makefile:84: all] Error 2
It refers to the correct source file and identifies correctly the line and column numbers (4:3) where the error occured. Can anyone confirm if this is a bug with CMake or Ninja or am I doing something else wrong?