1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying 2 file Copyright.txt or https://cmake.org/licensing for details. */ 3 #pragma once 4 5 #include "cmConfigure.h" // IWYU pragma: keep 6 7 #include <iosfwd> 8 #include <set> 9 #include <string> 10 #include <vector> 11 12 #include "cmExternalMakefileProjectGenerator.h" 13 14 class cmLocalGenerator; 15 class cmMakefile; 16 class cmSourceGroup; 17 class cmXMLWriter; 18 19 /** \class cmExtraEclipseCDT4Generator 20 * \brief Write Eclipse project files for Makefile based projects 21 */ 22 class cmExtraEclipseCDT4Generator : public cmExternalMakefileProjectGenerator 23 { 24 public: 25 enum LinkType 26 { 27 VirtualFolder, 28 LinkToFolder, 29 LinkToFile 30 }; 31 32 cmExtraEclipseCDT4Generator(); 33 34 static cmExternalMakefileProjectGeneratorFactory* GetFactory(); 35 36 void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*, 37 bool optional) override; 38 39 void Generate() override; 40 41 private: 42 // create .project file in the source tree 43 void CreateSourceProjectFile(); 44 45 // create .settings/org.eclipse.core.resources.prefs 46 void CreateSettingsResourcePrefsFile(); 47 48 // create .project file 49 void CreateProjectFile(); 50 51 // create .cproject file 52 void CreateCProjectFile() const; 53 54 // If built with cygwin cmake, convert posix to windows path. 55 static std::string GetEclipsePath(const std::string& path); 56 57 // Extract basename. 58 static std::string GetPathBasename(const std::string& path); 59 60 // Generate the project name as: <name>-<type>@<path> 61 static std::string GenerateProjectName(const std::string& name, 62 const std::string& type, 63 const std::string& path); 64 65 // Helper functions 66 static void AppendStorageScanners(cmXMLWriter& xml, 67 const cmMakefile& makefile); 68 static void AppendTarget(cmXMLWriter& xml, const std::string& target, 69 const std::string& make, 70 const std::string& makeArguments, 71 const std::string& path, const char* prefix = "", 72 const char* makeTarget = nullptr); 73 static void AppendScannerProfile( 74 cmXMLWriter& xml, const std::string& profileID, bool openActionEnabled, 75 const std::string& openActionFilePath, bool pParserEnabled, 76 const std::string& scannerInfoProviderID, 77 const std::string& runActionArguments, const std::string& runActionCommand, 78 bool runActionUseDefault, bool sipParserEnabled); 79 80 static void AppendLinkedResource(cmXMLWriter& xml, const std::string& name, 81 const std::string& path, LinkType linkType); 82 83 static void AppendIncludeDirectories( 84 cmXMLWriter& xml, const std::vector<std::string>& includeDirs, 85 std::set<std::string>& emittedDirs); 86 87 static void AddEnvVar(std::ostream& out, const char* envVar, 88 cmLocalGenerator& lg); 89 90 void WriteGroups(std::vector<cmSourceGroup> const& sourceGroups, 91 std::string& linkName, cmXMLWriter& xml); 92 void CreateLinksToSubprojects(cmXMLWriter& xml, const std::string& baseDir); 93 void CreateLinksForTargets(cmXMLWriter& xml); 94 95 std::vector<std::string> SrcLinkedResources; 96 std::set<std::string> Natures; 97 std::string HomeDirectory; 98 std::string HomeOutputDirectory; 99 bool IsOutOfSourceBuild; 100 bool GenerateSourceProject; 101 bool GenerateLinkedResources; 102 bool SupportsVirtualFolders; 103 bool SupportsGmakeErrorParser; 104 bool SupportsMachO64Parser; 105 bool CEnabled; 106 bool CXXEnabled; 107 }; 108