From 05f16ca7eefad41cbb8d6a973f47fe7c1a488ae5 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Tue, 2 Feb 2021 15:18:48 +0100 Subject: file(CONFIGURE): Use text mode for default OUTPUT content This affects only Windows where \n will be translated as \r\n Fixes: #21769 --- Source/cmFileCommand.cxx | 4 +++- Tests/RunCMake/File_Configure/NewLineStyle-ValidArg.cmake | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 5eff789..031e0d7 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3122,12 +3122,14 @@ bool HandleConfigureCommand(std::vector const& args, } std::string newLineCharacters = "\n"; + bool open_with_binary_flag = false; if (newLineStyle.IsValid()) { newLineCharacters = newLineStyle.GetCharacters(); + open_with_binary_flag = true; } cmGeneratedFileStream fout; - fout.Open(outputFile, false, true); + fout.Open(outputFile, false, open_with_binary_flag); if (!fout) { cmSystemTools::Error("Could not open file for write in copy operation " + outputFile); diff --git a/Tests/RunCMake/File_Configure/NewLineStyle-ValidArg.cmake b/Tests/RunCMake/File_Configure/NewLineStyle-ValidArg.cmake index 09aec45..5e35e5c 100644 --- a/Tests/RunCMake/File_Configure/NewLineStyle-ValidArg.cmake +++ b/Tests/RunCMake/File_Configure/NewLineStyle-ValidArg.cmake @@ -22,4 +22,8 @@ test_eol(CRLF "c" "630d0a") test_eol(UNIX "d" "640a") test_eol(LF "e" "650a") -test_eol("" "a\nb" "610a62") +if (WIN32) + test_eol("" "a\nb" "610d0a62") +elseif(UNIX) + test_eol("" "a\nb" "610a62") +endif() -- cgit v0.12