ENH: put the 64 bit paths first
[cmake.git] / Source / cmScriptGenerator.h
blobc74e46eb245ba28cb8228eb11554ab3f2b0e3683
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmScriptGenerator.h,v $
5 Language: C++
6 Date: $Date: 2009-03-16 14:39:53 $
7 Version: $Revision: 1.1 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmScriptGenerator_h
18 #define cmScriptGenerator_h
20 #include "cmStandardIncludes.h"
22 class cmScriptGeneratorIndent
24 public:
25 cmScriptGeneratorIndent(): Level(0) {}
26 cmScriptGeneratorIndent(int level): Level(level) {}
27 void Write(std::ostream& os) const
29 for(int i=0; i < this->Level; ++i)
31 os << " ";
34 cmScriptGeneratorIndent Next(int step = 2) const
36 return cmScriptGeneratorIndent(this->Level + step);
38 private:
39 int Level;
41 inline std::ostream& operator<<(std::ostream& os,
42 cmScriptGeneratorIndent const& indent)
44 indent.Write(os);
45 return os;
48 /** \class cmScriptGenerator
49 * \brief Support class for generating install and test scripts.
52 class cmScriptGenerator
54 public:
55 cmScriptGenerator(const char* config_var,
56 std::vector<std::string> const& configurations);
57 virtual ~cmScriptGenerator();
59 void Generate(std::ostream& os, const char* config,
60 std::vector<std::string> const& configurationTypes);
62 const std::vector<std::string>& GetConfigurations() const
63 { return this->Configurations; }
65 protected:
66 typedef cmScriptGeneratorIndent Indent;
67 virtual void GenerateScript(std::ostream& os);
68 virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent);
69 virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
70 virtual void GenerateScriptForConfig(std::ostream& os,
71 const char* config,
72 Indent const& indent);
74 // Test if this generator does something for a given configuration.
75 bool GeneratesForConfig(const char*);
77 std::string CreateConfigTest(const char* config);
78 std::string CreateConfigTest(std::vector<std::string> const& configs);
79 std::string CreateComponentTest(const char* component);
81 // Information shared by most generator types.
82 std::string RuntimeConfigVariable;
83 std::vector<std::string> const Configurations;
85 // Information used during generation.
86 const char* ConfigurationName;
87 std::vector<std::string> const* ConfigurationTypes;
89 // True if the subclass needs to generate an explicit rule for each
90 // configuration. False if the subclass only generates one rule for
91 // all enabled configurations.
92 bool ActionsPerConfig;
94 private:
95 void GenerateScriptActionsOnce(std::ostream& os, Indent const& indent);
96 void GenerateScriptActionsPerConfig(std::ostream& os, Indent const& indent);
99 #endif