summaryrefslogtreecommitdiffstats
path: root/Source/cmIncludeCommand.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmIncludeCommand.cxx')
-rw-r--r--Source/cmIncludeCommand.cxx39
1 files changed, 39 insertions, 0 deletions
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index bb891d6..a3d8b83 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -88,6 +88,45 @@ bool cmIncludeCommand
fname = mfile.c_str();
}
}
+
+ std::string fname_abs =
+ cmSystemTools::CollapseFullPath(fname.c_str(),
+ this->Makefile->GetStartDirectory());
+
+ if (this->Makefile->IsExportedTargetsFile(fname_abs))
+ {
+ const char *modal = 0;
+ cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+
+ switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0024))
+ {
+ case cmPolicies::WARN:
+ modal = "should";
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ modal = "may";
+ messageType = cmake::FATAL_ERROR;
+ }
+ if (modal)
+ {
+ cmOStringStream e;
+ e << (this->Makefile->GetPolicies()
+ ->GetPolicyWarning(cmPolicies::CMP0024)) << "\n";
+ e << "The file\n " << fname_abs << "\nwas generated by the export() "
+ "command. It " << modal << " not be used as the argument to the "
+ "include() command. Use ALIAS targets instead to refer to targets "
+ "by alternative names.\n";
+ this->Makefile->IssueMessage(messageType, e.str().c_str());
+ if (messageType == cmake::FATAL_ERROR)
+ {
+ return false;
+ }
+ }
+ }
+
std::string fullFilePath;
bool readit =
this->Makefile->ReadListFile( this->Makefile->GetCurrentListFile(),