summaryrefslogtreecommitdiffstats
path: root/Source/cmIncludeCommand.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-06-18 14:33:33 (GMT)
committerBrad King <brad.king@kitware.com>2013-10-07 23:57:06 (GMT)
commit904ff9fe592882db5dae88e526db2b380d92f87d (patch)
tree2b03c49057bcfb72c69df6148f3028c48a308e30 /Source/cmIncludeCommand.cxx
parentd4134352abf69374fdad24d53d67734a135daaa5 (diff)
downloadCMake-904ff9fe592882db5dae88e526db2b380d92f87d.zip
CMake-904ff9fe592882db5dae88e526db2b380d92f87d.tar.gz
CMake-904ff9fe592882db5dae88e526db2b380d92f87d.tar.bz2
export: Add policy CMP0024 to disallow include() of export files
Currently, export() is executed at configure-time. One problem with this is that certain exported properties like the link interface may not be complete at the point the export() is encountered leading to an incorrect or incomplete exported representation. Additionally, the generated IMPORTED_LOCATION property may even be incorrect if commands following the export() have an effect on it. Another problem is that it requires the C++ implementation of cmake to be capable of computing the exported information at configure time. This is a limitation on the cleanup and maintenance of the code. At some point in the future, this limitation will be dropped and more implementation will be moved from cmTarget to cmGeneratorTarget.
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(),