[cmake-developers] Fortran support for Ninja generator

Brad King brad.king at kitware.com
Thu Mar 26 08:53:25 EDT 2015


On 03/25/2015 05:12 PM, Alexander Neundorf wrote:
>> 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

Thanks.  I have a similar structure in mind.  I think it will end up
being a bit more complicated because the dependencies have to be
scanned and loaded on the fly.  Currently Ninja loads all depfiles
up front and dependencies generated from scanning are only considered
on the next invocation.  We will need build-time incremental addition
of dependencies and even new build nodes to represent the module
files that sit between providers and consumers.

I'm working on a write-up of the whole thing to present to Ninja
folks.  Once it's drafted I'll post it here for discussion.

>> 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.

Yes, the Makefile generator already uses an undocumented cmake command
line tool to scan dependencies during the build.

-Brad



More information about the cmake-developers mailing list