[CMake] Problem with Fortran module enclosed in #ifdef

Michael Wild themiwi at gmail.com
Fri Jan 9 04:09:16 EST 2009


On 9. Jan, 2009, at 9:27, Martin Apel wrote:

> Hi all,
>
> I am experiencing a problem with one Fortran source file containing a
> module definition. Unfortunately the whole source file is enclosed in
> '#ifdef WINDOWS'. On Linux this causes the build process to fail,
> because cmake wants to copy a generated .mod file, which does not  
> exist.
> The file containing the module has the suffix ".f". When changing the
> suffix to ".F", everything works fine.
> CMake probably thinks, the file need not be preprocessed before
> scanning, if it has the suffix ".f". Is there any way to tell CMake,
> that files with the suffix ".f" have to be preprocessed before
> dependency scanning?
>
> Regards,
>
> Martin
>

Hi

I think it is fairly non-standard to have a .f file preprocessed. All  
Fortran compilers I'm acquainted with only preprocess a file if it has  
a .F extension (unless forced, of course).

But since it is the whole file, can't you just exclude it in the CMake  
code?

set( SRCS foo.f bar.f )
if(WIN32)
   list( APPEND SRCS winspecific.f )
endif(WIN32)

add_executable( super_cow ${SRCS} )


HTH

Michael


More information about the CMake mailing list