summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmIDEOptions.cxx27
-rw-r--r--Source/cmIDEOptions.h19
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx62
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h3
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx41
6 files changed, 89 insertions, 65 deletions
diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx
index 1f3c066..dfbece7 100644
--- a/Source/cmIDEOptions.cxx
+++ b/Source/cmIDEOptions.cxx
@@ -152,18 +152,7 @@ void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry,
}
else if(entry->special & cmIDEFlagTable::SemicolonAppendable)
{
- std::map<std::string,std::string>::iterator itr;
- itr = this->FlagMap.find(entry->IDEName);
- if(itr != this->FlagMap.end())
- {
- // Append to old value (if present) with semicolons;
- itr->second += ";";
- itr->second += new_value;
- }
- else
- {
- this->FlagMap[entry->IDEName] = new_value;
- }
+ this->FlagMap[entry->IDEName].push_back(new_value);
}
else
{
@@ -200,6 +189,13 @@ void cmIDEOptions::AddFlag(const char* flag, const char* value)
}
//----------------------------------------------------------------------------
+void cmIDEOptions::AddFlag(const char* flag,
+ std::vector<std::string> const& value)
+{
+ this->FlagMap[flag] = value;
+}
+
+//----------------------------------------------------------------------------
void cmIDEOptions::RemoveFlag(const char* flag)
{
this->FlagMap.erase(flag);
@@ -208,10 +204,11 @@ void cmIDEOptions::RemoveFlag(const char* flag)
//----------------------------------------------------------------------------
const char* cmIDEOptions::GetFlag(const char* flag)
{
- std::map<std::string, std::string>::iterator i = this->FlagMap.find(flag);
- if(i != this->FlagMap.end())
+ // This method works only for single-valued flags!
+ std::map<std::string, FlagValue>::iterator i = this->FlagMap.find(flag);
+ if(i != this->FlagMap.end() && i->second.size() == 1)
{
- return i->second.c_str();
+ return i->second[0].c_str();
}
return 0;
}
diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h
index e7749ec..313c003 100644
--- a/Source/cmIDEOptions.h
+++ b/Source/cmIDEOptions.h
@@ -29,6 +29,7 @@ public:
void AddDefines(const char* defines);
void AddDefines(const std::vector<std::string> &defines);
void AddFlag(const char* flag, const char* value);
+ void AddFlag(const char* flag, std::vector<std::string> const& value);
void RemoveFlag(const char* flag);
const char* GetFlag(const char* flag);
@@ -40,7 +41,23 @@ protected:
// Then parse the command line flags specified in CMAKE_CXX_FLAGS
// and CMAKE_C_FLAGS
// and overwrite or add new values to this map
- std::map<std::string, std::string> FlagMap;
+ class FlagValue: public std::vector<std::string>
+ {
+ typedef std::vector<std::string> derived;
+ public:
+ FlagValue& operator=(std::string const& r)
+ {
+ this->resize(1);
+ this->operator[](0) = r;
+ return *this;
+ }
+ FlagValue& operator=(std::vector<std::string> const& r)
+ {
+ this->derived::operator=(r);
+ return *this;
+ }
+ };
+ std::map<std::string, FlagValue > FlagMap;
// Preprocessor definitions.
std::vector<std::string> Defines;
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index e0fe0fd..3ed4a48 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1013,7 +1013,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
if(!this->ModuleDefinitionFile.empty())
{
std::string defFile =
- this->ConvertToXMLOutputPath(this->ModuleDefinitionFile.c_str());
+ this->ConvertToOptionallyRelativeOutputPath(this->ModuleDefinitionFile);
linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str());
}
switch(target.GetType())
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 15439f6..5674317 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -343,19 +343,20 @@ void cmVisualStudio10TargetGenerator::Generate()
}
this->WriteString("<Platform>", 2);
- (*this->BuildFileStream) << this->Platform << "</Platform>\n";
+ (*this->BuildFileStream) << cmVS10EscapeXML(this->Platform)
+ << "</Platform>\n";
const char* projLabel = this->Target->GetProperty("PROJECT_LABEL");
if(!projLabel)
{
projLabel = this->Name.c_str();
}
this->WriteString("<ProjectName>", 2);
- (*this->BuildFileStream) << projLabel << "</ProjectName>\n";
+ (*this->BuildFileStream) << cmVS10EscapeXML(projLabel) << "</ProjectName>\n";
if(const char* targetFrameworkVersion = this->Target->GetProperty(
"VS_DOTNET_TARGET_FRAMEWORK_VERSION"))
{
this->WriteString("<TargetFrameworkVersion>", 2);
- (*this->BuildFileStream) << targetFrameworkVersion
+ (*this->BuildFileStream) << cmVS10EscapeXML(targetFrameworkVersion)
<< "</TargetFrameworkVersion>\n";
}
this->WriteString("</PropertyGroup>\n", 1);
@@ -507,7 +508,8 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurations()
this->WriteString("<Configuration>", 3);
(*this->BuildFileStream ) << *i << "</Configuration>\n";
this->WriteString("<Platform>", 3);
- (*this->BuildFileStream) << this->Platform << "</Platform>\n";
+ (*this->BuildFileStream) << cmVS10EscapeXML(this->Platform)
+ << "</Platform>\n";
this->WriteString("</ProjectConfiguration>\n", 2);
}
this->WriteString("</ItemGroup>\n", 1);
@@ -700,7 +702,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
(*this->BuildFileStream ) << script << "</Command>\n";
this->WritePlatformConfigTag("AdditionalInputs", i->c_str(), 3);
- (*this->BuildFileStream ) << source->GetFullPath();
+ (*this->BuildFileStream ) << cmVS10EscapeXML(source->GetFullPath());
for(std::vector<std::string>::const_iterator d =
ccg.GetDepends().begin();
d != ccg.GetDepends().end();
@@ -710,7 +712,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
if(this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(), dep))
{
this->ConvertToWindowsSlash(dep);
- (*this->BuildFileStream ) << ";" << dep;
+ (*this->BuildFileStream ) << ";" << cmVS10EscapeXML(dep);
}
}
(*this->BuildFileStream ) << ";%(AdditionalInputs)</AdditionalInputs>\n";
@@ -723,7 +725,7 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
{
std::string out = *o;
this->ConvertToWindowsSlash(out);
- (*this->BuildFileStream ) << sep << out;
+ (*this->BuildFileStream ) << sep << cmVS10EscapeXML(out);
sep = ";";
}
(*this->BuildFileStream ) << "</Outputs>\n";
@@ -824,7 +826,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
std::string obj = (*oi)->GetFullPath();
this->WriteString("<EmbeddedResource Include=\"", 2);
this->ConvertToWindowsSlash(obj);
- (*this->BuildFileStream ) << obj << "\">\n";
+ (*this->BuildFileStream ) << cmVS10EscapeXML(obj) << "\">\n";
this->WriteString("<Filter>Resource Files</Filter>\n", 3);
this->WriteString("</EmbeddedResource>\n", 2);
}
@@ -843,7 +845,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
std::string obj = *oi;
this->WriteString("<Object Include=\"", 2);
this->ConvertToWindowsSlash(obj);
- (*this->BuildFileStream ) << obj << "\">\n";
+ (*this->BuildFileStream ) << cmVS10EscapeXML(obj) << "\">\n";
this->WriteString("<Filter>Object Libraries</Filter>\n", 3);
this->WriteString("</Object>\n", 2);
}
@@ -978,7 +980,7 @@ WriteGroupSources(const char* name,
std::string path = this->ConvertPath(source, s->RelativePath);
this->ConvertToWindowsSlash(path);
(*this->BuildFileStream) << name << " Include=\""
- << path;
+ << cmVS10EscapeXML(path);
if(strlen(filter))
{
(*this->BuildFileStream) << "\">\n";
@@ -1033,7 +1035,8 @@ void cmVisualStudio10TargetGenerator::WriteSource(
}
this->ConvertToWindowsSlash(sourceFile);
this->WriteString("<", 2);
- (*this->BuildFileStream ) << tool << " Include=\"" << sourceFile << "\"";
+ (*this->BuildFileStream ) << tool << " Include=\""
+ << cmVS10EscapeXML(sourceFile) << "\"";
if(sf->GetExtension() == "h" &&
this->IsResxHeader(sf->GetFullPath()))
@@ -1165,7 +1168,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
std::string obj = *oi;
this->WriteString("<Object Include=\"", 2);
this->ConvertToWindowsSlash(obj);
- (*this->BuildFileStream ) << obj << "\" />\n";
+ (*this->BuildFileStream ) << cmVS10EscapeXML(obj) << "\" />\n";
}
this->WriteString("</ItemGroup>\n", 1);
@@ -1735,6 +1738,9 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
}
// Replace spaces in libs with ;
cmSystemTools::ReplaceString(libs, " ", ";");
+ std::vector<std::string> libVec;
+ cmSystemTools::ExpandListArgument(libs, libVec);
+
cmComputeLinkInformation* pcli =
this->Target->GetLinkInformation(config.c_str());
if(!pcli)
@@ -1746,28 +1752,21 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
}
// add the libraries for the target to libs string
cmComputeLinkInformation& cli = *pcli;
- this->AddLibraries(cli, libs);
- linkOptions.AddFlag("AdditionalDependencies", libs.c_str());
+ this->AddLibraries(cli, libVec);
+ linkOptions.AddFlag("AdditionalDependencies", libVec);
std::vector<std::string> const& ldirs = cli.GetDirectories();
- const char* sep = "";
- std::string linkDirs;
+ std::vector<std::string> linkDirs;
for(std::vector<std::string>::const_iterator d = ldirs.begin();
d != ldirs.end(); ++d)
{
// first just full path
- linkDirs += sep;
- linkDirs += *d;
- sep = ";";
- linkDirs += sep;
+ linkDirs.push_back(*d);
// next path with configuration type Debug, Release, etc
- linkDirs += *d;
- linkDirs += "/$(Configuration)";
- linkDirs += sep;
+ linkDirs.push_back(*d + "/$(Configuration)");
}
- linkDirs += "%(AdditionalLibraryDirectories)";
- linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs.c_str());
- linkOptions.AddFlag("AdditionalDependencies", libs.c_str());
+ linkDirs.push_back("%(AdditionalLibraryDirectories)");
+ linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs);
std::string targetName;
std::string targetNameSO;
@@ -1867,11 +1866,10 @@ cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& config)
void cmVisualStudio10TargetGenerator::AddLibraries(
cmComputeLinkInformation& cli,
- std::string& libstring)
+ std::vector<std::string>& libVec)
{
typedef cmComputeLinkInformation::ItemVector ItemVector;
ItemVector libs = cli.GetItems();
- const char* sep = ";";
for(ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l)
{
if(l->IsPath)
@@ -1881,14 +1879,12 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED);
this->ConvertToWindowsSlash(path);
- libstring += sep;
- libstring += path;
+ libVec.push_back(path);
}
else if (!l->Target
|| l->Target->GetType() != cmTarget::INTERFACE_LIBRARY)
{
- libstring += sep;
- libstring += l->Value;
+ libVec.push_back(l->Value);
}
}
}
@@ -2051,7 +2047,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences()
path += dt->GetName();
path += ".vcxproj";
}
- (*this->BuildFileStream) << path << "\">\n";
+ (*this->BuildFileStream) << cmVS10EscapeXML(path) << "\">\n";
this->WriteString("<Project>", 3);
(*this->BuildFileStream)
<< this->GlobalGenerator->GetGUID(name.c_str())
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 6c92b57..7a329cb 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -90,7 +90,8 @@ private:
void WriteGroups();
void WriteProjectReferences();
bool OutputSourceSpecificFlags(cmSourceFile const* source);
- void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring);
+ void AddLibraries(cmComputeLinkInformation& cli,
+ std::vector<std::string>& libVec);
void WriteLibOptions(std::string const& config);
void WriteEvents(std::string const& configName);
void WriteEvent(const char* name,
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 2cbf5db..b14fc45 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -3,9 +3,9 @@
#include <cmsys/System.h>
#include "cmVisualStudio10TargetGenerator.h"
-inline std::string cmVisualStudio10GeneratorOptionsEscapeForXML(const char* s)
+static
+std::string cmVisualStudio10GeneratorOptionsEscapeForXML(std::string ret)
{
- std::string ret = s;
cmSystemTools::ReplaceString(ret, ";", "%3B");
cmSystemTools::ReplaceString(ret, "&", "&amp;");
cmSystemTools::ReplaceString(ret, "<", "&lt;");
@@ -13,9 +13,9 @@ inline std::string cmVisualStudio10GeneratorOptionsEscapeForXML(const char* s)
return ret;
}
-inline std::string cmVisualStudioGeneratorOptionsEscapeForXML(const char* s)
+static
+std::string cmVisualStudioGeneratorOptionsEscapeForXML(std::string ret)
{
- std::string ret = s;
cmSystemTools::ReplaceString(ret, "&", "&amp;");
cmSystemTools::ReplaceString(ret, "\"", "&quot;");
cmSystemTools::ReplaceString(ret, "<", "&lt;");
@@ -269,7 +269,7 @@ cmVisualStudioGeneratorOptions
// Escape this flag for the IDE.
if(this->Version >= cmLocalVisualStudioGenerator::VS10)
{
- define = cmVisualStudio10GeneratorOptionsEscapeForXML(define.c_str());
+ define = cmVisualStudio10GeneratorOptionsEscapeForXML(define);
if(lang == "RC")
{
@@ -278,7 +278,7 @@ cmVisualStudioGeneratorOptions
}
else
{
- define = cmVisualStudioGeneratorOptionsEscapeForXML(define.c_str());
+ define = cmVisualStudioGeneratorOptionsEscapeForXML(define);
}
// Store the flag in the project file.
fout << sep << define;
@@ -301,7 +301,7 @@ cmVisualStudioGeneratorOptions
{
if(this->Version >= cmLocalVisualStudioGenerator::VS10)
{
- for(std::map<std::string, std::string>::iterator m = this->FlagMap.begin();
+ for(std::map<std::string, FlagValue>::iterator m = this->FlagMap.begin();
m != this->FlagMap.end(); ++m)
{
fout << indent;
@@ -317,20 +317,34 @@ cmVisualStudioGeneratorOptions
{
fout << "<" << m->first << ">";
}
- fout << m->second;
+ const char* sep = "";
+ for(std::vector<std::string>::iterator i = m->second.begin();
+ i != m->second.end(); ++i)
+ {
+ fout << sep << cmVisualStudio10GeneratorOptionsEscapeForXML(*i);
+ sep = ";";
+ }
if (m->first == "AdditionalIncludeDirectories")
{
- fout << ";%(AdditionalIncludeDirectories)";
+ fout << sep << "%(AdditionalIncludeDirectories)";
}
fout << "</" << m->first << ">\n";
}
}
else
{
- for(std::map<std::string, std::string>::iterator m = this->FlagMap.begin();
+ for(std::map<std::string, FlagValue>::iterator m = this->FlagMap.begin();
m != this->FlagMap.end(); ++m)
{
- fout << indent << m->first << "=\"" << m->second << "\"\n";
+ fout << indent << m->first << "=\"";
+ const char* sep = "";
+ for(std::vector<std::string>::iterator i = m->second.begin();
+ i != m->second.end(); ++i)
+ {
+ fout << sep << cmVisualStudioGeneratorOptionsEscapeForXML(*i);
+ sep = ";";
+ }
+ fout << "\"\n";
}
}
}
@@ -359,14 +373,13 @@ cmVisualStudioGeneratorOptions
{
fout << "<AdditionalOptions>";
}
- fout << this->FlagString.c_str()
+ fout << cmVisualStudio10GeneratorOptionsEscapeForXML(this->FlagString)
<< " %(AdditionalOptions)</AdditionalOptions>\n";
}
else
{
fout << prefix << "AdditionalOptions=\"";
- fout <<
- cmVisualStudioGeneratorOptionsEscapeForXML(this->FlagString.c_str());
+ fout << cmVisualStudioGeneratorOptionsEscapeForXML(this->FlagString);
fout << "\"" << suffix;
}
}