[CMake] Problem with generated source files and Fortran90 modules

Julien Bigot julien at julien-bigot.fr
Wed Mar 13 09:33:17 EDT 2013


On Wednesday 13 March 2013 2:11 PM Julien Bigot wrote:
> On Wednesday 13 March 2013 8:27 AM Brad King wrote:
> > On 03/11/2013 06:41 AM, Julien Bigot wrote:
> > > 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
> > 
> > This is expected to work.  The custom command should be evaluated
> > during the build before CMake scans dependencies.  I just tested
> > this case and it works for me.
> > 
> > Perhaps something about the actual content of gen.f90 prevents
> > CMake from picking up the module it generates.  Can you post
> > its content here?  Even better, can you provide a *minimal* but
> > complete source tarball that reproduces the problem?
> 
> I will try to provide a minimal example ASAP. For now I have a deadline to
> meet and I'll use the version with the explicit dependency on the object
> file.

This might also be related to the fact that all uses of the module are 
included inside #ifdef MYMACRO ... #endif where MYMACRO is defined with
set_property(SOURCE usegen.f90 APPEND PROPERTY 
COMPILE_DEFINITIONS_DEBUG MYMACRO)

> > -Brad
> 
> Regards,
> Julien
-- 
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/38c94482/attachment-0001.pgp>


More information about the CMake mailing list