summaryrefslogtreecommitdiffstats
path: root/Source/cmVisualStudio10TargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmVisualStudio10TargetGenerator.cxx')
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx107
1 files changed, 71 insertions, 36 deletions
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 965ac3e..82880a9 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -498,7 +498,7 @@ void cmVisualStudio10TargetGenerator::Generate()
cmProp targetFramework =
this->GeneratorTarget->GetProperty("DOTNET_TARGET_FRAMEWORK");
if (targetFramework) {
- if (std::strchr(targetFramework->c_str(), ';') != nullptr) {
+ if (targetFramework->find(';') != std::string::npos) {
e1.Element("TargetFrameworks", *targetFramework);
} else {
e1.Element("TargetFramework", *targetFramework);
@@ -545,7 +545,7 @@ void cmVisualStudio10TargetGenerator::Generate()
e1.Element(
"CudaToolkitCustomDir",
this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString() +
- "nvcc");
+ this->GlobalGenerator->GetPlatformToolsetCudaNvccSubdirString());
}
}
@@ -654,8 +654,9 @@ void cmVisualStudio10TargetGenerator::Generate()
std::string cudaPath = customDir.empty()
? "$(VCTargetsPath)\\BuildCustomizations\\"
: customDir +
- "CUDAVisualStudioIntegration\\extras\\"
- "visual_studio_integration\\MSBuildExtensions\\";
+ this->GlobalGenerator
+ ->GetPlatformToolsetCudaVSIntegrationSubdirString() +
+ "extras\\visual_studio_integration\\MSBuildExtensions\\";
Elem(e1, "Import")
.Attribute("Project",
std::move(cudaPath) + "CUDA " +
@@ -747,8 +748,9 @@ void cmVisualStudio10TargetGenerator::Generate()
std::string cudaPath = customDir.empty()
? "$(VCTargetsPath)\\BuildCustomizations\\"
: customDir +
- "CUDAVisualStudioIntegration\\extras\\"
- "visual_studio_integration\\MSBuildExtensions\\";
+ this->GlobalGenerator
+ ->GetPlatformToolsetCudaVSIntegrationSubdirString() +
+ "extras\\visual_studio_integration\\MSBuildExtensions\\";
Elem(e1, "Import")
.Attribute("Project",
std::move(cudaPath) + "CUDA " +
@@ -766,6 +768,11 @@ void cmVisualStudio10TargetGenerator::Generate()
Elem(e1, "Import").Attribute("Project", nasmTargets);
}
}
+ if (this->ProjectType == vcxproj && this->HaveCustomCommandDepfile) {
+ std::string depfileTargets =
+ GetCMakeFilePath("Templates/MSBuild/CustomBuildDepFile.targets");
+ Elem(e0, "Import").Attribute("Project", depfileTargets);
+ }
if (this->ProjectType == csproj) {
for (std::string const& c : this->Configurations) {
Elem e1(e0, "PropertyGroup");
@@ -1458,7 +1465,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
e2.SetHasElements();
}
for (std::string const& c : this->Configurations) {
- cmCustomCommandGenerator ccg(command, c, lg);
+ cmCustomCommandGenerator ccg(command, c, lg, true);
std::string comment = lg->ConstructComment(ccg);
comment = cmVS10EscapeComment(comment);
std::string script = lg->ConstructScript(ccg);
@@ -1522,10 +1529,10 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
std::string name = "CustomCommand_" + c + "_" +
cmSystemTools::ComputeStringMD5(sourcePath);
this->WriteCustomRuleCSharp(e0, c, name, script, additional_inputs.str(),
- outputs.str(), comment);
+ outputs.str(), comment, ccg);
} else {
this->WriteCustomRuleCpp(*spe2, c, script, additional_inputs.str(),
- outputs.str(), comment, symbolic);
+ outputs.str(), comment, ccg, symbolic);
}
}
}
@@ -1533,7 +1540,8 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp(
Elem& e2, std::string const& config, std::string const& script,
std::string const& additional_inputs, std::string const& outputs,
- std::string const& comment, bool symbolic)
+ std::string const& comment, cmCustomCommandGenerator const& ccg,
+ bool symbolic)
{
const std::string cond = this->CalcCondition(config);
e2.WritePlatformConfigTag("Message", cond, comment);
@@ -1552,13 +1560,29 @@ void cmVisualStudio10TargetGenerator::WriteCustomRuleCpp(
// outputs is marked SYMBOLIC and not expected to be created.
e2.WritePlatformConfigTag("VerifyInputsAndOutputsExist", cond, "false");
}
+
+ std::string depfile = ccg.GetFullDepfile();
+ if (!depfile.empty()) {
+ this->HaveCustomCommandDepfile = true;
+ std::string internal_depfile = ccg.GetInternalDepfile();
+ ConvertToWindowsSlash(internal_depfile);
+ e2.WritePlatformConfigTag("DepFileAdditionalInputsFile", cond,
+ internal_depfile);
+ }
}
void cmVisualStudio10TargetGenerator::WriteCustomRuleCSharp(
Elem& e0, std::string const& config, std::string const& name,
std::string const& script, std::string const& inputs,
- std::string const& outputs, std::string const& comment)
+ std::string const& outputs, std::string const& comment,
+ cmCustomCommandGenerator const& ccg)
{
+ if (!ccg.GetFullDepfile().empty()) {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("CSharp target \"", this->GeneratorTarget->GetName(),
+ "\" does not support add_custom_command DEPFILE."));
+ }
this->CSharpCustomCommandNames.insert(name);
Elem e1(e0, "Target");
e1.Attribute("Condition", this->CalcCondition(config));
@@ -2275,6 +2299,20 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
std::back_inserter(exclude_configs));
Elem e2(e1, tool);
+ bool isCSharp = (si.Source->GetLanguage() == "CSharp");
+ if (isCSharp && exclude_configs.size() > 0) {
+ std::stringstream conditions;
+ bool firstConditionSet{ false };
+ for (const auto& ci : include_configs) {
+ if (firstConditionSet) {
+ conditions << " Or ";
+ }
+ conditions << "('$(Configuration)|$(Platform)'=='" +
+ this->Configurations[ci] + "|" + this->Platform + "')";
+ firstConditionSet = true;
+ }
+ e2.Attribute("Condition", conditions.str());
+ }
this->WriteSource(e2, si.Source);
bool useNativeUnityBuild = false;
@@ -2319,7 +2357,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
if (si.Source->GetPropertyAsBool("SKIP_PRECOMPILE_HEADERS")) {
e2.Element("PrecompiledHeader", "NotUsing");
}
- if (!exclude_configs.empty()) {
+ if (!isCSharp && !exclude_configs.empty()) {
this->WriteExcludeFromBuild(e2, exclude_configs);
}
}
@@ -3340,8 +3378,6 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions(
// cmLinkLineDeviceComputer
cmComputeLinkInformation& cli = *pcli;
std::vector<std::string> libVec;
- const std::string currentBinDir =
- this->LocalGenerator->GetCurrentBinaryDirectory();
const auto& libs = cli.GetItems();
for (cmComputeLinkInformation::Item const& l : libs) {
@@ -3377,9 +3413,9 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaLinkOptions(
}
}
- if (l.IsPath) {
- std::string path = this->LocalGenerator->MaybeConvertToRelativePath(
- currentBinDir, l.Value.Value);
+ if (l.IsPath == cmComputeLinkInformation::ItemIsPath::Yes) {
+ std::string path =
+ this->LocalGenerator->MaybeRelativeToCurBinDir(l.Value.Value);
ConvertToWindowsSlash(path);
if (!cmVS10IsTargetsFile(l.Value.Value)) {
libVec.push_back(path);
@@ -3507,8 +3543,6 @@ void cmVisualStudio10TargetGenerator::WriteNasmOptions(
}
Elem e2(e1, "NASM");
- std::vector<std::string> includes =
- this->GetIncludes(configName, "ASM_NASM");
OptionsHelper nasmOptions(*(this->NasmOptions[configName]), e2);
nasmOptions.OutputAdditionalIncludeDirectories("ASM_NASM");
nasmOptions.OutputFlagMap();
@@ -3930,12 +3964,11 @@ bool cmVisualStudio10TargetGenerator::ComputeLibOptions(
cmComputeLinkInformation& cli = *pcli;
using ItemVector = cmComputeLinkInformation::ItemVector;
const ItemVector& libs = cli.GetItems();
- std::string currentBinDir =
- this->LocalGenerator->GetCurrentBinaryDirectory();
for (cmComputeLinkInformation::Item const& l : libs) {
- if (l.IsPath && cmVS10IsTargetsFile(l.Value.Value)) {
- std::string path = this->LocalGenerator->MaybeConvertToRelativePath(
- currentBinDir, l.Value.Value);
+ if (l.IsPath == cmComputeLinkInformation::ItemIsPath::Yes &&
+ cmVS10IsTargetsFile(l.Value.Value)) {
+ std::string path =
+ this->LocalGenerator->MaybeRelativeToCurBinDir(l.Value.Value);
ConvertToWindowsSlash(path);
this->AddTargetsFileAndConfigPair(path, config);
}
@@ -3975,8 +4008,6 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
{
using ItemVector = cmComputeLinkInformation::ItemVector;
ItemVector const& libs = cli.GetItems();
- std::string currentBinDir =
- this->LocalGenerator->GetCurrentBinaryDirectory();
for (cmComputeLinkInformation::Item const& l : libs) {
if (l.Target) {
auto managedType = l.Target->GetManagedType(config);
@@ -4018,9 +4049,9 @@ void cmVisualStudio10TargetGenerator::AddLibraries(
}
}
- if (l.IsPath) {
- std::string path = this->LocalGenerator->MaybeConvertToRelativePath(
- currentBinDir, l.Value.Value);
+ if (l.IsPath == cmComputeLinkInformation::ItemIsPath::Yes) {
+ std::string path =
+ this->LocalGenerator->MaybeRelativeToCurBinDir(l.Value.Value);
ConvertToWindowsSlash(path);
if (cmVS10IsTargetsFile(l.Value.Value)) {
vsTargetVec.push_back(path);
@@ -4237,11 +4268,10 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
if (dt->IsCSharpOnly() || cmHasLiteralSuffix(path, "csproj")) {
e2.Element("SkipGetTargetFrameworkProperties", "true");
}
-
// Don't reference targets that don't produce any output.
- if (this->Configurations.empty() ||
- dt->GetManagedType(this->Configurations[0]) ==
- cmGeneratorTarget::ManagedType::Undefined) {
+ else if (this->Configurations.empty() ||
+ dt->GetManagedType(this->Configurations[0]) ==
+ cmGeneratorTarget::ManagedType::Undefined) {
e2.Element("ReferenceOutputAssembly", "false");
e2.Element("CopyToOutputDirectory", "Never");
}
@@ -5035,7 +5065,9 @@ std::string cmVisualStudio10TargetGenerator::GetCSharpSourceLink(
{
// For out of source files, we first check if a matching source group
// for this file exists, otherwise we check if the path relative to current
- // source- or binary-dir is used within the link and return that
+ // source- or binary-dir is used within the link and return that.
+ // In case of .cs files we can't do that automatically for files in the
+ // binary directory, because this leads to compilation errors.
std::string link;
std::string sourceGroupedFile;
std::string const& fullFileName = source->GetFullPath();
@@ -5057,7 +5089,8 @@ std::string cmVisualStudio10TargetGenerator::GetCSharpSourceLink(
link = sourceGroupedFile;
} else if (cmHasPrefix(fullFileName, srcDir)) {
link = fullFileName.substr(srcDir.length() + 1);
- } else if (cmHasPrefix(fullFileName, binDir)) {
+ } else if (!cmHasSuffix(fullFileName, ".cs") &&
+ cmHasPrefix(fullFileName, binDir)) {
link = fullFileName.substr(binDir.length() + 1);
} else if (cmProp l = source->GetProperty("VS_CSHARP_Link")) {
link = *l;
@@ -5080,7 +5113,9 @@ std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath(
void cmVisualStudio10TargetGenerator::WriteStdOutEncodingUtf8(Elem& e1)
{
- if (this->GlobalGenerator->IsStdOutEncodingSupported()) {
+ if (this->GlobalGenerator->IsUtf8EncodingSupported()) {
+ e1.Element("UseUtf8Encoding", "Always");
+ } else if (this->GlobalGenerator->IsStdOutEncodingSupported()) {
e1.Element("StdOutEncoding", "UTF-8");
}
}