summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-01-29 19:52:19 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-01-29 19:52:19 (GMT)
commit5f78d2057f1447afb6ec33e5f8a241c8bcdcd5f1 (patch)
treec473a92ace315c7cf2a48465a2643658a1425838 /Source
parent3e7bba3fb2d431b512181e99c6333e9dfdc8a9fd (diff)
parent34d1ade048a87953c089d730f0126eecb6685968 (diff)
downloadCMake-5f78d2057f1447afb6ec33e5f8a241c8bcdcd5f1.zip
CMake-5f78d2057f1447afb6ec33e5f8a241c8bcdcd5f1.tar.gz
CMake-5f78d2057f1447afb6ec33e5f8a241c8bcdcd5f1.tar.bz2
Merge topic 'fix-relocatable-include-dirs'
34d1ade Add the INSTALL_PREFIX genex. 3a17197 Generate the _IMPORT_PREFIX in the non-config export file.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmDocumentGeneratorExpressions.h2
-rw-r--r--Source/cmExportFileGenerator.cxx10
-rw-r--r--Source/cmExportFileGenerator.h2
-rw-r--r--Source/cmExportInstallFileGenerator.cxx72
-rw-r--r--Source/cmExportInstallFileGenerator.h2
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx20
6 files changed, 79 insertions, 29 deletions
diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h
index be9f2ff..8b80a8a 100644
--- a/Source/cmDocumentGeneratorExpressions.h
+++ b/Source/cmDocumentGeneratorExpressions.h
@@ -55,6 +55,8 @@
"the 'head' target was created, else '0'. If the policy was not " \
"set, the warning message for the policy will be emitted. This " \
"generator expression only works for a subset of policies.\n" \
+ " $<INSTALL_PREFIX> = Content of the install prefix when " \
+ "the target is exported via INSTALL(EXPORT) and empty otherwise.\n" \
"Boolean expressions:\n" \
" $<AND:?[,?]...> = '1' if all '?' are '1', else '0'\n" \
" $<OR:?[,?]...> = '0' if all '?' are '0', else '1'\n" \
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 96e0aea..2ae7138 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -431,6 +431,9 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
input.replace(pos, endPos - pos + 1, targetName);
lastPos = endPos;
}
+
+ this->ReplaceInstallPrefix(input);
+
if (!errorString.empty())
{
mf->IssueMessage(cmake::FATAL_ERROR, errorString);
@@ -439,6 +442,13 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
//----------------------------------------------------------------------------
void
+cmExportFileGenerator::ReplaceInstallPrefix(std::string &)
+{
+ // Do nothing
+}
+
+//----------------------------------------------------------------------------
+void
cmExportFileGenerator
::SetImportLinkInterface(const char* config, std::string const& suffix,
cmGeneratorExpression::PreprocessContext preprocessRule,
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index b39df0f..776be61 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -152,6 +152,8 @@ private:
void ResolveTargetsInGeneratorExpression(std::string &input,
cmTarget* target,
std::vector<std::string> &missingTargets);
+
+ virtual void ReplaceInstallPrefix(std::string &input);
};
#endif
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index a35f5cf..b6600f0 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -69,6 +69,27 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
this->GenerateExpectedTargetsCode(os, expectedTargets);
}
+ // Add code to compute the installation prefix relative to the
+ // import file location.
+ const char* installDest = this->IEGen->GetDestination();
+ if(!cmSystemTools::FileIsFullPath(installDest))
+ {
+ std::string dest = installDest;
+ os << "# Compute the installation prefix relative to this file.\n"
+ << "get_filename_component(_IMPORT_PREFIX "
+ << "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n";
+ while(!dest.empty())
+ {
+ os <<
+ "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n";
+ dest = cmSystemTools::GetFilenamePath(dest);
+ }
+ os << "\n";
+
+ // Import location properties may reference this variable.
+ this->ImportPrefix = "${_IMPORT_PREFIX}/";
+ }
+
std::vector<std::string> missingTargets;
// Create all the imported targets.
@@ -107,6 +128,13 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
<< "endforeach()\n"
<< "\n";
+ // Cleanup the import prefix variable.
+ if(!this->ImportPrefix.empty())
+ {
+ os << "# Cleanup temporary variables.\n"
+ << "set(_IMPORT_PREFIX)\n"
+ << "\n";
+ }
this->GenerateImportedFileCheckLoop(os);
// Generate an import file for each configuration.
@@ -127,6 +155,21 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
}
//----------------------------------------------------------------------------
+void
+cmExportInstallFileGenerator::ReplaceInstallPrefix(std::string &input)
+{
+ std::string::size_type pos = 0;
+ std::string::size_type lastPos = pos;
+
+ while((pos = input.find("$<INSTALL_PREFIX>", lastPos)) != input.npos)
+ {
+ std::string::size_type endPos = pos + sizeof("$<INSTALL_PREFIX>") - 1;
+ input.replace(pos, endPos - pos, "${_IMPORT_PREFIX}");
+ lastPos = endPos;
+ }
+}
+
+//----------------------------------------------------------------------------
bool
cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config,
std::vector<std::string> &missingTargets)
@@ -187,27 +230,6 @@ cmExportInstallFileGenerator
const char* config, std::string const& suffix,
std::vector<std::string> &missingTargets)
{
- // Add code to compute the installation prefix relative to the
- // import file location.
- const char* installDest = this->IEGen->GetDestination();
- if(!cmSystemTools::FileIsFullPath(installDest))
- {
- std::string dest = installDest;
- os << "# Compute the installation prefix relative to this file.\n"
- << "get_filename_component(_IMPORT_PREFIX "
- << "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n";
- while(!dest.empty())
- {
- os <<
- "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n";
- dest = cmSystemTools::GetFilenamePath(dest);
- }
- os << "\n";
-
- // Import location properties may reference this variable.
- this->ImportPrefix = "${_IMPORT_PREFIX}/";
- }
-
// Add each target in the set to the export.
for(std::vector<cmTargetExport*>::const_iterator
tei = this->IEGen->GetExportSet()->GetTargetExports()->begin();
@@ -253,14 +275,6 @@ cmExportInstallFileGenerator
importedLocations);
}
}
-
- // Cleanup the import prefix variable.
- if(!this->ImportPrefix.empty())
- {
- os << "# Cleanup temporary variables.\n"
- << "set(_IMPORT_PREFIX)\n"
- << "\n";
- }
}
//----------------------------------------------------------------------------
diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h
index e187749..7a70431 100644
--- a/Source/cmExportInstallFileGenerator.h
+++ b/Source/cmExportInstallFileGenerator.h
@@ -64,6 +64,8 @@ protected:
cmTarget* depender,
cmTarget* dependee);
+ virtual void ReplaceInstallPrefix(std::string &input);
+
void ComplainAboutMissingTarget(cmTarget* depender,
cmTarget* dependee,
int occurrences);
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 0c61a12..f74b69e 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -615,6 +615,24 @@ static const struct TargetPolicyNode : public cmGeneratorExpressionNode
} targetPolicyNode;
//----------------------------------------------------------------------------
+static const struct InstallPrefixNode : public cmGeneratorExpressionNode
+{
+ InstallPrefixNode() {}
+
+ virtual bool GeneratesContent() const { return false; }
+ virtual int NumExpectedParameters() const { return 0; }
+
+ std::string Evaluate(const std::vector<std::string> &,
+ cmGeneratorExpressionContext *,
+ const GeneratorExpressionContent *,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ return std::string();
+ }
+
+} installPrefixNode;
+
+//----------------------------------------------------------------------------
template<bool linker, bool soname>
struct TargetFilesystemArtifactResultCreator
{
@@ -849,6 +867,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
return &installInterfaceNode;
else if (identifier == "TARGET_DEFINED")
return &targetDefinedNode;
+ else if (identifier == "INSTALL_PREFIX")
+ return &installPrefixNode;
return 0;
}