summaryrefslogtreecommitdiffstats
path: root/Source/cmExportFileGenerator.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-11-26 10:24:47 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-11-26 12:01:55 (GMT)
commit5838aba1aae5c341941c0779cd947ed0172e3a61 (patch)
tree3af0ca6398b63a642beecfc2fa7a05680f9d1477 /Source/cmExportFileGenerator.cxx
parent7a3e45b9d469e468e4db867d51e92ceeed132b79 (diff)
downloadCMake-5838aba1aae5c341941c0779cd947ed0172e3a61.zip
CMake-5838aba1aae5c341941c0779cd947ed0172e3a61.tar.gz
CMake-5838aba1aae5c341941c0779cd947ed0172e3a61.tar.bz2
Export: Report error on relative include with genex.
Diagnostics which check the sanity of exported include paths previously skipped over any path containing a generator expression. Introduce a policy to issue an error message in such cases. The export files created in the OLD behavior are not usable, because they contain relative paths or paths to the source or build location which are not suitable for use on installation. CMake will report an error on import.
Diffstat (limited to 'Source/cmExportFileGenerator.cxx')
-rw-r--r--Source/cmExportFileGenerator.cxx42
1 files changed, 28 insertions, 14 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 9186ab6..2d963fe 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -233,26 +233,46 @@ static bool checkInterfaceDirs(const std::string &prepro,
const bool inSourceBuild = strcmp(topSourceDir, topBinaryDir) == 0;
+ bool hadFatalError = false;
+
for(std::vector<std::string>::iterator li = parts.begin();
li != parts.end(); ++li)
{
- if (cmGeneratorExpression::Find(*li) != std::string::npos)
+ size_t genexPos = cmGeneratorExpression::Find(*li);
+ if (genexPos == 0)
{
continue;
}
+ cmake::MessageType messageType = cmake::FATAL_ERROR;
+ cmOStringStream e;
+ if (genexPos != std::string::npos)
+ {
+ switch (target->GetPolicyStatusCMP0041())
+ {
+ case cmPolicies::WARN:
+ messageType = cmake::WARNING;
+ e << target->GetMakefile()->GetPolicies()
+ ->GetPolicyWarning(cmPolicies::CMP0041) << "\n";
+ break;
+ case cmPolicies::OLD:
+ continue;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ hadFatalError = true;
+ break; // Issue fatal message.
+ }
+ }
if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}"))
{
continue;
}
if (!cmSystemTools::FileIsFullPath(li->c_str()))
{
- cmOStringStream e;
e << "Target \"" << target->GetName() << "\" "
"INTERFACE_INCLUDE_DIRECTORIES property contains relative path:\n"
" \"" << *li << "\"";
- target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR,
- e.str().c_str());
- return false;
+ target->GetMakefile()->IssueMessage(messageType, e.str().c_str());
}
if (isSubDirectory(li->c_str(), installDir))
{
@@ -260,29 +280,23 @@ static bool checkInterfaceDirs(const std::string &prepro,
}
if (isSubDirectory(li->c_str(), topBinaryDir))
{
- cmOStringStream e;
e << "Target \"" << target->GetName() << "\" "
"INTERFACE_INCLUDE_DIRECTORIES property contains path:\n"
" \"" << *li << "\"\nwhich is prefixed in the build directory.";
- target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR,
- e.str().c_str());
- return false;
+ target->GetMakefile()->IssueMessage(messageType, e.str().c_str());
}
if (!inSourceBuild)
{
if (isSubDirectory(li->c_str(), topSourceDir))
{
- cmOStringStream e;
e << "Target \"" << target->GetName() << "\" "
"INTERFACE_INCLUDE_DIRECTORIES property contains path:\n"
" \"" << *li << "\"\nwhich is prefixed in the source directory.";
- target->GetMakefile()->IssueMessage(cmake::FATAL_ERROR,
- e.str().c_str());
- return false;
+ target->GetMakefile()->IssueMessage(messageType, e.str().c_str());
}
}
}
- return true;
+ return !hadFatalError;
}
//----------------------------------------------------------------------------