cmExtraSublimeTextGenerator.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 <cmConfigure.h>
  14. #include "cmExternalMakefileProjectGenerator.h"
  15. #include <map>
  16. #include <string>
  17. #include <vector>
  18. class cmGeneratedFileStream;
  19. class cmGeneratorTarget;
  20. class cmLocalGenerator;
  21. class cmMakefile;
  22. class cmSourceFile;
  23. /** \class cmExtraSublimeTextGenerator
  24. * \brief Write Sublime Text 2 project files for Makefile based projects
  25. */
  26. class cmExtraSublimeTextGenerator : public cmExternalMakefileProjectGenerator
  27. {
  28. public:
  29. static cmExternalMakefileProjectGeneratorFactory* GetFactory();
  30. typedef std::map<std::string, std::vector<std::string> > MapSourceFileFlags;
  31. cmExtraSublimeTextGenerator();
  32. void Generate() CM_OVERRIDE;
  33. private:
  34. void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
  35. void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
  36. const std::string& filename);
  37. /** Appends all targets as build systems to the project file and get all
  38. * include directories and compiler definitions used.
  39. */
  40. void AppendAllTargets(const std::vector<cmLocalGenerator*>& lgs,
  41. const cmMakefile* mf, cmGeneratedFileStream& fout,
  42. MapSourceFileFlags& sourceFileFlags);
  43. /** Returns the build command that needs to be executed to build the
  44. * specified target.
  45. */
  46. std::string BuildMakeCommand(const std::string& make, const char* makefile,
  47. const std::string& target);
  48. /** Appends the specified target to the generated project file as a Sublime
  49. * Text build system.
  50. */
  51. void AppendTarget(cmGeneratedFileStream& fout, const std::string& targetName,
  52. cmLocalGenerator* lg, cmGeneratorTarget* target,
  53. const char* make, const cmMakefile* makefile,
  54. const char* compiler, MapSourceFileFlags& sourceFileFlags,
  55. bool firstTarget);
  56. /**
  57. * Compute the flags for compilation of object files for a given @a language.
  58. * @note Generally it is the value of the variable whose name is computed
  59. * by LanguageFlagsVarName().
  60. */
  61. std::string ComputeFlagsForObject(cmSourceFile* source, cmLocalGenerator* lg,
  62. cmGeneratorTarget* gtgt);
  63. std::string ComputeDefines(cmSourceFile* source, cmLocalGenerator* lg,
  64. cmGeneratorTarget* gtgt);
  65. };
  66. #endif