cmExtraSublimeTextGenerator.h 3.5 KB

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