Encoding: If configured, write Visual Studio project files as UTF-8.

This commit is contained in:
Clinton Stimpson 2014-03-14 08:48:42 -06:00
parent 91fd99b865
commit ee8cef8725
5 changed files with 30 additions and 8 deletions

View File

@ -873,7 +873,8 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
std::string guid = this->GetGUID(pname.c_str()); std::string guid = this->GetGUID(pname.c_str());
fout << fout <<
"<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n" "<?xml version=\"1.0\" encoding = \""
<< this->Encoding() << "\"?>\n"
"<VisualStudioProject\n" "<VisualStudioProject\n"
"\tProjectType=\"Visual C++\"\n" "\tProjectType=\"Visual C++\"\n"
"\tVersion=\"" << this->GetIDEVersion() << "0\"\n" "\tVersion=\"" << this->GetIDEVersion() << "0\"\n"
@ -1038,3 +1039,14 @@ cmIDEFlagTable const* cmGlobalVisualStudio7Generator::GetExtraFlagTableVS7()
{ {
return cmVS7ExtraFlagTable; return cmVS7ExtraFlagTable;
} }
std::string cmGlobalVisualStudio7Generator::Encoding()
{
std::ostringstream encoding;
#ifdef CMAKE_ENCODING_UTF8
encoding << "UTF-8";
#else
encoding << "Windows-1252";
#endif
return encoding.str();
}

View File

@ -109,6 +109,9 @@ public:
virtual void FindMakeProgram(cmMakefile*); virtual void FindMakeProgram(cmMakefile*);
// Encoding for Visual Studio files
virtual std::string Encoding();
protected: protected:
virtual const char* GetIDEVersion() { return "7.0"; } virtual const char* GetIDEVersion() { return "7.0"; }

View File

@ -1,3 +1,4 @@
/*============================================================================ /*============================================================================
CMake - Cross Platform Makefile Generator CMake - Cross Platform Makefile Generator
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
@ -918,4 +919,4 @@ std::string cmGlobalVisualStudioGenerator::ExpandCFGIntDir(
i += config.size(); i += config.size();
} }
return tmp; return tmp;
} }

View File

@ -1975,7 +1975,8 @@ cmLocalVisualStudio7Generator
cmGlobalVisualStudio7Generator* gg = cmGlobalVisualStudio7Generator* gg =
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator); static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n" fout << "<?xml version=\"1.0\" encoding = \""
<< gg->Encoding() << "\"?>\n"
<< "<VisualStudioProject\n" << "<VisualStudioProject\n"
<< "\tProjectCreator=\"Intel Fortran\"\n" << "\tProjectCreator=\"Intel Fortran\"\n"
<< "\tVersion=\"" << gg->GetIntelProjectVersion() << "\"\n"; << "\tVersion=\"" << gg->GetIntelProjectVersion() << "\"\n";
@ -2038,7 +2039,12 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
this->WriteProjectStartFortran(fout, libName, target); this->WriteProjectStartFortran(fout, libName, target);
return; return;
} }
fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
cmGlobalVisualStudio7Generator* gg =
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
fout << "<?xml version=\"1.0\" encoding = \""
<< gg->Encoding() << "\"?>\n"
<< "<VisualStudioProject\n" << "<VisualStudioProject\n"
<< "\tProjectType=\"Visual C++\"\n"; << "\tProjectType=\"Visual C++\"\n";
if(this->Version == VS71) if(this->Version == VS71)
@ -2059,8 +2065,6 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
{ {
keyword = "Win32Proj"; keyword = "Win32Proj";
} }
cmGlobalVisualStudio7Generator* gg =
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
fout << "\tName=\"" << projLabel << "\"\n"; fout << "\tName=\"" << projLabel << "\"\n";
if(this->Version >= VS8) if(this->Version >= VS8)
{ {

View File

@ -222,7 +222,8 @@ void cmVisualStudio10TargetGenerator::Generate()
//get the tools version to use //get the tools version to use
const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); const std::string toolsVer(this->GlobalGenerator->GetToolsVersion());
std::string project_defaults= std::string project_defaults=
"<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"; "<?xml version=\"1.0\" encoding=\"" +
this->GlobalGenerator->Encoding() + "\"?>\n";
project_defaults.append("<Project DefaultTargets=\"Build\" ToolsVersion=\""); project_defaults.append("<Project DefaultTargets=\"Build\" ToolsVersion=\"");
project_defaults.append(toolsVer +"\" "); project_defaults.append(toolsVer +"\" ");
project_defaults.append( project_defaults.append(
@ -732,7 +733,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
//get the tools version to use //get the tools version to use
const std::string toolsVer(this->GlobalGenerator->GetToolsVersion()); const std::string toolsVer(this->GlobalGenerator->GetToolsVersion());
std::string project_defaults= std::string project_defaults=
"<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n"; "<?xml version=\"1.0\" encoding=\"" +
this->GlobalGenerator->Encoding() + "\"?>\n";
project_defaults.append("<Project ToolsVersion=\""); project_defaults.append("<Project ToolsVersion=\"");
project_defaults.append(toolsVer +"\" "); project_defaults.append(toolsVer +"\" ");
project_defaults.append( project_defaults.append(