Why doesn't CMake offer the NEWLINE_STYLE option to file(WRITE|APPEND) as well?

Problem Description

Recently, I needed to use CMake commands to create and write content to a file. Initially, I used the file(WRITE) command to write the modified content, but later I wanted to ensure that the line endings of the files I create and modify are uniformly LF.

After reading this issue, I learned that I can use file(GENERATE|CONFIGURE) or configure_file() with the NEWLINE_STYLE option to specify the line ending format used during saving. For example:

#
# Write ${jsonCnt} into ${_filepath}
#
# file(WRITE "${_filepath}" ${jsonCnt})
file(CONFIGURE OUTPUT "${_filepath}" CONTENT ${jsonCnt} NEWLINE_STYLE LF)

Although the problem seems to be solved, I have a question:

Why doesn’t CMake offer the NEWLINE_STYLE option to file(WRITE|APPEND) as well?

Reference Links

It looks like there is an open feature request addressing what you are asking. It doesn’t appear there is much information there as to go/no go on the feature. May not be a high priority feature? Might be a good feature to get introduced to CMake source development.

There’s a different issue that goes into more of a discussion about what’s happening behind the scenes with the file(WRITE) command. They just open the file in text mode for that command so it’s relying on the C/C++ runtime behavior.