[CMake] Using preprocessor to set module name with Fortran in CMake
Tom Clune
Thomas.L.Clune at nasa.gov
Tue Feb 25 10:18:39 EST 2014
I would like to have create a poor-man's template module in Fortran by using the preprocessor and #include. The generic logic will go in the include file, and the various top-level files will define tokens to instantiate specific implementations. A very simple example is the following:
!----------------------
! <IntegerVersion.F90>
#define _TYPE integer
#define MODULE_NAME Integer_mod
#include <generic.h>
!----------------------
!----------------------
! <generic.h>
module MODULE_NAME
_TYPE :: i
…
end module MODULE_NAME
!----------------------
The problem is that CMake does not realize that module has been renamed via the preprocessor and still tries to find a .mod file called MODULE_NAME.mod: "Error copying Fortran module module_name" …
How can I notify CMake that the module has a different name than what it finds in the source code? I have tried using set_property() on the top file, but that does not seem to help.
I am aware that with the simple example above, I could move the module declaration up to the top level and circumvent this problem. But the include file is itself being automatically generated.
Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140225/d1970d4a/attachment-0001.html>
More information about the CMake
mailing list