[CMake] Problem with generated source files and Fortran90 modules

Julien Bigot julien at julien-bigot.fr
Wed Mar 13 06:35:14 EDT 2013


Hi,

On Tuesday 12 March 2013 7:37 AM Petr Kmoch wrote:
> Hi Julien,
> 
> CMake correctly identifies that gen.90f depends on gen.f90.sh, but you
> have no code to tell CMake that usegen.f90 depends on gen.f90. The
> following should do the trick:
> 
> set_property(SOURCE usegen.f90 PROPERTY OBJECT_DEPENDS
> "${CMAKE_BINARY_DIR}/gen.f90")

Thanks, while this specific line doesn't work, it seems like the following one 
works :
set_property(SOURCE usegen.f90 PROPERTY OBJECT_DEPENDS
${CMAKE_BINARY_DIR}/CMakeFiles/mylib.dir/gen.f90.o)

This is not very clean as it has to be specified for each and every use of the 
file in a new target and has to be modified every time the dependencies change 
... :/ but well, for now it will work !

> Petr

Thanks a lot,
Julien

> On Mon, Mar 11, 2013 at 11:41 AM, Julien Bigot <julien at julien-bigot.fr> 
wrote:
> > Hi,
> > 
> > I'm using cmake with something like that
> > 
> > add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/gen.f90"
> > 
> >         COMMAND bash ARGS "${CMAKE_SOURCE_DIR}/gen.f90.sh" ">"
> > 
> > "${CMAKE_BINARY_DIR}/gen.f90"
> > 
> >         MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/gen.f90.sh"
> >         VERBATIM
> > 
> > )
> > 
> > add_library(mylib STATIC usegen.f90 "${CMAKE_BINARY_DIR}/gen.f90")
> > 
> > gen.f90 defines a module gen_module and usegen uses this module
> > 
> > unfortunately cmake doesn't seem to catch the dependency and tries to
> > compile usegen.f90 before gen.f90 resulting in an error of missing
> > gen_module.mod
> > 
> > I've tried to set the gen.f90 property GENERATED to TRUE but this does not
> > seem to have any effect ...
> > 
> > Could someone give me some hint to understand what I'm doing wrong ?
> > 
> > Regards,
-- 
Julien Bigot, Ph.D.  --  http://work.julien-bigot.fr
Maison de la Simulation USR 3441 - bât. 565 - CEA Saclay
91191 Gif-sur-Yvette CEDEX - FRANCE
phone: (+33) 1 69 08 01 75  --  xmpp: jbigot at jabber.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 230 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130313/90c0ac1f/attachment.pgp>


More information about the CMake mailing list