cmake/Source/cmInstallScriptGenerator.cxx

40 lines
1.2 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallScriptGenerator.h"
2016-10-30 18:24:19 +01:00
#include "cmScriptGenerator.h"
2016-10-30 18:24:19 +01:00
#include <ostream>
#include <vector>
2016-07-09 11:21:54 +02:00
cmInstallScriptGenerator::cmInstallScriptGenerator(const char* script,
bool code,
const char* component,
bool exclude_from_all)
2018-01-26 17:06:56 +01:00
: cmInstallGenerator(nullptr, std::vector<std::string>(), component,
2016-07-09 11:21:54 +02:00
MessageDefault, exclude_from_all)
, Script(script)
, Code(code)
{
}
2016-07-09 11:21:54 +02:00
cmInstallScriptGenerator::~cmInstallScriptGenerator()
{
}
void cmInstallScriptGenerator::GenerateScript(std::ostream& os)
{
Indent indent;
std::string component_test =
2016-07-09 11:21:54 +02:00
this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll);
2014-08-03 19:52:23 +02:00
os << indent << "if(" << component_test << ")\n";
2016-07-09 11:21:54 +02:00
if (this->Code) {
os << indent.Next() << this->Script << "\n";
2016-07-09 11:21:54 +02:00
} else {
2014-08-03 19:52:23 +02:00
os << indent.Next() << "include(\"" << this->Script << "\")\n";
2016-07-09 11:21:54 +02:00
}
2014-08-03 19:52:23 +02:00
os << indent << "endif()\n\n";
}