Imported Upstream version 2.8.12.2
[platform/upstream/cmake.git] / Source / cmExtraSublimeTextGenerator.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2004-2009 Kitware, Inc.
4   Copyright 2004 Alexander Neundorf (neundorf@kde.org)
5
6   Distributed under the OSI-approved BSD License (the "License");
7   see accompanying file Copyright.txt for details.
8
9   This software is distributed WITHOUT ANY WARRANTY; without even the
10   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11   See the License for more information.
12 ============================================================================*/
13 #ifndef cmExtraSublimeTextGenerator_h
14 #define cmExtraSublimeTextGenerator_h
15
16 #include "cmExternalMakefileProjectGenerator.h"
17 #include "cmSourceFile.h"
18
19 class cmLocalGenerator;
20 class cmMakefile;
21 class cmTarget;
22 class cmGeneratedFileStream;
23 class cmGeneratorTarget;
24
25 /** \class cmExtraSublimeTextGenerator
26  * \brief Write Sublime Text 2 project files for Makefile based projects
27  */
28 class cmExtraSublimeTextGenerator : public cmExternalMakefileProjectGenerator
29 {
30 public:
31   typedef std::map<std::string, std::vector<std::string> > MapSourceFileFlags;
32   cmExtraSublimeTextGenerator();
33
34   virtual const char* GetName() const
35                         { return cmExtraSublimeTextGenerator::GetActualName();}
36   static const char* GetActualName()
37                         { return "Sublime Text 2";}
38   static cmExternalMakefileProjectGenerator* New()
39                                     { return new cmExtraSublimeTextGenerator; }
40   /** Get the documentation entry for this generator.  */
41   virtual void GetDocumentation(cmDocumentationEntry& entry,
42                                 const char* fullName) const;
43
44   virtual void Generate();
45 private:
46
47   void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
48
49   void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
50                                 const std::string& filename);
51
52   /** Appends all targets as build systems to the project file and get all
53    * include directories and compiler definitions used.
54    */
55   void AppendAllTargets(const std::vector<cmLocalGenerator*>& lgs,
56                         const cmMakefile* mf,
57                         cmGeneratedFileStream& fout,
58                         MapSourceFileFlags& sourceFileFlags);
59   /** Returns the build command that needs to be executed to build the
60    *  specified target.
61    */
62   std::string BuildMakeCommand(const std::string& make, const char* makefile,
63                                const char* target);
64   /** Appends the specified target to the generated project file as a Sublime
65    *  Text build system.
66    */
67   void AppendTarget(cmGeneratedFileStream& fout,
68                     const char* targetName,
69                     cmLocalGenerator* lg,
70                     cmTarget* target,
71                     const char* make,
72                     const cmMakefile* makefile,
73                     const char* compiler,
74                     MapSourceFileFlags& sourceFileFlags, bool firstTarget);
75   /**
76    * Compute the flags for compilation of object files for a given @a language.
77    * @note Generally it is the value of the variable whose name is computed
78    *       by LanguageFlagsVarName().
79    */
80   std::string ComputeFlagsForObject(cmSourceFile *source,
81                                     cmLocalGenerator* lg,
82                                     cmTarget *target,
83                                     cmGeneratorTarget* gtgt);
84
85   std::string ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg,
86                              cmTarget *target, cmGeneratorTarget* gtgt);
87 };
88
89 #endif