[CMake] Problem with Fortran module enclosed in #ifdef

Martin Apel martin.apel at simpack.de
Fri Jan 9 04:26:03 EST 2009


Michael Wild wrote:
> 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} )
>   
You are right, that this is uncommon. But I'm trying to replace an
existing "build system" for some thousands of files, which preprocesses
all Fortran files, even those with ".f" suffix. Unfortunately this is
something I can't change.
I could use the approach you suggest, but I'd like a more general
solution, because I cannot be sure, that this is the only file, where
preprocessing makes a difference. There might
be other files containing a USE directive enclosed in ifdefs.

Regards,

Martin
____________
Virus checked by G DATA AntiVirus
Version: AVF 19.215 from 08.01.2009




More information about the CMake mailing list