[CMake] Problem with generated source files and Fortran90 modules

Brad King brad.king at kitware.com
Wed Mar 13 08:27:47 EDT 2013


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?

-Brad


More information about the CMake mailing list