summaryrefslogtreecommitdiffstats
path: root/Source/cmComputeTargetDepends.cxx
diff options
context:
space:
mode:
authorNils Gladitz <nilsgladitz@gmail.com>2014-01-12 11:58:04 (GMT)
committerNils Gladitz <nilsgladitz@gmail.com>2014-01-12 11:58:04 (GMT)
commit0bf6f13b1dc278b68c1ddf94d838014852ada679 (patch)
tree3464265a00fc0ad27c36d5b3bf0c9c81ff8f49c5 /Source/cmComputeTargetDepends.cxx
parentcb7af7af44bd9ce5ac11e345b1756ea0770bbc83 (diff)
downloadCMake-0bf6f13b1dc278b68c1ddf94d838014852ada679.zip
CMake-0bf6f13b1dc278b68c1ddf94d838014852ada679.tar.gz
CMake-0bf6f13b1dc278b68c1ddf94d838014852ada679.tar.bz2
AddDependencies: new policy requires dependencies to exist
Added new policy CMP0046 which requires dependencies added by add_dependencies() to actually exist.
Diffstat (limited to 'Source/cmComputeTargetDepends.cxx')
-rw-r--r--Source/cmComputeTargetDepends.cxx39
1 files changed, 39 insertions, 0 deletions
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 73a8e27..a848e4f 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -343,6 +343,45 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
cmTarget const* dependee =
depender->GetMakefile()->FindTargetToUse(dependee_name);
+ if(!dependee && !linking &&
+ (depender->GetType() != cmTarget::GLOBAL_TARGET))
+ {
+ cmMakefile *makefile = depender->GetMakefile();
+ cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ bool issueMessage = false;
+ switch(makefile->GetPolicyStatus(cmPolicies::CMP0046))
+ {
+ case cmPolicies::WARN:
+ issueMessage = true;
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::NEW:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ issueMessage = true;
+ messageType = cmake::FATAL_ERROR;
+ }
+ if(issueMessage)
+ {
+ cmake* cm = this->GlobalGenerator->GetCMakeInstance();
+ cmOStringStream e;
+ e << (makefile->GetPolicies()
+ ->GetPolicyWarning(cmPolicies::CMP0046)) << "\n";
+ e << "The dependency target \"" << dependee_name
+ << "\" of target \"" << depender->GetName() << "\" does not exist.";
+
+ cmListFileBacktrace nullBacktrace;
+ cmListFileBacktrace const* backtrace =
+ depender->GetUtilityBacktrace(dependee_name);
+ if(!backtrace)
+ {
+ backtrace = &nullBacktrace;
+ }
+
+ cm->IssueMessage(messageType, e.str(), *backtrace);
+ }
+ }
+
// Skip targets that will not really be linked. This is probably a
// name conflict between an external library and an executable
// within the project.