Detect and set Unicode character set in VS 10
This commit teaches the VS 10 generator to detect the -D_UNICODE option in preprocessor definitions and set the CharacterSet attribute to the value 'Unicode'. This was already done for other VS IDE versions. See issue #9769
This commit is contained in:
parent
d4377c3377
commit
5484550af6
|
@ -22,6 +22,8 @@
|
||||||
#include "cmVS10LinkFlagTable.h"
|
#include "cmVS10LinkFlagTable.h"
|
||||||
#include "cmVS10LibFlagTable.h"
|
#include "cmVS10LibFlagTable.h"
|
||||||
|
|
||||||
|
#include <cmsys/auto_ptr.hxx>
|
||||||
|
|
||||||
static std::string cmVS10EscapeXML(std::string arg)
|
static std::string cmVS10EscapeXML(std::string arg)
|
||||||
{
|
{
|
||||||
cmSystemTools::ReplaceString(arg, "&", "&");
|
cmSystemTools::ReplaceString(arg, "&", "&");
|
||||||
|
@ -50,6 +52,11 @@ cmVisualStudio10TargetGenerator(cmTarget* target,
|
||||||
|
|
||||||
cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
|
cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
|
||||||
{
|
{
|
||||||
|
for(OptionsMap::iterator i = this->ClOptions.begin();
|
||||||
|
i != this->ClOptions.end(); ++i)
|
||||||
|
{
|
||||||
|
delete i->second;
|
||||||
|
}
|
||||||
if(!this->BuildFileStream)
|
if(!this->BuildFileStream)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -116,6 +123,10 @@ void cmVisualStudio10TargetGenerator::Generate()
|
||||||
this->Target->SetProperty("GENERATOR_FILE_NAME",this->Name.c_str());
|
this->Target->SetProperty("GENERATOR_FILE_NAME",this->Name.c_str());
|
||||||
this->Target->SetProperty("GENERATOR_FILE_NAME_EXT",
|
this->Target->SetProperty("GENERATOR_FILE_NAME_EXT",
|
||||||
".vcxproj");
|
".vcxproj");
|
||||||
|
if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY)
|
||||||
|
{
|
||||||
|
this->ComputeClOptions();
|
||||||
|
}
|
||||||
cmMakefile* mf = this->Target->GetMakefile();
|
cmMakefile* mf = this->Target->GetMakefile();
|
||||||
std::string path = mf->GetStartOutputDirectory();
|
std::string path = mf->GetStartOutputDirectory();
|
||||||
path += "/";
|
path += "/";
|
||||||
|
@ -237,7 +248,15 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
|
||||||
{
|
{
|
||||||
this->WriteString("<UseOfMfc>false</UseOfMfc>\n", 2);
|
this->WriteString("<UseOfMfc>false</UseOfMfc>\n", 2);
|
||||||
}
|
}
|
||||||
this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
|
if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY &&
|
||||||
|
this->ClOptions[*i]->UsingUnicode())
|
||||||
|
{
|
||||||
|
this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
|
||||||
|
}
|
||||||
this->WriteString("</PropertyGroup>\n", 1);
|
this->WriteString("</PropertyGroup>\n", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -831,21 +850,31 @@ OutputLinkIncremental(std::string const& configName)
|
||||||
<< "</LinkIncremental>\n";
|
<< "</LinkIncremental>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
void
|
void cmVisualStudio10TargetGenerator::ComputeClOptions()
|
||||||
cmVisualStudio10TargetGenerator::
|
|
||||||
WriteClOptions(std::string const& configName,
|
|
||||||
std::vector<std::string> const & includes)
|
|
||||||
{
|
{
|
||||||
|
std::vector<std::string> const* configs =
|
||||||
|
this->GlobalGenerator->GetConfigurations();
|
||||||
|
for(std::vector<std::string>::const_iterator i = configs->begin();
|
||||||
|
i != configs->end(); ++i)
|
||||||
|
{
|
||||||
|
this->ComputeClOptions(*i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmVisualStudio10TargetGenerator::ComputeClOptions(
|
||||||
|
std::string const& configName)
|
||||||
|
{
|
||||||
// much of this was copied from here:
|
// much of this was copied from here:
|
||||||
// copied from cmLocalVisualStudio7Generator.cxx 805
|
// copied from cmLocalVisualStudio7Generator.cxx 805
|
||||||
|
// TODO: Integrate code below with cmLocalVisualStudio7Generator.
|
||||||
|
|
||||||
|
cmsys::auto_ptr<Options> pOptions(
|
||||||
|
new Options(this->LocalGenerator, 10, Options::Compiler,
|
||||||
|
cmVS10CLFlagTable));
|
||||||
|
Options& clOptions = *pOptions;
|
||||||
|
|
||||||
this->WriteString("<ClCompile>\n", 2);
|
|
||||||
cmVisualStudioGeneratorOptions
|
|
||||||
clOptions(this->LocalGenerator,
|
|
||||||
10, cmVisualStudioGeneratorOptions::Compiler,
|
|
||||||
cmVS10CLFlagTable);
|
|
||||||
std::string flags;
|
std::string flags;
|
||||||
// collect up flags for
|
// collect up flags for
|
||||||
if(this->Target->GetType() < cmTarget::UTILITY)
|
if(this->Target->GetType() < cmTarget::UTILITY)
|
||||||
|
@ -915,6 +944,17 @@ WriteClOptions(std::string const& configName,
|
||||||
{
|
{
|
||||||
clOptions.AddDefine(exportMacro);
|
clOptions.AddDefine(exportMacro);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->ClOptions[configName] = pOptions.release();
|
||||||
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmVisualStudio10TargetGenerator::WriteClOptions(
|
||||||
|
std::string const& configName,
|
||||||
|
std::vector<std::string> const& includes)
|
||||||
|
{
|
||||||
|
Options& clOptions = *(this->ClOptions[configName]);
|
||||||
|
this->WriteString("<ClCompile>\n", 2);
|
||||||
clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
||||||
this->OutputIncludes(includes);
|
this->OutputIncludes(includes);
|
||||||
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
||||||
|
|
|
@ -21,6 +21,7 @@ class cmSourceFile;
|
||||||
class cmCustomCommand;
|
class cmCustomCommand;
|
||||||
class cmLocalVisualStudio7Generator;
|
class cmLocalVisualStudio7Generator;
|
||||||
class cmComputeLinkInformation;
|
class cmComputeLinkInformation;
|
||||||
|
class cmVisualStudioGeneratorOptions;
|
||||||
#include "cmSourceGroup.h"
|
#include "cmSourceGroup.h"
|
||||||
|
|
||||||
class cmVisualStudio10TargetGenerator
|
class cmVisualStudio10TargetGenerator
|
||||||
|
@ -49,6 +50,8 @@ private:
|
||||||
void WriteObjSources();
|
void WriteObjSources();
|
||||||
void WritePathAndIncrementalLinkOptions();
|
void WritePathAndIncrementalLinkOptions();
|
||||||
void WriteItemDefinitionGroups();
|
void WriteItemDefinitionGroups();
|
||||||
|
void ComputeClOptions();
|
||||||
|
void ComputeClOptions(std::string const& configName);
|
||||||
void WriteClOptions(std::string const& config,
|
void WriteClOptions(std::string const& config,
|
||||||
std::vector<std::string> const & includes);
|
std::vector<std::string> const & includes);
|
||||||
void WriteRCOptions(std::string const& config,
|
void WriteRCOptions(std::string const& config,
|
||||||
|
@ -75,6 +78,9 @@ private:
|
||||||
std::vector<cmSourceFile*> const& sources,
|
std::vector<cmSourceFile*> const& sources,
|
||||||
std::vector<cmSourceGroup>& );
|
std::vector<cmSourceGroup>& );
|
||||||
private:
|
private:
|
||||||
|
typedef cmVisualStudioGeneratorOptions Options;
|
||||||
|
typedef std::map<cmStdString, Options*> OptionsMap;
|
||||||
|
OptionsMap ClOptions;
|
||||||
std::string ModuleDefinitionFile;
|
std::string ModuleDefinitionFile;
|
||||||
std::string PathToVcxproj;
|
std::string PathToVcxproj;
|
||||||
cmTarget* Target;
|
cmTarget* Target;
|
||||||
|
|
Loading…
Reference in New Issue