# \#cmakedefine and Fortran

**URL:** https://discourse.cmake.org/t/cmakedefine-and-fortran/8013
**Category:** Usage
**Created:** [April 28, 2023, 3:49pm UTC](https://discourse.cmake.org/t/cmakedefine-and-fortran/8013 "2023-04-28T15:49:04Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mathomp4](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mathomp4/32/176_2.png) [@mathomp4](https://discourse.cmake.org/u/mathomp4)
#### Post date: [April 28, 2023, 3:49pm UTC](https://discourse.cmake.org/t/cmakedefine-and-fortran/8013/1 "2023-04-28T15:49:04Z")

</div>

All,

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

```fortran
#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:

```fortran
#define PFUNIT_EXTRA_USE ...

```

or:

```fortran
/* #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](https://cmake.org/cmake/help/latest/command/configure_file.html), 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](https://cmake.org/pipermail/cmake/2011-October/046602.html) 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`, …))

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 1, 2023, 3:26pm UTC](https://discourse.cmake.org/t/cmakedefine-and-fortran/8013/2 "2023-05-01T15:26:13Z")

</div>

> [@mathomp4](#):
>
> (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](https://gitlab.kitware.com/cmake/cmake/-/issues) to me.
