summaryrefslogtreecommitdiffstats
path: root/Source/cmInstallScriptGenerator.cxx
diff options
context:
space:
mode:
authorJon Chronopoulos <patches@crondog.com>2018-05-29 11:37:26 (GMT)
committerBrad King <brad.king@kitware.com>2018-06-07 17:18:23 (GMT)
commit6dad812143ae50df5ed0de4c5c2d433b6d59aea2 (patch)
tree9a20cd5510a8275bbef5405c8342fd316392ca90 /Source/cmInstallScriptGenerator.cxx
parentacaaca968c512fa420f3564649be1f49acfa6a6a (diff)
downloadCMake-6dad812143ae50df5ed0de4c5c2d433b6d59aea2.zip
CMake-6dad812143ae50df5ed0de4c5c2d433b6d59aea2.tar.gz
CMake-6dad812143ae50df5ed0de4c5c2d433b6d59aea2.tar.bz2
install: Teach CODE,SCRIPT modes to evaluate generator expressions
Fixes: #15785
Diffstat (limited to 'Source/cmInstallScriptGenerator.cxx')
-rw-r--r--Source/cmInstallScriptGenerator.cxx40
1 files changed, 32 insertions, 8 deletions
diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx
index f7e6e44..3a90f4c 100644
--- a/Source/cmInstallScriptGenerator.cxx
+++ b/Source/cmInstallScriptGenerator.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallScriptGenerator.h"
+#include "cmGeneratorExpression.h"
#include "cmScriptGenerator.h"
#include <ostream>
@@ -16,24 +17,47 @@ cmInstallScriptGenerator::cmInstallScriptGenerator(const char* script,
, Script(script)
, Code(code)
{
+ // We need per-config actions if the script has generator expressions.
+ if (cmGeneratorExpression::Find(Script) != std::string::npos) {
+ this->ActionsPerConfig = true;
+ }
}
cmInstallScriptGenerator::~cmInstallScriptGenerator()
{
}
-void cmInstallScriptGenerator::GenerateScript(std::ostream& os)
+void cmInstallScriptGenerator::Compute(cmLocalGenerator* lg)
{
- Indent indent;
- std::string component_test =
- this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll);
- os << indent << "if(" << component_test << ")\n";
+ this->LocalGenerator = lg;
+}
+void cmInstallScriptGenerator::AddScriptInstallRule(std::ostream& os,
+ Indent indent,
+ std::string const& script)
+{
if (this->Code) {
- os << indent.Next() << this->Script << "\n";
+ os << indent.Next() << script << "\n";
+ } else {
+ os << indent.Next() << "include(\"" << script << "\")\n";
+ }
+}
+
+void cmInstallScriptGenerator::GenerateScriptActions(std::ostream& os,
+ Indent indent)
+{
+ if (this->ActionsPerConfig) {
+ this->cmInstallGenerator::GenerateScriptActions(os, indent);
} else {
- os << indent.Next() << "include(\"" << this->Script << "\")\n";
+ this->AddScriptInstallRule(os, indent, this->Script);
}
+}
- os << indent << "endif()\n\n";
+void cmInstallScriptGenerator::GenerateScriptForConfig(
+ std::ostream& os, const std::string& config, Indent indent)
+{
+ cmGeneratorExpression ge;
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(this->Script);
+ this->AddScriptInstallRule(os, indent,
+ cge->Evaluate(this->LocalGenerator, config));
}