cmInstallScriptGenerator.cxx 1.17 KB
Newer Older
1 2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
3 4
#include "cmInstallScriptGenerator.h"

5 6 7 8 9
#include "cmScriptGenerator.h"

#include <ostream>
#include <vector>

10 11 12 13
cmInstallScriptGenerator::cmInstallScriptGenerator(const char* script,
                                                   bool code,
                                                   const char* component,
                                                   bool exclude_from_all)
Daniel Pfeifer's avatar
Daniel Pfeifer committed
14
  : cmInstallGenerator(CM_NULLPTR, std::vector<std::string>(), component,
15 16 17
                       MessageDefault, exclude_from_all)
  , Script(script)
  , Code(code)
18 19 20
{
}

21
cmInstallScriptGenerator::~cmInstallScriptGenerator()
22 23 24 25 26
{
}

void cmInstallScriptGenerator::GenerateScript(std::ostream& os)
{
27 28
  Indent indent;
  std::string component_test =
29
    this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll);
30
  os << indent << "if(" << component_test << ")\n";
31

32
  if (this->Code) {
33
    os << indent.Next() << this->Script << "\n";
34
  } else {
35
    os << indent.Next() << "include(\"" << this->Script << "\")\n";
36
  }
37

38
  os << indent << "endif()\n\n";
39
}