[cmake-developers] Fortran support for Ninja generator
Alexander Neundorf
neundorf at kde.org
Wed Mar 25 17:12:14 EDT 2015
On Wednesday, March 25, 2015 14:37:00 Steven Vancoillie wrote:
> On Mar 24 [11:21], Brad King wrote:
> > On 03/24/2015 05:46 AM, Nils Gladitz wrote:
> > > I am not very familiar with fortran myself but there was this discussion
> > > on the ninja mailing list that implied that this might also require
> > > changes to ninja itself:
> > >
> > > https://groups.google.com/d/msg/ninja-build/b1-AF3pRJuE/NkPDsO0C2IUJ
> >
> > That discussion concludes assuming that CMake scans source files
> > while generating the build files to generate the ordering dependencies.
> > It does not. There could be generated source files or header files
> > that are needed to get the ordering right. In the Makefile generator
> > we have a step to scan dependencies for a target after all its
> > dependencies are finished and its custom commands have executed.
> > This ensures generated files are available. Then CMake puts the
> > dependency scanning results in a place used by the actual compile
> > and link rules.
> >
> > [snip]
> >
> > I've been thinking about some ideas on how build.ninja rules
> > could express the dynamic scanning and update we need. Rather
> > than posting them now, perhaps the design process would benefit
> > from any independently developed ideas you may have.
>
> From what I understood from the conclusion of the discussion is indeed
> that it would require cmake to generate dependency files at build
> time. In a test setup, I have the following:
>
> build CMakeFiles/testninja.dir/prog.o.d: Fortran_DEPENDS_SCAN ../prog.f90
> build CMakeFiles/testninja.dir/prog.o: Fortran_COMPILER ../prog.f90 |
> CMakeFiles/testninja.dir/prog.o.d DEP_FILE =
> CMakeFiles/testninja.dir/prog.o.d
> FLAGS = -cpp -I../
> OBJECT_DIR = CMakeFiles/testninja.dir
> OBJECT_FILE_DIR = CMakeFiles/testninja.dir
> build ...
> build ...
>
> I skipped all the other files, but the pattern is the same.
> Then, there are these rules:
>
> rule Fortran_DEPENDS_SCAN
> command = f90deps $in $out
> description = Write Fortran dependencies to $out
>
> rule Fortran_COMPILER
> depfile = $DEP_FILE
> deps = gcc
> command = /usr/bin/f95 $DEFINES $FLAGS -c $in -o $out
> description = Building Fortran object $out
>
> In this case, a script 'f90deps' does the dependencies on the fly.
> Note that the Fortran_COMPILER rule is now missing any -MMD/-MT stuff.
>
> So, to do a similar thing with cmake, one would need to expose the
> cmake Fortran dependency scanner so that it can be invoked as e.g.:
>
> rule Fortran_DEPENDS_SCAN
> command = cmake scan_dependencies $in $out
> description = Write Fortran dependencies to $out
>
> but I don't know if turning the cmake executable into a build-time
> dependency scanner is feasible and/or acceptable.
as Brad wrote, this is already the case for the makefile generator, so I guess
in general this should be Ok.
Alex
More information about the cmake-developers
mailing list