summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorDāvis Mosāns <davispuh@gmail.com>2016-10-19 20:51:51 (GMT)
committerBrad King <brad.king@kitware.com>2016-10-20 17:13:48 (GMT)
commitced77d2bbd07d195f563217bea1930e29472fd4d (patch)
treeead2c50bb00bc04f21614ee6be979f0886ce44e7 /Source
parent7aa9961939f99c915485d86e460b9941f949d59c (diff)
downloadCMake-ced77d2bbd07d195f563217bea1930e29472fd4d.zip
CMake-ced77d2bbd07d195f563217bea1930e29472fd4d.tar.gz
CMake-ced77d2bbd07d195f563217bea1930e29472fd4d.tar.bz2
Ninja: Use ANSI encoding for Ninja build files on Windows
Pass ANSI encoding to cmGeneratedFileStream for use with Ninja generator.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx18
-rw-r--r--Source/cmGlobalNinjaGenerator.h3
2 files changed, 19 insertions, 2 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index b90428d..22302fb 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -496,6 +496,18 @@ cmLocalGenerator* cmGlobalNinjaGenerator::CreateLocalGenerator(cmMakefile* mf)
return new cmLocalNinjaGenerator(this, mf);
}
+codecvt::Encoding cmGlobalNinjaGenerator::GetMakefileEncoding() const
+{
+#ifdef _WIN32
+ // Ninja on Windows does not support non-ANSI characters.
+ // https://github.com/ninja-build/ninja/issues/1195
+ return codecvt::ANSI;
+#else
+ // No encoding conversion needed on other platforms.
+ return codecvt::None;
+#endif
+}
+
void cmGlobalNinjaGenerator::GetDocumentation(cmDocumentationEntry& entry)
{
entry.Name = cmGlobalNinjaGenerator::GetActualName();
@@ -754,7 +766,8 @@ void cmGlobalNinjaGenerator::OpenBuildFileStream()
// Get a stream where to generate things.
if (!this->BuildFileStream) {
- this->BuildFileStream = new cmGeneratedFileStream(buildFilePath.c_str());
+ this->BuildFileStream = new cmGeneratedFileStream(
+ buildFilePath.c_str(), false, this->GetMakefileEncoding());
if (!this->BuildFileStream) {
// An error message is generated by the constructor if it cannot
// open the file.
@@ -791,7 +804,8 @@ void cmGlobalNinjaGenerator::OpenRulesFileStream()
// Get a stream where to generate things.
if (!this->RulesFileStream) {
- this->RulesFileStream = new cmGeneratedFileStream(rulesFilePath.c_str());
+ this->RulesFileStream = new cmGeneratedFileStream(
+ rulesFilePath.c_str(), false, this->GetMakefileEncoding());
if (!this->RulesFileStream) {
// An error message is generated by the constructor if it cannot
// open the file.
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index d4a14e2..3d13e0b 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -186,6 +186,9 @@ public:
static std::string GetActualName() { return "Ninja"; }
+ /** Get encoding used by generator for ninja files */
+ codecvt::Encoding GetMakefileEncoding() const CM_OVERRIDE;
+
static void GetDocumentation(cmDocumentationEntry& entry);
void EnableLanguage(std::vector<std::string> const& languages,