summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefileTargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-01-27 16:04:45 (GMT)
committerKitware Robot <kwrobot@kitware.com>2022-01-27 16:05:04 (GMT)
commit67d604a7929cd13ccc02bf6e982535241b31a8f3 (patch)
tree9a2f7e04460efd1fbc722f6efd98018ed2520fb1 /Source/cmMakefileTargetGenerator.cxx
parent57595c6673b969706f00a1141e52163878f42dce (diff)
parentd5ee6d50ee71f78dc619001e86e69f23444acfa9 (diff)
downloadCMake-67d604a7929cd13ccc02bf6e982535241b31a8f3.zip
CMake-67d604a7929cd13ccc02bf6e982535241b31a8f3.tar.gz
CMake-67d604a7929cd13ccc02bf6e982535241b31a8f3.tar.bz2
Merge topic 'nmake-rsp-encoding'
d5ee6d50ee NMake: Use UTF-8 BOM in response files only with MSVC tooling cab631c2e2 NMake: Document response file encoding heuristic in a comment Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !6905
Diffstat (limited to 'Source/cmMakefileTargetGenerator.cxx')
-rw-r--r--Source/cmMakefileTargetGenerator.cxx17
1 files changed, 15 insertions, 2 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 5d306ec..1c92c7f 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -16,6 +16,8 @@
#include <cmext/algorithm>
#include <cmext/string_view>
+#include "cm_codecvt.hxx"
+
#include "cmComputeLinkInformation.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
@@ -2077,11 +2079,22 @@ std::string cmMakefileTargetGenerator::CreateResponseFile(
const char* name, std::string const& options,
std::vector<std::string>& makefile_depends)
{
+ // FIXME: Find a better way to determine the response file encoding,
+ // perhaps using tool-specific platform information variables.
+ // For now, use the makefile encoding as a heuristic.
+ codecvt::Encoding responseEncoding =
+ this->GlobalGenerator->GetMakefileEncoding();
+ // Non-MSVC tooling may not understand a BOM.
+ if (responseEncoding == codecvt::UTF8_WITH_BOM &&
+ !this->Makefile->IsOn("MSVC")) {
+ responseEncoding = codecvt::UTF8;
+ }
+
// Create the response file.
std::string responseFileNameFull =
cmStrCat(this->TargetBuildDirectoryFull, '/', name);
- cmGeneratedFileStream responseStream(
- responseFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
+ cmGeneratedFileStream responseStream(responseFileNameFull, false,
+ responseEncoding);
responseStream.SetCopyIfDifferent(true);
responseStream << options << "\n";