cmExtraEclipseCDT4Generator.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 cmExtraEclipseCDT4Generator_h
  4. #define cmExtraEclipseCDT4Generator_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include "cmExternalMakefileProjectGenerator.h"
  7. #include <iosfwd>
  8. #include <set>
  9. #include <string>
  10. #include <vector>
  11. class cmLocalGenerator;
  12. class cmMakefile;
  13. class cmSourceGroup;
  14. class cmXMLWriter;
  15. /** \class cmExtraEclipseCDT4Generator
  16. * \brief Write Eclipse project files for Makefile based projects
  17. */
  18. class cmExtraEclipseCDT4Generator : public cmExternalMakefileProjectGenerator
  19. {
  20. public:
  21. enum LinkType
  22. {
  23. VirtualFolder,
  24. LinkToFolder,
  25. LinkToFile
  26. };
  27. cmExtraEclipseCDT4Generator();
  28. static cmExternalMakefileProjectGeneratorFactory* GetFactory();
  29. void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
  30. bool optional) override;
  31. void Generate() override;
  32. private:
  33. // create .project file in the source tree
  34. void CreateSourceProjectFile();
  35. // create .project file
  36. void CreateProjectFile();
  37. // create .cproject file
  38. void CreateCProjectFile() const;
  39. // If built with cygwin cmake, convert posix to windows path.
  40. static std::string GetEclipsePath(const std::string& path);
  41. // Extract basename.
  42. static std::string GetPathBasename(const std::string& path);
  43. // Generate the project name as: <name>-<type>@<path>
  44. static std::string GenerateProjectName(const std::string& name,
  45. const std::string& type,
  46. const std::string& path);
  47. // Helper functions
  48. static void AppendStorageScanners(cmXMLWriter& xml,
  49. const cmMakefile& makefile);
  50. static void AppendTarget(cmXMLWriter& xml, const std::string& target,
  51. const std::string& make,
  52. const std::string& makeArguments,
  53. const std::string& path, const char* prefix = "",
  54. const char* makeTarget = nullptr);
  55. static void AppendScannerProfile(
  56. cmXMLWriter& xml, const std::string& profileID, bool openActionEnabled,
  57. const std::string& openActionFilePath, bool pParserEnabled,
  58. const std::string& scannerInfoProviderID,
  59. const std::string& runActionArguments, const std::string& runActionCommand,
  60. bool runActionUseDefault, bool sipParserEnabled);
  61. static void AppendLinkedResource(cmXMLWriter& xml, const std::string& name,
  62. const std::string& path, LinkType linkType);
  63. static void AppendIncludeDirectories(
  64. cmXMLWriter& xml, const std::vector<std::string>& includeDirs,
  65. std::set<std::string>& emittedDirs);
  66. static void AddEnvVar(std::ostream& out, const char* envVar,
  67. cmLocalGenerator* lg);
  68. void WriteGroups(std::vector<cmSourceGroup> const& sourceGroups,
  69. std::string& linkName, cmXMLWriter& xml);
  70. void CreateLinksToSubprojects(cmXMLWriter& xml, const std::string& baseDir);
  71. void CreateLinksForTargets(cmXMLWriter& xml);
  72. std::vector<std::string> SrcLinkedResources;
  73. std::set<std::string> Natures;
  74. std::string HomeDirectory;
  75. std::string HomeOutputDirectory;
  76. bool IsOutOfSourceBuild;
  77. bool GenerateSourceProject;
  78. bool GenerateLinkedResources;
  79. bool SupportsVirtualFolders;
  80. bool SupportsGmakeErrorParser;
  81. bool SupportsMachO64Parser;
  82. bool CEnabled;
  83. bool CXXEnabled;
  84. };
  85. #endif