Merge topic 'vs-refactor-includes'
5fcb42ab
VS: Refactor include directory generation in .vcxproj files8e026aa7
VS: Refactor include directory slash conversion9633d112
cmIDEOptions: Add HasFlag method to test if a flag is set84100102
cmIDEOptions: Add an AppendFlag overload to append multiple values
This commit is contained in:
commit
9f4701bde9
|
@ -202,12 +202,26 @@ void cmIDEOptions::AppendFlag(std::string const& flag,
|
||||||
this->FlagMap[flag].push_back(value);
|
this->FlagMap[flag].push_back(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
void cmIDEOptions::AppendFlag(std::string const& flag,
|
||||||
|
std::vector<std::string> const& value)
|
||||||
|
{
|
||||||
|
FlagValue& fv = this->FlagMap[flag];
|
||||||
|
std::copy(value.begin(), value.end(), std::back_inserter(fv));
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmIDEOptions::RemoveFlag(const char* flag)
|
void cmIDEOptions::RemoveFlag(const char* flag)
|
||||||
{
|
{
|
||||||
this->FlagMap.erase(flag);
|
this->FlagMap.erase(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------
|
||||||
|
bool cmIDEOptions::HasFlag(std::string const& flag) const
|
||||||
|
{
|
||||||
|
return this->FlagMap.find(flag) != this->FlagMap.end();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
const char* cmIDEOptions::GetFlag(const char* flag)
|
const char* cmIDEOptions::GetFlag(const char* flag)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,7 +31,10 @@ public:
|
||||||
void AddFlag(const char* flag, const char* value);
|
void AddFlag(const char* flag, const char* value);
|
||||||
void AddFlag(const char* flag, std::vector<std::string> const& value);
|
void AddFlag(const char* flag, std::vector<std::string> const& value);
|
||||||
void AppendFlag(std::string const& flag, std::string const& value);
|
void AppendFlag(std::string const& flag, std::string const& value);
|
||||||
|
void AppendFlag(std::string const& flag,
|
||||||
|
std::vector<std::string> const& value);
|
||||||
void RemoveFlag(const char* flag);
|
void RemoveFlag(const char* flag);
|
||||||
|
bool HasFlag(std::string const& flag) const;
|
||||||
const char* GetFlag(const char* flag);
|
const char* GetFlag(const char* flag);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -1374,6 +1374,11 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
||||||
clOptions.AddFlag("CompileAs", compileAs);
|
clOptions.AddFlag("CompileAs", compileAs);
|
||||||
}
|
}
|
||||||
clOptions.Parse(flags.c_str());
|
clOptions.Parse(flags.c_str());
|
||||||
|
if(clOptions.HasFlag("AdditionalIncludeDirectories"))
|
||||||
|
{
|
||||||
|
clOptions.AppendFlag("AdditionalIncludeDirectories",
|
||||||
|
"%(AdditionalIncludeDirectories)");
|
||||||
|
}
|
||||||
clOptions.AddDefines(configDefines.c_str());
|
clOptions.AddDefines(configDefines.c_str());
|
||||||
clOptions.SetConfiguration((*config).c_str());
|
clOptions.SetConfiguration((*config).c_str());
|
||||||
clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
||||||
|
@ -1615,7 +1620,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
|
||||||
Options& clOptions = *(this->ClOptions[configName]);
|
Options& clOptions = *(this->ClOptions[configName]);
|
||||||
this->WriteString("<ClCompile>\n", 2);
|
this->WriteString("<ClCompile>\n", 2);
|
||||||
clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
||||||
this->OutputIncludes(includes);
|
clOptions.AppendFlag("AdditionalIncludeDirectories", includes);
|
||||||
|
clOptions.AppendFlag("AdditionalIncludeDirectories",
|
||||||
|
"%(AdditionalIncludeDirectories)");
|
||||||
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
||||||
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
|
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
|
||||||
"\n", "CXX");
|
"\n", "CXX");
|
||||||
|
@ -1646,23 +1653,6 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
|
||||||
this->WriteString("</ClCompile>\n", 2);
|
this->WriteString("</ClCompile>\n", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmVisualStudio10TargetGenerator::
|
|
||||||
OutputIncludes(std::vector<std::string> const & includes)
|
|
||||||
{
|
|
||||||
this->WriteString("<AdditionalIncludeDirectories>", 3);
|
|
||||||
for(std::vector<std::string>::const_iterator i = includes.begin();
|
|
||||||
i != includes.end(); ++i)
|
|
||||||
{
|
|
||||||
std::string incDir = *i;
|
|
||||||
this->ConvertToWindowsSlash(incDir);
|
|
||||||
*this->BuildFileStream << cmVS10EscapeXML(incDir) << ";";
|
|
||||||
}
|
|
||||||
this->WriteString("%(AdditionalIncludeDirectories)"
|
|
||||||
"</AdditionalIncludeDirectories>\n", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
|
bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
|
||||||
{
|
{
|
||||||
|
@ -1714,9 +1704,11 @@ WriteRCOptions(std::string const& configName,
|
||||||
Options& clOptions = *(this->ClOptions[configName]);
|
Options& clOptions = *(this->ClOptions[configName]);
|
||||||
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
|
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
|
||||||
"\n", "RC");
|
"\n", "RC");
|
||||||
this->OutputIncludes(includes);
|
|
||||||
|
|
||||||
Options& rcOptions = *(this->RcOptions[configName]);
|
Options& rcOptions = *(this->RcOptions[configName]);
|
||||||
|
rcOptions.AppendFlag("AdditionalIncludeDirectories", includes);
|
||||||
|
rcOptions.AppendFlag("AdditionalIncludeDirectories",
|
||||||
|
"%(AdditionalIncludeDirectories)");
|
||||||
rcOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
rcOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
||||||
rcOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
rcOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
||||||
|
|
||||||
|
@ -2022,7 +2014,14 @@ WriteMidlOptions(std::string const& /*config*/,
|
||||||
// only). Perhaps there's something to be done to make this more automatic
|
// only). Perhaps there's something to be done to make this more automatic
|
||||||
// on the CMake side?
|
// on the CMake side?
|
||||||
this->WriteString("<Midl>\n", 2);
|
this->WriteString("<Midl>\n", 2);
|
||||||
this->OutputIncludes(includes);
|
this->WriteString("<AdditionalIncludeDirectories>", 3);
|
||||||
|
for(std::vector<std::string>::const_iterator i = includes.begin();
|
||||||
|
i != includes.end(); ++i)
|
||||||
|
{
|
||||||
|
*this->BuildFileStream << cmVS10EscapeXML(*i) << ";";
|
||||||
|
}
|
||||||
|
this->WriteString("%(AdditionalIncludeDirectories)"
|
||||||
|
"</AdditionalIncludeDirectories>\n", 0);
|
||||||
this->WriteString("<OutputDirectory>$(IntDir)</OutputDirectory>\n", 3);
|
this->WriteString("<OutputDirectory>$(IntDir)</OutputDirectory>\n", 3);
|
||||||
this->WriteString("<HeaderFileName>%(Filename).h</HeaderFileName>\n", 3);
|
this->WriteString("<HeaderFileName>%(Filename).h</HeaderFileName>\n", 3);
|
||||||
this->WriteString(
|
this->WriteString(
|
||||||
|
@ -2047,6 +2046,11 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
|
||||||
this->LocalGenerator->GetIncludeDirectories(includes,
|
this->LocalGenerator->GetIncludeDirectories(includes,
|
||||||
this->GeneratorTarget,
|
this->GeneratorTarget,
|
||||||
"C", i->c_str());
|
"C", i->c_str());
|
||||||
|
for(std::vector<std::string>::iterator ii = includes.begin();
|
||||||
|
ii != includes.end(); ++ii)
|
||||||
|
{
|
||||||
|
this->ConvertToWindowsSlash(*ii);
|
||||||
|
}
|
||||||
this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1);
|
this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1);
|
||||||
*this->BuildFileStream << "\n";
|
*this->BuildFileStream << "\n";
|
||||||
// output cl compile flags <ClCompile></ClCompile>
|
// output cl compile flags <ClCompile></ClCompile>
|
||||||
|
|
|
@ -83,7 +83,6 @@ private:
|
||||||
void WriteLinkOptions(std::string const& config);
|
void WriteLinkOptions(std::string const& config);
|
||||||
void WriteMidlOptions(std::string const& config,
|
void WriteMidlOptions(std::string const& config,
|
||||||
std::vector<std::string> const & includes);
|
std::vector<std::string> const & includes);
|
||||||
void OutputIncludes(std::vector<std::string> const & includes);
|
|
||||||
void OutputLinkIncremental(std::string const& configName);
|
void OutputLinkIncremental(std::string const& configName);
|
||||||
void WriteCustomRule(cmSourceFile const* source,
|
void WriteCustomRule(cmSourceFile const* source,
|
||||||
cmCustomCommand const & command);
|
cmCustomCommand const & command);
|
||||||
|
|
|
@ -324,10 +324,6 @@ cmVisualStudioGeneratorOptions
|
||||||
fout << sep << cmVisualStudio10GeneratorOptionsEscapeForXML(*i);
|
fout << sep << cmVisualStudio10GeneratorOptionsEscapeForXML(*i);
|
||||||
sep = ";";
|
sep = ";";
|
||||||
}
|
}
|
||||||
if (m->first == "AdditionalIncludeDirectories")
|
|
||||||
{
|
|
||||||
fout << sep << "%(AdditionalIncludeDirectories)";
|
|
||||||
}
|
|
||||||
fout << "</" << m->first << ">\n";
|
fout << "</" << m->first << ">\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue