Feature Request: User-selected comment characters for #cmakedefine
Per a CMake Discourse post (and with encouragement from @ben.boeckel), 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 had to figure out a workaround (I think using #cmakedefine01
).
My request is for some sort of ability for users to pass into configure_file
the comment style. One thought I had was to have a COMMENT_STYLE <lang>
a la NEWLINE_STYLE <style>
but then that could become a disaster (C, Fortran, Lua, etc.). @ben.boeckel thought something like COMMENT_BEGIN
and COMMENT_END
would be more general. Then users could do:
configure_file(... COMMENT_BEGIN "!" COMMENT_END "")
for Fortran or:
configure_file(... COMMENT_BEGIN "--" COMMENT_END "")
for Lua?