summaryrefslogtreecommitdiffstats
path: root/Source/cmExportFileGenerator.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-11-28 17:58:38 (GMT)
committerStephen Kelly <steveire@gmail.com>2015-02-10 23:51:34 (GMT)
commit6da65b3907419df28484c570f24d0da3593a0e5a (patch)
treeae814193dd7306ad6aa369dca4d489f9f8f6eaf9 /Source/cmExportFileGenerator.cxx
parent736bcb9664b714b91e8a2a573451e0453716f4da (diff)
downloadCMake-6da65b3907419df28484c570f24d0da3593a0e5a.zip
CMake-6da65b3907419df28484c570f24d0da3593a0e5a.tar.gz
CMake-6da65b3907419df28484c570f24d0da3593a0e5a.tar.bz2
Allow export of targets with INTERFACE_SOURCES.
Use the same rules for paths in source and binary dirs in installed INTERFACE_SOURCES as are used for INTERFACE_INCLUDE_DIRECTORIES.
Diffstat (limited to 'Source/cmExportFileGenerator.cxx')
-rw-r--r--Source/cmExportFileGenerator.cxx136
1 files changed, 93 insertions, 43 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index af4ce8b..71728be 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -224,7 +224,7 @@ static bool isSubDirectory(const char* a, const char* b)
//----------------------------------------------------------------------------
static bool checkInterfaceDirs(const std::string &prepro,
- cmTarget *target)
+ cmTarget *target, const std::string& prop)
{
const char* installDir =
target->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
@@ -250,20 +250,27 @@ static bool checkInterfaceDirs(const std::string &prepro,
std::ostringstream e;
if (genexPos != std::string::npos)
{
- switch (target->GetPolicyStatusCMP0041())
+ if (prop == "INTERFACE_INCLUDE_DIRECTORIES")
{
- 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.
+ 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.
+ }
+ }
+ else
+ {
+ hadFatalError = true;
}
}
if (cmHasLiteralPrefix(li->c_str(), "${_IMPORT_PREFIX}"))
@@ -272,8 +279,8 @@ static bool checkInterfaceDirs(const std::string &prepro,
}
if (!cmSystemTools::FileIsFullPath(li->c_str()))
{
- e << "Target \"" << target->GetName() << "\" "
- "INTERFACE_INCLUDE_DIRECTORIES property contains relative path:\n"
+ e << "Target \"" << target->GetName() << "\" " << prop <<
+ " property contains relative path:\n"
" \"" << *li << "\"";
target->GetMakefile()->IssueMessage(messageType, e.str());
}
@@ -289,32 +296,35 @@ static bool checkInterfaceDirs(const std::string &prepro,
(!inBinary || isSubDirectory(installDir, topBinaryDir)) &&
(!inSource || isSubDirectory(installDir, topSourceDir));
- if (!shouldContinue)
+ if (prop == "INTERFACE_INCLUDE_DIRECTORIES")
{
- switch(target->GetPolicyStatusCMP0052())
+ if (!shouldContinue)
{
- case cmPolicies::WARN:
+ switch(target->GetPolicyStatusCMP0052())
{
- std::ostringstream s;
- s << target->GetMakefile()->GetPolicies()
- ->GetPolicyWarning(cmPolicies::CMP0052) << "\n";
- s << "Directory:\n \"" << *li << "\"\nin "
- "INTERFACE_INCLUDE_DIRECTORIES of target \""
- << target->GetName() << "\" is a subdirectory of the install "
- "directory:\n \"" << installDir << "\"\nhowever it is also "
- "a subdirectory of the " << (inBinary ? "build" : "source")
- << " tree:\n \"" << (inBinary ? topBinaryDir : topSourceDir)
- << "\"" << std::endl;
- target->GetMakefile()->IssueMessage(cmake::AUTHOR_WARNING,
- s.str());
+ case cmPolicies::WARN:
+ {
+ std::ostringstream s;
+ s << target->GetMakefile()->GetPolicies()
+ ->GetPolicyWarning(cmPolicies::CMP0052) << "\n";
+ s << "Directory:\n \"" << *li << "\"\nin "
+ "INTERFACE_INCLUDE_DIRECTORIES of target \""
+ << target->GetName() << "\" is a subdirectory of the install "
+ "directory:\n \"" << installDir << "\"\nhowever it is also "
+ "a subdirectory of the " << (inBinary ? "build" : "source")
+ << " tree:\n \"" << (inBinary ? topBinaryDir : topSourceDir)
+ << "\"" << std::endl;
+ target->GetMakefile()->IssueMessage(cmake::AUTHOR_WARNING,
+ s.str());
+ }
+ case cmPolicies::OLD:
+ shouldContinue = true;
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ break;
}
- case cmPolicies::OLD:
- shouldContinue = true;
- break;
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::NEW:
- break;
}
}
if (shouldContinue)
@@ -324,8 +334,8 @@ static bool checkInterfaceDirs(const std::string &prepro,
}
if (inBinary)
{
- e << "Target \"" << target->GetName() << "\" "
- "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n"
+ e << "Target \"" << target->GetName() << "\" " << prop <<
+ " property contains path:\n"
" \"" << *li << "\"\nwhich is prefixed in the build directory.";
target->GetMakefile()->IssueMessage(messageType, e.str());
}
@@ -333,8 +343,8 @@ static bool checkInterfaceDirs(const std::string &prepro,
{
if (inSource)
{
- e << "Target \"" << target->GetName() << "\" "
- "INTERFACE_INCLUDE_DIRECTORIES property contains path:\n"
+ e << "Target \"" << target->GetName() << "\" " << prop <<
+ " property contains path:\n"
" \"" << *li << "\"\nwhich is prefixed in the source directory.";
target->GetMakefile()->IssueMessage(messageType, e.str());
}
@@ -365,6 +375,46 @@ static void prefixItems(std::string &exportDirs)
}
//----------------------------------------------------------------------------
+void cmExportFileGenerator::PopulateSourcesInterface(
+ cmTargetExport *tei,
+ cmGeneratorExpression::PreprocessContext preprocessRule,
+ ImportPropertyMap &properties,
+ std::vector<std::string> &missingTargets)
+{
+ cmTarget *target = tei->Target;
+ assert(preprocessRule == cmGeneratorExpression::InstallInterface);
+
+ const char *propName = "INTERFACE_SOURCES";
+ const char *input = target->GetProperty(propName);
+
+ if (!input)
+ {
+ return;
+ }
+
+ if (!*input)
+ {
+ properties[propName] = "";
+ return;
+ }
+
+ std::string prepro = cmGeneratorExpression::Preprocess(input,
+ preprocessRule,
+ true);
+ if (!prepro.empty())
+ {
+ this->ResolveTargetsInGeneratorExpressions(prepro, target,
+ missingTargets);
+
+ if (!checkInterfaceDirs(prepro, target, propName))
+ {
+ return;
+ }
+ properties[propName] = prepro;
+ }
+}
+
+//----------------------------------------------------------------------------
void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
cmTargetExport *tei,
cmGeneratorExpression::PreprocessContext preprocessRule,
@@ -424,7 +474,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
this->ResolveTargetsInGeneratorExpressions(prepro, target,
missingTargets);
- if (!checkInterfaceDirs(prepro, target))
+ if (!checkInterfaceDirs(prepro, target, propName))
{
return;
}