summaryrefslogtreecommitdiffstats
path: root/Source
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
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')
-rw-r--r--Source/cmAddDependenciesCommand.cxx2
-rw-r--r--Source/cmComputeTargetDepends.cxx39
-rw-r--r--Source/cmPolicies.cxx5
-rw-r--r--Source/cmPolicies.h1
-rw-r--r--Source/cmTarget.cxx20
-rw-r--r--Source/cmTarget.h4
6 files changed, 69 insertions, 2 deletions
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index 87bfb3c..a7ffded 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -46,7 +46,7 @@ bool cmAddDependenciesCommand
++s; // skip over target_name
for (; s != args.end(); ++s)
{
- target->AddUtility(s->c_str());
+ target->AddUtility(s->c_str(), this->Makefile);
}
}
else
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.
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 5a189f8..020a782 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -331,6 +331,11 @@ cmPolicies::cmPolicies()
CMP0045, "CMP0045",
"Error on non-existent target in get_target_property.",
3,0,0,0, cmPolicies::WARN);
+
+ this->DefinePolicy(
+ CMP0046, "CMP0046",
+ "Error on non-existent dependency in add_dependencies.",
+ 3,0,0,0, cmPolicies::WARN);
}
cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index b1342bf..38f47f1 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -99,6 +99,7 @@ public:
CMP0043, ///< Ignore COMPILE_DEFINITIONS_<Config> properties
CMP0044, ///< Case sensitive <LANG>_COMPILER_ID generator expressions
CMP0045, ///< Error on non-existent target in get_target_property
+ CMP0046, ///< Error on non-existent dependency in add_dependencies
/** \brief Always the last entry.
*
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 4828d20..24fa0c5 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -402,6 +402,26 @@ void cmTarget::SetMakefile(cmMakefile* mf)
}
//----------------------------------------------------------------------------
+void cmTarget::AddUtility(const char *u, cmMakefile *makefile)
+{
+ this->Utilities.insert(u);
+ if(makefile)
+ {
+ makefile->GetBacktrace(UtilityBacktraces[u]);
+ }
+}
+
+//----------------------------------------------------------------------------
+cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(const char *u) const
+{
+ std::map<cmStdString, cmListFileBacktrace>::const_iterator i =
+ this->UtilityBacktraces.find(u);
+ if(i == this->UtilityBacktraces.end()) return 0;
+
+ return &i->second;
+}
+
+//----------------------------------------------------------------------------
void cmTarget::FinishConfigure()
{
// Erase any cached link information that might have been comptued
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 26d391f..ce0d812 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -242,9 +242,10 @@ public:
* name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE
* commands. It is not a full path nor does it have an extension.
*/
- void AddUtility(const char* u) { this->Utilities.insert(u);}
+ void AddUtility(const char* u, cmMakefile *makefile = 0);
///! Get the utilities used by this target
std::set<cmStdString>const& GetUtilities() const { return this->Utilities; }
+ cmListFileBacktrace const* GetUtilityBacktrace(const char* u) const;
/** Finalize the target at the end of the Configure step. */
void FinishConfigure();
@@ -691,6 +692,7 @@ private:
std::string RuntimeInstallPath;
mutable std::string ExportMacro;
std::set<cmStdString> Utilities;
+ std::map<cmStdString, cmListFileBacktrace> UtilityBacktraces;
bool RecordDependencies;
mutable cmPropertyMap Properties;
LinkLibraryVectorType OriginalLinkLibraries;