cmInstallScriptGenerator.cxx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmInstallScriptGenerator.h"
  4. #include "cmScriptGenerator.h"
  5. #include <ostream>
  6. #include <vector>
  7. cmInstallScriptGenerator::cmInstallScriptGenerator(const char* script,
  8. bool code,
  9. const char* component,
  10. bool exclude_from_all)
  11. : cmInstallGenerator(nullptr, std::vector<std::string>(), component,
  12. MessageDefault, exclude_from_all)
  13. , Script(script)
  14. , Code(code)
  15. {
  16. }
  17. cmInstallScriptGenerator::~cmInstallScriptGenerator()
  18. {
  19. }
  20. void cmInstallScriptGenerator::GenerateScript(std::ostream& os)
  21. {
  22. Indent indent;
  23. std::string component_test =
  24. this->CreateComponentTest(this->Component.c_str(), this->ExcludeFromAll);
  25. os << indent << "if(" << component_test << ")\n";
  26. if (this->Code) {
  27. os << indent.Next() << this->Script << "\n";
  28. } else {
  29. os << indent.Next() << "include(\"" << this->Script << "\")\n";
  30. }
  31. os << indent << "endif()\n\n";
  32. }