Imported Upstream version 2.8.12.2
[platform/upstream/cmake.git] / Source / cmInstallScriptGenerator.cxx
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #include "cmInstallScriptGenerator.h"
13
14 //----------------------------------------------------------------------------
15 cmInstallScriptGenerator
16 ::cmInstallScriptGenerator(const char* script, bool code,
17                            const char* component) :
18   cmInstallGenerator(0, std::vector<std::string>(), component),
19   Script(script), Code(code)
20 {
21 }
22
23 //----------------------------------------------------------------------------
24 cmInstallScriptGenerator
25 ::~cmInstallScriptGenerator()
26 {
27 }
28
29 //----------------------------------------------------------------------------
30 void cmInstallScriptGenerator::GenerateScript(std::ostream& os)
31 {
32   Indent indent;
33   std::string component_test =
34     this->CreateComponentTest(this->Component.c_str());
35   os << indent << "IF(" << component_test << ")\n";
36
37   if(this->Code)
38     {
39     os << indent.Next() << this->Script << "\n";
40     }
41   else
42     {
43     os << indent.Next() << "INCLUDE(\"" << this->Script << "\")\n";
44     }
45
46   os << indent << "ENDIF(" << component_test << ")\n\n";
47 }