summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2018-06-26 14:21:05 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2018-06-27 16:38:36 (GMT)
commitcc9f88af53b6dd95d3fc1786166dd05599e2ba91 (patch)
tree8d5bb84ed7ec6b6757a87f792c81e6ba7a017f99 /Source
parentb142b721419f5653b7eeea65c5c899970be58812 (diff)
downloadCMake-cc9f88af53b6dd95d3fc1786166dd05599e2ba91.zip
CMake-cc9f88af53b6dd95d3fc1786166dd05599e2ba91.tar.gz
CMake-cc9f88af53b6dd95d3fc1786166dd05599e2ba91.tar.bz2
LINK_DEPENDS: add support for property INTERFACE_LINK_DEPENDS
Fixes: #17997
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExportBuildFileGenerator.cxx3
-rw-r--r--Source/cmExportFileGenerator.cxx31
-rw-r--r--Source/cmExportFileGenerator.h4
-rw-r--r--Source/cmExportInstallFileGenerator.cxx2
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.h3
-rw-r--r--Source/cmGeneratorTarget.cxx36
-rw-r--r--Source/cmGeneratorTarget.h4
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx22
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx22
-rw-r--r--Source/cmMakefileTargetGenerator.cxx8
-rw-r--r--Source/cmMakefileTargetGenerator.h3
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx4
-rw-r--r--Source/cmNinjaTargetGenerator.cxx15
-rw-r--r--Source/cmNinjaTargetGenerator.h2
14 files changed, 119 insertions, 40 deletions
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 9f2e01d..7f42035 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -98,6 +98,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
this->PopulateInterfaceProperty("INTERFACE_LINK_OPTIONS", gte,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_LINK_DEPENDS", gte,
+ cmGeneratorExpression::BuildInterface,
+ properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", gte,
properties);
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 5f61571..ec68fce 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -420,6 +420,37 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
}
}
+void cmExportFileGenerator::PopulateLinkDependsInterface(
+ cmTargetExport* tei, cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
+{
+ cmGeneratorTarget* gt = tei->Target;
+ assert(preprocessRule == cmGeneratorExpression::InstallInterface);
+
+ const char* propName = "INTERFACE_LINK_DEPENDS";
+ const char* input = gt->GetProperty(propName);
+
+ if (!input) {
+ return;
+ }
+
+ if (!*input) {
+ properties[propName].clear();
+ return;
+ }
+
+ std::string prepro =
+ cmGeneratorExpression::Preprocess(input, preprocessRule, true);
+ if (!prepro.empty()) {
+ this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets);
+
+ if (!checkInterfaceDirs(prepro, gt, propName)) {
+ return;
+ }
+ properties[propName] = prepro;
+ }
+}
+
void cmExportFileGenerator::PopulateInterfaceProperty(
const std::string& propName, cmGeneratorTarget* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 954e6c5..6ca2e07 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -147,6 +147,10 @@ protected:
cmTargetExport* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
+ void PopulateLinkDependsInterface(
+ cmTargetExport* target,
+ cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
void SetImportLinkInterface(
const std::string& config, std::string const& suffix,
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 1db76ac..3595708 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -106,6 +106,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
this->PopulateInterfaceProperty("INTERFACE_LINK_OPTIONS", gt,
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
+ this->PopulateLinkDependsInterface(
+ te, cmGeneratorExpression::InstallInterface, properties, missingTargets);
std::string errorMessage;
if (!this->PopulateExportProperties(gt, properties, errorMessage)) {
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index cfe31f1..cd23904 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -26,7 +26,8 @@ struct cmGeneratorExpressionContext;
SELECT(F, EvaluatingAutoUicOptions, AUTOUIC_OPTIONS) \
SELECT(F, EvaluatingSources, SOURCES) \
SELECT(F, EvaluatingCompileFeatures, COMPILE_FEATURES) \
- SELECT(F, EvaluatingLinkOptions, LINK_OPTIONS)
+ SELECT(F, EvaluatingLinkOptions, LINK_OPTIONS) \
+ SELECT(F, EvaluatingLinkDepends, LINK_DEPENDS)
#define CM_FOR_EACH_TRANSITIVE_PROPERTY(F) \
CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_BOTH)
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 41e55a5..d4686c2 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -3008,6 +3008,42 @@ void cmGeneratorTarget::GetLinkOptions(std::vector<std::string>& result,
}
}
+namespace {
+void processLinkDepends(
+ cmGeneratorTarget const* tgt,
+ const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
+ std::vector<std::string>& options,
+ std::unordered_set<std::string>& uniqueOptions,
+ cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
+ std::string const& language)
+{
+ processOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker,
+ config, false, "link depends", language,
+ OptionsParse::None);
+}
+}
+
+void cmGeneratorTarget::GetLinkDepends(std::vector<std::string>& result,
+ const std::string& config,
+ const std::string& language) const
+{
+ if (const char* linkDepends = this->GetProperty("LINK_DEPENDS")) {
+ cmSystemTools::ExpandListArgument(linkDepends, result);
+ }
+
+ std::unordered_set<std::string> uniqueOptions;
+ std::vector<cmGeneratorTarget::TargetPropertyEntry*> linkDependsEntries;
+ cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), "LINK_DEPENDS",
+ nullptr, nullptr);
+
+ AddInterfaceEntries(this, config, "INTERFACE_LINK_DEPENDS",
+ linkDependsEntries);
+ processLinkDepends(this, linkDependsEntries, result, uniqueOptions,
+ &dagChecker, config, language);
+
+ cmDeleteAll(linkDependsEntries);
+}
+
void cmGeneratorTarget::ComputeTargetManifest(const std::string& config) const
{
if (this->IsImported()) {
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index aa36823..4cc0aac 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -422,6 +422,10 @@ public:
const std::string& config,
const std::string& language) const;
+ void GetLinkDepends(std::vector<std::string>& result,
+ const std::string& config,
+ const std::string& language) const;
+
bool IsSystemIncludeDirectory(const std::string& dir,
const std::string& config,
const std::string& language) const;
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 82f4683..b9845ba 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -97,15 +97,15 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule(
std::vector<std::string> commands;
- // Build list of dependencies.
- std::vector<std::string> depends;
- this->AppendLinkDepends(depends);
-
// Get the language to use for linking this library.
std::string linkLanguage = "CUDA";
std::string const objExt =
this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
+ // Build list of dependencies.
+ std::vector<std::string> depends;
+ this->AppendLinkDepends(depends, linkLanguage);
+
// Get the name of the device object to generate.
std::string const targetOutputReal =
this->GeneratorTarget->ObjectDirectory + "cmake_device_link" + objExt;
@@ -294,13 +294,6 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
{
std::vector<std::string> commands;
- // Build list of dependencies.
- std::vector<std::string> depends;
- this->AppendLinkDepends(depends);
- if (!this->DeviceLinkObject.empty()) {
- depends.push_back(this->DeviceLinkObject);
- }
-
// Get the name of the executable to generate.
std::string targetName;
std::string targetNameReal;
@@ -378,6 +371,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
return;
}
+ // Build list of dependencies.
+ std::vector<std::string> depends;
+ this->AppendLinkDepends(depends, linkLanguage);
+ if (!this->DeviceLinkObject.empty()) {
+ depends.push_back(this->DeviceLinkObject);
+ }
+
this->NumberOfProgressActions++;
if (!this->NoRuleMessages) {
cmLocalUnixMakefileGenerator3::EchoProgress progress;
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 036acc7..571e74b 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -260,15 +260,15 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules(
// code duplication.
std::vector<std::string> commands;
- // Build list of dependencies.
- std::vector<std::string> depends;
- this->AppendLinkDepends(depends);
-
// Get the language to use for linking this library.
std::string linkLanguage = "CUDA";
std::string const objExt =
this->Makefile->GetSafeDefinition("CMAKE_CUDA_OUTPUT_EXTENSION");
+ // Build list of dependencies.
+ std::vector<std::string> depends;
+ this->AppendLinkDepends(depends, linkLanguage);
+
// Create set of linking flags.
std::string linkFlags;
this->GetTargetLinkFlags(linkFlags, linkLanguage);
@@ -444,13 +444,6 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
// code duplication.
std::vector<std::string> commands;
- // Build list of dependencies.
- std::vector<std::string> depends;
- this->AppendLinkDepends(depends);
- if (!this->DeviceLinkObject.empty()) {
- depends.push_back(this->DeviceLinkObject);
- }
-
// Get the language to use for linking this library.
std::string linkLanguage =
this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
@@ -462,6 +455,13 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
return;
}
+ // Build list of dependencies.
+ std::vector<std::string> depends;
+ this->AppendLinkDepends(depends, linkLanguage);
+ if (!this->DeviceLinkObject.empty()) {
+ depends.push_back(this->DeviceLinkObject);
+ }
+
// Create set of linking flags.
std::string linkFlags;
this->LocalGenerator->AppendFlags(linkFlags, extraFlags);
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 08fcd8f..7cae305 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -1387,7 +1387,7 @@ void cmMakefileTargetGenerator::AppendObjectDepends(
}
void cmMakefileTargetGenerator::AppendLinkDepends(
- std::vector<std::string>& depends)
+ std::vector<std::string>& depends, const std::string& linkLanguage)
{
this->AppendObjectDepends(depends);
@@ -1411,10 +1411,8 @@ void cmMakefileTargetGenerator::AppendLinkDepends(
}
// Add user-specified dependencies.
- if (const char* linkDepends =
- this->GeneratorTarget->GetProperty("LINK_DEPENDS")) {
- cmSystemTools::ExpandListArgument(linkDepends, depends);
- }
+ this->GeneratorTarget->GetLinkDepends(depends, this->ConfigName,
+ linkLanguage);
}
std::string cmMakefileTargetGenerator::GetLinkRule(
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 4d1c9ec..f21362a 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -128,7 +128,8 @@ protected:
void AppendObjectDepends(std::vector<std::string>& depends);
// Append link rule dependencies (objects, etc.).
- void AppendLinkDepends(std::vector<std::string>& depends);
+ void AppendLinkDepends(std::vector<std::string>& depends,
+ const std::string& linkLanguage);
// Lookup the link rule for this target.
std::string GetLinkRule(const std::string& linkRuleVar);
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 7394188..f94e5bc 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -625,7 +625,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkStatement()
outputs.push_back(targetOutputReal);
// Compute specific libraries to link with.
cmNinjaDeps explicitDeps = this->GetObjects();
- cmNinjaDeps implicitDeps = this->ComputeLinkDeps();
+ cmNinjaDeps implicitDeps = this->ComputeLinkDeps(this->TargetLinkLanguage);
std::string frameworkPath;
std::string linkPath;
@@ -794,7 +794,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// Compute specific libraries to link with.
cmNinjaDeps explicitDeps = this->GetObjects();
- cmNinjaDeps implicitDeps = this->ComputeLinkDeps();
+ cmNinjaDeps implicitDeps = this->ComputeLinkDeps(this->TargetLinkLanguage);
if (!this->DeviceLinkObject.empty()) {
explicitDeps.push_back(this->DeviceLinkObject);
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 9d41948..df32f40 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -235,7 +235,8 @@ std::string cmNinjaTargetGenerator::ComputeIncludes(
return includesString;
}
-cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
+cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps(
+ const std::string& linkLanguage) const
{
// Static libraries never depend on other targets for linking.
if (this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY ||
@@ -270,13 +271,11 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
}
// Add user-specified dependencies.
- if (const char* linkDepends =
- this->GeneratorTarget->GetProperty("LINK_DEPENDS")) {
- std::vector<std::string> linkDeps;
- cmSystemTools::ExpandListArgument(linkDepends, linkDeps);
- std::transform(linkDeps.begin(), linkDeps.end(),
- std::back_inserter(result), MapToNinjaPath());
- }
+ std::vector<std::string> linkDeps;
+ this->GeneratorTarget->GetLinkDepends(linkDeps, this->ConfigName,
+ linkLanguage);
+ std::transform(linkDeps.begin(), linkDeps.end(), std::back_inserter(result),
+ MapToNinjaPath());
return result;
}
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 4660a3a..e58a8a0 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -95,7 +95,7 @@ protected:
}
/// @return the list of link dependency for the given target @a target.
- cmNinjaDeps ComputeLinkDeps() const;
+ cmNinjaDeps ComputeLinkDeps(const std::string& linkLanguage) const;
/// @return the source file path for the given @a source.
std::string GetSourceFilePath(cmSourceFile const* source) const;