cmExtraSublimeTextGenerator.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmExtraSublimeTextGenerator_h
  4. #define cmExtraSublimeTextGenerator_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include "cmExternalMakefileProjectGenerator.h"
  7. #include <map>
  8. #include <string>
  9. #include <vector>
  10. class cmGeneratedFileStream;
  11. class cmGeneratorTarget;
  12. class cmLocalGenerator;
  13. class cmMakefile;
  14. class cmSourceFile;
  15. /** \class cmExtraSublimeTextGenerator
  16. * \brief Write Sublime Text 2 project files for Makefile based projects
  17. */
  18. class cmExtraSublimeTextGenerator : public cmExternalMakefileProjectGenerator
  19. {
  20. public:
  21. static cmExternalMakefileProjectGeneratorFactory* GetFactory();
  22. typedef std::map<std::string, std::vector<std::string>> MapSourceFileFlags;
  23. cmExtraSublimeTextGenerator();
  24. void Generate() override;
  25. private:
  26. void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
  27. void CreateNewProjectFile(const std::vector<cmLocalGenerator*>& lgs,
  28. const std::string& filename);
  29. /** Appends all targets as build systems to the project file and get all
  30. * include directories and compiler definitions used.
  31. */
  32. void AppendAllTargets(const std::vector<cmLocalGenerator*>& lgs,
  33. const cmMakefile* mf, cmGeneratedFileStream& fout,
  34. MapSourceFileFlags& sourceFileFlags);
  35. /** Returns the build command that needs to be executed to build the
  36. * specified target.
  37. */
  38. std::string BuildMakeCommand(const std::string& make, const char* makefile,
  39. const std::string& target);
  40. /** Appends the specified target to the generated project file as a Sublime
  41. * Text build system.
  42. */
  43. void AppendTarget(cmGeneratedFileStream& fout, const std::string& targetName,
  44. cmLocalGenerator* lg, cmGeneratorTarget* target,
  45. const char* make, const cmMakefile* makefile,
  46. const char* compiler, MapSourceFileFlags& sourceFileFlags,
  47. bool firstTarget);
  48. /**
  49. * Compute the flags for compilation of object files for a given @a language.
  50. * @note Generally it is the value of the variable whose name is computed
  51. * by LanguageFlagsVarName().
  52. */
  53. std::string ComputeFlagsForObject(cmSourceFile* source, cmLocalGenerator* lg,
  54. cmGeneratorTarget* gtgt);
  55. std::string ComputeDefines(cmSourceFile* source, cmLocalGenerator* lg,
  56. cmGeneratorTarget* gtgt);
  57. std::string ComputeIncludes(cmSourceFile* source, cmLocalGenerator* lg,
  58. cmGeneratorTarget* gtgt);
  59. bool Open(const std::string& bindir, const std::string& projectName,
  60. bool dryRun) override;
  61. bool ExcludeBuildFolder;
  62. std::string EnvSettings;
  63. };
  64. #endif