summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-10-23 11:34:37 -0400
committerBrad King <brad.king@kitware.com>2009-10-23 11:34:37 -0400
commit5484550af63946292c96baba472b7a959f0dfb9d (patch)
tree92ed5338eaca8c4a445a98af6b49c74372faf6ba
parentd4377c33777fe523edd3b9744a85c360feba5fa0 (diff)
downloadcmake-5484550af63946292c96baba472b7a959f0dfb9d.tar.gz
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
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx62
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h6
2 files changed, 57 insertions, 11 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 154fe6c9e7..f0ce049d02 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -22,6 +22,8 @@
#include "cmVS10LinkFlagTable.h"
#include "cmVS10LibFlagTable.h"
+#include <cmsys/auto_ptr.hxx>
+
static std::string cmVS10EscapeXML(std::string arg)
{
cmSystemTools::ReplaceString(arg, "&", "&amp;");
@@ -50,6 +52,11 @@ cmVisualStudio10TargetGenerator(cmTarget* target,
cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
{
+ for(OptionsMap::iterator i = this->ClOptions.begin();
+ i != this->ClOptions.end(); ++i)
+ {
+ delete i->second;
+ }
if(!this->BuildFileStream)
{
return;
@@ -116,6 +123,10 @@ void cmVisualStudio10TargetGenerator::Generate()
this->Target->SetProperty("GENERATOR_FILE_NAME",this->Name.c_str());
this->Target->SetProperty("GENERATOR_FILE_NAME_EXT",
".vcxproj");
+ if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY)
+ {
+ this->ComputeClOptions();
+ }
cmMakefile* mf = this->Target->GetMakefile();
std::string path = mf->GetStartOutputDirectory();
path += "/";
@@ -237,7 +248,15 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
{
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);
}
}
@@ -831,21 +850,31 @@ OutputLinkIncremental(std::string const& configName)
<< "</LinkIncremental>\n";
}
+//----------------------------------------------------------------------------
+void cmVisualStudio10TargetGenerator::ComputeClOptions()
+{
+ 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::
-WriteClOptions(std::string const& configName,
- std::vector<std::string> const & includes)
+//----------------------------------------------------------------------------
+void cmVisualStudio10TargetGenerator::ComputeClOptions(
+ std::string const& configName)
{
-
// much of this was copied from here:
// 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;
// collect up flags for
if(this->Target->GetType() < cmTarget::UTILITY)
@@ -915,6 +944,17 @@ WriteClOptions(std::string const& configName,
{
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, " ", "");
this->OutputIncludes(includes);
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index f70a06696a..989db71a06 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -21,6 +21,7 @@ class cmSourceFile;
class cmCustomCommand;
class cmLocalVisualStudio7Generator;
class cmComputeLinkInformation;
+class cmVisualStudioGeneratorOptions;
#include "cmSourceGroup.h"
class cmVisualStudio10TargetGenerator
@@ -49,6 +50,8 @@ private:
void WriteObjSources();
void WritePathAndIncrementalLinkOptions();
void WriteItemDefinitionGroups();
+ void ComputeClOptions();
+ void ComputeClOptions(std::string const& configName);
void WriteClOptions(std::string const& config,
std::vector<std::string> const & includes);
void WriteRCOptions(std::string const& config,
@@ -75,6 +78,9 @@ private:
std::vector<cmSourceFile*> const& sources,
std::vector<cmSourceGroup>& );
private:
+ typedef cmVisualStudioGeneratorOptions Options;
+ typedef std::map<cmStdString, Options*> OptionsMap;
+ OptionsMap ClOptions;
std::string ModuleDefinitionFile;
std::string PathToVcxproj;
cmTarget* Target;