summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-10-23 15:34:37 (GMT)
committerBrad King <brad.king@kitware.com>2009-10-23 15:34:37 (GMT)
commit5484550af63946292c96baba472b7a959f0dfb9d (patch)
tree92ed5338eaca8c4a445a98af6b49c74372faf6ba /Source/cmVisualStudio10TargetGenerator.cxx
parentd4377c33777fe523edd3b9744a85c360feba5fa0 (diff)
downloadCMake-5484550af63946292c96baba472b7a959f0dfb9d.zip
CMake-5484550af63946292c96baba472b7a959f0dfb9d.tar.gz
CMake-5484550af63946292c96baba472b7a959f0dfb9d.tar.bz2
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
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx62
1 files changed, 51 insertions, 11 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 154fe6c..f0ce049 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, " ");