[cmake-developers] [RFC] Trailing newline in CMakeConfigurableFile.in

Ben Boeckel ben.boeckel at kitware.com
Tue May 5 17:44:44 EDT 2015


Hi,

Should CMakeConfigurableFile.in have a trailing newline? I recently hit
a problem where my contents were made using:

    foreach (...)
        set(contents "${contents}new stuff\n")
    endforeach ()

    set(CMAKE_CONFIGURABLE_FILE_CONTENT "${contents}")
    configure_file(...)

but this caused an extra newline to be placed at the end of the
resulting file (which was not valid for the file being written). I think
at least some documentation that a (native) newline is implicit at the
end of the configured file. A version without a newline at the end might
be wanted as well in case literal *nix- or Windows-style newlines are
required for the format of the file being configured. This also might
mean a BINARY argument value for NEWLINE_STYLE in configure_file makes
sense to avoid messing with any newlines at all (I can think of
configuring files with HTTP headers which need CRLF but contents with LF
for use in a test suite).

Thoughts?

--Ben


More information about the cmake-developers mailing list