[CMake] retrieving and manipulating (Fortran) dependency information

Brad King brad.king at kitware.com
Mon Feb 3 11:46:05 EST 2014


On 01/30/2014 05:43 PM, Zaak Beekman wrote:
> I noticed that output_required_files is deprecated.

Yes, it has been marked as such since CMake 2.8.5:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5cf4ff6e
 http://www.cmake.org/Bug/view.php?id=12214

but was out of favor long before that.  It was a rudimentary
scanner and did not support Fortran the way CMake's scanner
used by Makefile generator does.

The modern dependency scanner is an internal implementation
detail and is not exposed through a public interface.  We do
not want to expose it publicly because that would limit future
refactoring.

> Is there a way to determine the dependencies of a Fortran source
> file that I can then manipulate in a CMakeLists.txt file? Fortran
> dependency resolution is a pain, and I need to determine
> dependencies for a custom target.

While the scanner output is not directly accessible you can tell
CMake to treat dependencies for a custom command as it would
a particular language source compilation.  The IMPLICIT_DEPENDS
option to add_custom_command may work:

 add_custom_command(...
   COMMAND ...command that runs compiler...
   IMPLICIT_DEPENDS Fortran
   )

but only with Makefile generators.

-Brad



More information about the CMake mailing list