summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmExportCommand.cxx2
-rw-r--r--Source/cmIncludeCommand.cxx39
-rw-r--r--Source/cmMakefile.h14
-rw-r--r--Source/cmPolicies.cxx19
-rw-r--r--Source/cmPolicies.h1
5 files changed, 74 insertions, 1 deletions
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index be2ee31..837bb39 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -171,6 +171,8 @@ bool cmExportCommand
ebfg.SetCommand(this);
ebfg.SetExportOld(this->ExportOld.IsEnabled());
+ this->Makefile->AddExportedTargetsFile(fname);
+
// Compute the set of configurations exported.
std::vector<std::string> configurationTypes;
this->Makefile->GetConfigurations(configurationTypes);
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(),
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 8bce9fd..362b066 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -489,6 +489,18 @@ public:
return this->cmCurrentListFile.c_str();
}
+ void AddExportedTargetsFile(const std::string &filename)
+ {
+ this->ExportedTargetsFiles.insert(filename);
+ }
+
+ bool IsExportedTargetsFile(const std::string &filename) const
+ {
+ const std::set<std::string>::const_iterator it
+ = this->ExportedTargetsFiles.find(filename);
+ return it != this->ExportedTargetsFiles.end();
+ }
+
//@}
/**
@@ -1041,7 +1053,7 @@ private:
void EnforceDirectoryLevelRules();
bool GeneratingBuildSystem;
-
+ std::set<std::string> ExportedTargetsFiles;
/**
* Old version of GetSourceFileWithOutput(const char*) kept for
* backward-compatibility. It implements a linear search and support
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index f9197e0..9e5e6e0 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -601,6 +601,25 @@ cmPolicies::cmPolicies()
"The NEW behavior for this policy is to not to allow mixing of the "
"keyword and plain signatures.",
2,8,12,0, cmPolicies::WARN);
+
+ this->DefinePolicy(
+ CMP0024, "CMP0024",
+ "Disallow include export result.",
+ "CMake 2.8.12 and lower allowed use of the include() command with the "
+ "result of the export() command. This relies on the assumption that "
+ "the export() command has an immediate effect at configure-time during a "
+ "cmake run. Certain properties of targets are not fully determined "
+ "until later at generate-time, such as the link language and complete "
+ "list of link libraries. Future refactoring will change the effect of "
+ "the export() command to be executed at generate-time. Use ALIAS "
+ "targets instead in cases where the goal is to refer to targets by "
+ "another name"
+ "\n"
+ "The OLD behavior for this policy is to allow including the result "
+ "of an export() command. "
+ "The NEW behavior for this policy is to not to allow including the "
+ "result of an export() command.",
+ 2,8,13,0, cmPolicies::WARN);
}
cmPolicies::~cmPolicies()
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 5b843a9..bafe5b2 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -74,6 +74,7 @@ public:
/// target property
CMP0022, ///< INTERFACE_LINK_LIBRARIES defines the link interface
CMP0023, ///< Disallow mixing keyword and plain tll signatures
+ CMP0024, ///< Disallow including export() result.
/** \brief Always the last entry.
*