summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx223
1 files changed, 138 insertions, 85 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 4cfb561..e06dc9b 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -80,10 +80,10 @@ struct cmVisualStudio10TargetGenerator::Elem
bool HasContent = false;
std::string Tag;
- Elem(std::ostream& s, const std::string& tag)
+ Elem(std::ostream& s, std::string tag)
: S(s)
, Indent(0)
- , Tag(tag)
+ , Tag(std::move(tag))
{
this->StartElement();
}
@@ -200,7 +200,7 @@ struct cmVisualStudio10TargetGenerator::OptionsHelper
}
};
-static std::string cmVS10EscapeComment(std::string comment)
+static std::string cmVS10EscapeComment(std::string const& comment)
{
// MSBuild takes the CDATA of a <Message></Message> element and just
// does "echo $CDATA" with no escapes. We must encode the string.
@@ -275,8 +275,8 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
this->Makefile->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig);
this->NsightTegra = gg->IsNsightTegra();
this->Android = gg->TargetsAndroid();
- for (int i = 0; i < 4; ++i) {
- this->NsightTegraVersion[i] = 0;
+ for (unsigned int& version : this->NsightTegraVersion) {
+ version = 0;
}
sscanf(gg->GetNsightTegraVersion().c_str(), "%u.%u.%u.%u",
&this->NsightTegraVersion[0], &this->NsightTegraVersion[1],
@@ -293,9 +293,7 @@ cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
this->ClassifyAllConfigSources();
}
-cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
-{
-}
+cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator() = default;
std::string cmVisualStudio10TargetGenerator::CalcCondition(
const std::string& config) const
@@ -406,6 +404,9 @@ void cmVisualStudio10TargetGenerator::Generate()
if (!this->ComputeCudaLinkOptions()) {
return;
}
+ if (!this->ComputeMarmasmOptions()) {
+ return;
+ }
if (!this->ComputeMasmOptions()) {
return;
}
@@ -423,7 +424,7 @@ void cmVisualStudio10TargetGenerator::Generate()
cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
this->Name, ProjectFileExtension);
cmGeneratedFileStream BuildFileStream(path);
- const std::string PathToProjectFile = path;
+ const std::string& PathToProjectFile = path;
BuildFileStream.SetCopyIfDifferent(true);
// Write the encoding header into the file
@@ -453,7 +454,7 @@ void cmVisualStudio10TargetGenerator::Generate()
void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
cmGeneratedFileStream& BuildFileStream)
{
- BuildFileStream << "<?xml version=\"1.0\" encoding=\""
+ BuildFileStream << R"(<?xml version="1.0" encoding=")"
<< this->GlobalGenerator->Encoding() << "\"?>";
{
Elem e0(BuildFileStream, "Project");
@@ -725,13 +726,18 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
: customDir +
this->GlobalGenerator
->GetPlatformToolsetCudaVSIntegrationSubdirString() +
- "extras\\visual_studio_integration\\MSBuildExtensions\\";
+ R"(extras\visual_studio_integration\MSBuildExtensions\)";
Elem(e1, "Import")
.Attribute("Project",
std::move(cudaPath) + "CUDA " +
this->GlobalGenerator->GetPlatformToolsetCuda() +
".props");
}
+ if (this->GlobalGenerator->IsMarmasmEnabled()) {
+ Elem(e1, "Import")
+ .Attribute("Project",
+ "$(VCTargetsPath)\\BuildCustomizations\\marmasm.props");
+ }
if (this->GlobalGenerator->IsMasmEnabled()) {
Elem(e1, "Import")
.Attribute("Project",
@@ -823,13 +829,18 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile(
: customDir +
this->GlobalGenerator
->GetPlatformToolsetCudaVSIntegrationSubdirString() +
- "extras\\visual_studio_integration\\MSBuildExtensions\\";
+ R"(extras\visual_studio_integration\MSBuildExtensions\)";
Elem(e1, "Import")
.Attribute("Project",
std::move(cudaPath) + "CUDA " +
this->GlobalGenerator->GetPlatformToolsetCuda() +
".targets");
}
+ if (this->GlobalGenerator->IsMarmasmEnabled()) {
+ Elem(e1, "Import")
+ .Attribute("Project",
+ "$(VCTargetsPath)\\BuildCustomizations\\marmasm.targets");
+ }
if (this->GlobalGenerator->IsMasmEnabled()) {
Elem(e1, "Import")
.Attribute("Project",
@@ -1020,8 +1031,9 @@ void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1)
std::vector<std::string> keys = this->GeneratorTarget->GetPropertyKeys();
for (std::string const& keyIt : keys) {
static const cm::string_view prefix = "VS_GLOBAL_";
- if (!cmHasPrefix(keyIt, prefix))
+ if (!cmHasPrefix(keyIt, prefix)) {
continue;
+ }
cm::string_view globalKey = cm::string_view(keyIt).substr(prefix.length());
// Skip invalid or separately-handled properties.
if (globalKey.empty() || globalKey == "PROJECT_TYPES" ||
@@ -1029,8 +1041,9 @@ void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1)
continue;
}
cmValue value = this->GeneratorTarget->GetProperty(keyIt);
- if (!value)
+ if (!value) {
continue;
+ }
e1.Element(globalKey, *value);
}
}
@@ -1043,14 +1056,11 @@ bool cmVisualStudio10TargetGenerator::HasCustomCommands() const
return true;
}
- for (cmGeneratorTarget::AllConfigSource const& si :
- this->GeneratorTarget->GetAllConfigSources()) {
- if (si.Source->GetCustomCommand()) {
- return true;
- }
- }
-
- return false;
+ auto const& config_sources = this->GeneratorTarget->GetAllConfigSources();
+ return std::any_of(config_sources.begin(), config_sources.end(),
+ [](cmGeneratorTarget::AllConfigSource const& si) {
+ return si.Source->GetCustomCommand();
+ });
}
void cmVisualStudio10TargetGenerator::WritePackageReferences(Elem& e0)
@@ -1220,7 +1230,7 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0)
e2.Attribute("Include", obj);
if (this->ProjectType != VsProjectType::csproj) {
- std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h";
+ std::string hFileName = obj.substr(0, obj.find_last_of('.')) + ".h";
e2.Element("DependentUpon", hFileName);
for (std::string const& c : this->Configurations) {
@@ -1912,7 +1922,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
char magic[] = { char(0xEF), char(0xBB), char(0xBF) };
fout.write(magic, 3);
- fout << "<?xml version=\"1.0\" encoding=\""
+ fout << R"(<?xml version="1.0" encoding=")"
<< this->GlobalGenerator->Encoding() << "\"?>";
{
Elem e0(fout, "Project");
@@ -2068,7 +2078,7 @@ void cmVisualStudio10TargetGenerator::WriteHeaderSource(
e2.Element("FileType", "CppForm");
} else if (this->IsXamlHeader(fileName)) {
e2.Element("DependentUpon",
- fileName.substr(0, fileName.find_last_of(".")));
+ fileName.substr(0, fileName.find_last_of('.')));
}
this->FinishWritingSource(e2, toolSettings);
}
@@ -2077,7 +2087,7 @@ void cmVisualStudio10TargetGenerator::ParseSettingsProperty(
const std::string& settingsPropertyValue, ConfigToSettings& toolSettings)
{
if (!settingsPropertyValue.empty()) {
- cmGeneratorExpression ge;
+ cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance());
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(settingsPropertyValue);
@@ -2104,7 +2114,7 @@ void cmVisualStudio10TargetGenerator::ParseSettingsProperty(
bool cmVisualStudio10TargetGenerator::PropertyIsSameInAllConfigs(
const ConfigToSettings& toolSettings, const std::string& propName)
{
- std::string firstPropValue = "";
+ std::string firstPropValue;
for (const auto& configToSettings : toolSettings) {
const std::unordered_map<std::string, std::string>& settings =
configToSettings.second;
@@ -2177,7 +2187,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
}
// Figure out if there's any additional flags to use
if (cmValue saf = sf->GetProperty("VS_SHADER_FLAGS")) {
- cmGeneratorExpression ge;
+ cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance());
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*saf);
for (const std::string& config : this->Configurations) {
@@ -2190,7 +2200,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
}
// Figure out if debug information should be generated
if (cmValue sed = sf->GetProperty("VS_SHADER_ENABLE_DEBUG")) {
- cmGeneratorExpression ge;
+ cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance());
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*sed);
for (const std::string& config : this->Configurations) {
@@ -2204,7 +2214,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
}
// Figure out if optimizations should be disabled
if (cmValue sdo = sf->GetProperty("VS_SHADER_DISABLE_OPTIMIZATIONS")) {
- cmGeneratorExpression ge;
+ cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance());
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*sdo);
for (const std::string& config : this->Configurations) {
@@ -2318,26 +2328,23 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(
this->FinishWritingSource(e2, toolSettings);
if (!deployContent.empty()) {
- cmGeneratorExpression ge;
+ cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance());
std::unique_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(deployContent);
// Deployment location cannot be set on a configuration basis
if (!deployLocation.empty()) {
e2.Element("Link", deployLocation + "\\%(FileName)%(Extension)");
}
- for (size_t i = 0; i != this->Configurations.size(); ++i) {
- if (cge->Evaluate(this->LocalGenerator, this->Configurations[i]) ==
- "1") {
+ for (auto& config : this->Configurations) {
+ if (cge->Evaluate(this->LocalGenerator, config) == "1") {
e2.WritePlatformConfigTag("DeploymentContent",
"'$(Configuration)|$(Platform)'=='" +
- this->Configurations[i] + "|" +
- this->Platform + "'",
+ config + "|" + this->Platform + "'",
"true");
} else {
e2.WritePlatformConfigTag("ExcludedFromBuild",
"'$(Configuration)|$(Platform)'=='" +
- this->Configurations[i] + "|" +
- this->Platform + "'",
+ config + "|" + this->Platform + "'",
"true");
}
}
@@ -2388,8 +2395,9 @@ void cmVisualStudio10TargetGenerator::WriteSource(Elem& e2,
// added with the plain filename without any path. This means the file will
// show up at root-level of the csproj (where CMakeLists.txt etc. are).
std::string link = this->GetCSharpSourceLink(sf);
- if (link.empty())
+ if (link.empty()) {
link = cmsys::SystemTools::GetFilenameName(sf->GetFullPath());
+ }
e2.Element("Link", link);
}
@@ -2485,6 +2493,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
const std::string& lang = si.Source->GetLanguage();
if (lang == "C" || lang == "CXX") {
tool = "ClCompile";
+ } else if (lang == "ASM_MARMASM" &&
+ this->GlobalGenerator->IsMarmasmEnabled()) {
+ tool = "MARMASM";
} else if (lang == "ASM_MASM" &&
this->GlobalGenerator->IsMasmEnabled()) {
tool = "MASM";
@@ -2519,7 +2530,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
Elem e2(e1, tool);
bool isCSharp = (si.Source->GetLanguage() == "CSharp");
- if (isCSharp && exclude_configs.size() > 0) {
+ if (isCSharp && !exclude_configs.empty()) {
std::stringstream conditions;
bool firstConditionSet{ false };
for (const auto& ci : include_configs) {
@@ -2661,7 +2672,7 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
? "C"
: this->GlobalGenerator->GetLanguageFromExtension(ext.c_str());
std::string lang = this->LocalGenerator->GetSourceFileLanguage(sf);
- const char* compileAs = 0;
+ const char* compileAs = nullptr;
if (lang != extLang) {
if (lang == "CXX") {
// force a C++ file type
@@ -2740,6 +2751,9 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
const std::string& srclang = source->GetLanguage();
if (srclang == "C" || srclang == "CXX") {
flagtable = gg->GetClFlagTable();
+ } else if (srclang == "ASM_MARMASM" &&
+ this->GlobalGenerator->IsMarmasmEnabled()) {
+ flagtable = gg->GetMarmasmFlagTable();
} else if (srclang == "ASM_MASM" &&
this->GlobalGenerator->IsMasmEnabled()) {
flagtable = gg->GetMasmFlagTable();
@@ -2842,10 +2856,9 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
if (this->IsXamlSource(source->GetFullPath())) {
const std::string& fileName = source->GetFullPath();
e2.Element("DependentUpon",
- fileName.substr(0, fileName.find_last_of(".")));
+ fileName.substr(0, fileName.find_last_of('.')));
}
if (this->ProjectType == VsProjectType::csproj) {
- std::string f = source->GetFullPath();
using CsPropMap = std::map<std::string, std::string>;
CsPropMap sourceFileTags;
this->GetCSharpSourceProperties(&sf, sourceFileTags);
@@ -2886,7 +2899,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
if (ttype >= cmStateEnums::UTILITY) {
e1.WritePlatformConfigTag(
- "IntDir", cond, "$(Platform)\\$(Configuration)\\$(ProjectName)\\");
+ "IntDir", cond, R"($(Platform)\$(Configuration)\$(ProjectName)\)");
} else {
std::string intermediateDir = cmStrCat(
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), '/',
@@ -3053,12 +3066,9 @@ std::vector<std::string> cmVisualStudio10TargetGenerator::GetIncludes(
bool cmVisualStudio10TargetGenerator::ComputeClOptions()
{
- for (std::string const& c : this->Configurations) {
- if (!this->ComputeClOptions(c)) {
- return false;
- }
- }
- return true;
+ return std::all_of(
+ this->Configurations.begin(), this->Configurations.end(),
+ [this](std::string const& c) { return this->ComputeClOptions(c); });
}
bool cmVisualStudio10TargetGenerator::ComputeClOptions(
@@ -3274,6 +3284,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
this->GeneratorTarget->GetLanguages(languages, configName);
if (languages.count("C")) {
std::string flagsC;
+ this->LocalGenerator->AddLanguageFlags(
+ flagsC, this->GeneratorTarget, cmBuildStep::Compile, "C", configName);
this->LocalGenerator->AddCompileOptions(flagsC, this->GeneratorTarget,
"C", configName);
Options optC(this->LocalGenerator, Options::Compiler,
@@ -3316,9 +3328,12 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
}
}
- if (this->ProjectType != VsProjectType::csproj && clOptions.IsManaged()) {
+ if (this->ProjectType != VsProjectType::csproj &&
+ (clOptions.IsManaged() || clOptions.HasFlag("CLRSupport"))) {
this->Managed = true;
- std::string managedType = clOptions.GetFlag("CompileAsManaged");
+ std::string managedType = clOptions.HasFlag("CompileAsManaged")
+ ? clOptions.GetFlag("CompileAsManaged")
+ : "Mixed";
if (managedType == "Safe" || managedType == "Pure") {
// force empty calling convention if safe clr is used
clOptions.AddFlag("CallingConvention", "");
@@ -3411,7 +3426,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
// add AdditionalUsingDirectories
if (this->AdditionalUsingDirectories.count(configName) > 0) {
std::string dirs;
- for (auto u : this->AdditionalUsingDirectories[configName]) {
+ for (auto const& u : this->AdditionalUsingDirectories[configName]) {
if (!dirs.empty()) {
dirs.append(";");
}
@@ -3424,12 +3439,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
{
- for (std::string const& c : this->Configurations) {
- if (!this->ComputeRcOptions(c)) {
- return false;
- }
- }
- return true;
+ return std::all_of(
+ this->Configurations.begin(), this->Configurations.end(),
+ [this](std::string const& c) { return this->ComputeRcOptions(c); });
}
bool cmVisualStudio10TargetGenerator::ComputeRcOptions(
@@ -3478,13 +3490,12 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions()
if (!this->GlobalGenerator->IsCudaEnabled()) {
return true;
}
- for (std::string const& c : this->Configurations) {
- if (this->GeneratorTarget->IsLanguageUsed("CUDA", c) &&
- !this->ComputeCudaOptions(c)) {
- return false;
- }
- }
- return true;
+ return std::all_of(this->Configurations.begin(), this->Configurations.end(),
+ [this](std::string const& c) {
+ return !this->GeneratorTarget->IsLanguageUsed("CUDA",
+ c) ||
+ this->ComputeCudaOptions(c);
+ });
}
bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
@@ -3570,7 +3581,7 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
// limitation by creating the directory and passing the flag ourselves.
pdb = this->ConvertPath(pdb, true);
ConvertToWindowsSlash(pdb);
- std::string const clFd = "-Xcompiler=\"-Fd\\\"" + pdb + "\\\"\"";
+ std::string const clFd = R"(-Xcompiler="-Fd\")" + pdb + R"(\"")";
cudaOptions.AppendFlagString("AdditionalOptions", clFd);
}
}
@@ -3654,12 +3665,9 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions()
if (!this->GlobalGenerator->IsCudaEnabled()) {
return true;
}
- for (std::string const& c : this->Configurations) {
- if (!this->ComputeCudaLinkOptions(c)) {
- return false;
- }
- }
- return true;
+ return std::all_of(
+ this->Configurations.begin(), this->Configurations.end(),
+ [this](std::string const& c) { return this->ComputeCudaLinkOptions(c); });
}
bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions(
@@ -3748,17 +3756,64 @@ void cmVisualStudio10TargetGenerator::WriteCudaLinkOptions(
cudaLinkOptions.OutputFlagMap();
}
+bool cmVisualStudio10TargetGenerator::ComputeMarmasmOptions()
+{
+ if (!this->GlobalGenerator->IsMarmasmEnabled()) {
+ return true;
+ }
+ return std::all_of(
+ this->Configurations.begin(), this->Configurations.end(),
+ [this](std::string const& c) { return this->ComputeMarmasmOptions(c); });
+}
+
+bool cmVisualStudio10TargetGenerator::ComputeMarmasmOptions(
+ std::string const& configName)
+{
+ cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
+ auto pOptions = cm::make_unique<Options>(
+ this->LocalGenerator, Options::MarmasmCompiler, gg->GetMarmasmFlagTable());
+ Options& marmasmOptions = *pOptions;
+
+ std::string flags;
+ this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget,
+ cmBuildStep::Compile, "ASM_MARMASM",
+ configName);
+
+ marmasmOptions.Parse(flags);
+
+ // Get includes for this target
+ marmasmOptions.AddIncludes(this->GetIncludes(configName, "ASM_MARMASM"));
+
+ this->MarmasmOptions[configName] = std::move(pOptions);
+ return true;
+}
+
+void cmVisualStudio10TargetGenerator::WriteMarmasmOptions(
+ Elem& e1, std::string const& configName)
+{
+ if (!this->MSTools || !this->GlobalGenerator->IsMarmasmEnabled()) {
+ return;
+ }
+ Elem e2(e1, "MARMASM");
+
+ // Preprocessor definitions and includes are shared with clOptions.
+ OptionsHelper clOptions(*(this->ClOptions[configName]), e2);
+ clOptions.OutputPreprocessorDefinitions("ASM_MARMASM");
+
+ OptionsHelper marmasmOptions(*(this->MarmasmOptions[configName]), e2);
+ marmasmOptions.OutputAdditionalIncludeDirectories("ASM_MARMASM");
+ marmasmOptions.PrependInheritedString("AdditionalOptions");
+ marmasmOptions.OutputFlagMap();
+}
+
bool cmVisualStudio10TargetGenerator::ComputeMasmOptions()
{
if (!this->GlobalGenerator->IsMasmEnabled()) {
return true;
}
- for (std::string const& c : this->Configurations) {
- if (!this->ComputeMasmOptions(c)) {
- return false;
- }
- }
- return true;
+ return std::all_of(
+ this->Configurations.begin(), this->Configurations.end(),
+ [this](std::string const& c) { return this->ComputeMasmOptions(c); });
}
bool cmVisualStudio10TargetGenerator::ComputeMasmOptions(
@@ -3806,12 +3861,9 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions()
if (!this->GlobalGenerator->IsNasmEnabled()) {
return true;
}
- for (std::string const& c : this->Configurations) {
- if (!this->ComputeNasmOptions(c)) {
- return false;
- }
- }
- return true;
+ return std::all_of(
+ this->Configurations.begin(), this->Configurations.end(),
+ [this](std::string const& c) { return this->ComputeNasmOptions(c); });
}
bool cmVisualStudio10TargetGenerator::ComputeNasmOptions(
@@ -4448,6 +4500,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups(Elem& e0)
// output rc compile flags <ResourceCompile></ResourceCompile>
this->WriteRCOptions(e1, c);
this->WriteCudaOptions(e1, c);
+ this->WriteMarmasmOptions(e1, c);
this->WriteMasmOptions(e1, c);
this->WriteNasmOptions(e1, c);
}