#cmakedefine and Fortran

All,

I’m pretty sure the answer to this is “Nope!” but, I thought I’d ask. Namely, I have a case where:

#cmakedefine PFUNIT_EXTRA_USE @PFUNIT_EXTRA_USE@

is used and then configure_file is run on this file. The extra twist? This file is a Fortran file so you can end up with either:

#define PFUNIT_EXTRA_USE ...

or:

/* #undef PFUNIT_EXTRA_USE */

And it turns out Cray Fortran does not allow C comments in Fortran code. Our guess is that our other compilers probably rely on cpp which might let this slide, but technically that is not valid Fortran. So we are having to try and figure out a workaround (maybe using #cmakedefine01?).

Now looking at the configure_file docs, it looks like there is no way to change the comment character used by this, right? (And since it’s configure_file it’s not even aware of the language used.)

If not, has anyone solved this in a nice way? My GoogleFu did bring up a 2011 (!) post on the CMake mailing list that was “Do a bunch of postprocessing” but maybe in the last 12 years, CMake has advanced to make it simpler?

(Note: it would be nice to have a COMMENT_STYLE <lang> a la NEWLINE_STYLE <style> but then I can see the flood gates might open… (C, Fortran, Lua, …))

I think having COMMENT_BEGIN and COMMENT_END arguments may be far more flexible. This sounds worth a feature request to me.