summaryrefslogtreecommitdiffstats
path: root/Source/cmExtraEclipseCDT4Generator.h
blob: ebd8c081e2507300077ec100814ef2a5cdef24d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*============================================================================
  CMake - Cross Platform Makefile Generator
  Copyright 2004-2009 Kitware, Inc.
  Copyright 2004 Alexander Neundorf (neundorf@kde.org)
  Copyright 2007 Miguel A. Figueroa-Villanueva

  Distributed under the OSI-approved BSD License (the "License");
  see accompanying file Copyright.txt for details.

  This software is distributed WITHOUT ANY WARRANTY; without even the
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the License for more information.
============================================================================*/
#ifndef cmExtraEclipseCDT4Generator_h
#define cmExtraEclipseCDT4Generator_h

#include "cmExternalMakefileProjectGenerator.h"

class cmMakefile;
class cmGeneratedFileStream;

/** \class cmExtraEclipseCDT4Generator
 * \brief Write Eclipse project files for Makefile based projects
 */
class cmExtraEclipseCDT4Generator : public cmExternalMakefileProjectGenerator
{
public:
  enum LinkType {VirtualFolder, LinkToFolder, LinkToFile };

  cmExtraEclipseCDT4Generator();

  static cmExternalMakefileProjectGenerator* New() {
    return new cmExtraEclipseCDT4Generator;
  }

  virtual const char* GetName() const {
    return cmExtraEclipseCDT4Generator::GetActualName();
  }

  static const char* GetActualName() { return "Eclipse CDT4"; }

  virtual void GetDocumentation(cmDocumentationEntry& entry,
                                const char*           fullName) const;

  virtual void Generate();

private:
  // create .project file in the source tree
  void CreateSourceProjectFile();

  // create .project file
  void CreateProjectFile();

  // create .cproject file
  void CreateCProjectFile() const;

  // If built with cygwin cmake, convert posix to windows path.
  static std::string GetEclipsePath(const std::string& path);

  // Extract basename.
  static std::string GetPathBasename(const std::string& path);

  // Generate the project name as: <name>-<type>@<path>
  static std::string GenerateProjectName(const std::string& name,
                                         const std::string& type,
                                         const std::string& path);

  static std::string EscapeForXML(const std::string& value);

  // Helper functions
  static void AppendStorageScanners(cmGeneratedFileStream& fout,
                                    const cmMakefile& makefile);
  static void AppendTarget         (cmGeneratedFileStream& fout,
                                    const std::string&     target,
                                    const std::string&     make,
                                    const std::string&     makeArguments,
                                    const std::string&     path,
                                    const char* prefix = "",
                                    const char* makeTarget = NULL);
  static void AppendScannerProfile (cmGeneratedFileStream& fout,
                                    const std::string&   profileID,
                                    bool                 openActionEnabled,
                                    const std::string&   openActionFilePath,
                                    bool                 pParserEnabled,
                                    const std::string&   scannerInfoProviderID,
                                    const std::string&   runActionArguments,
                                    const std::string&   runActionCommand,
                                    bool                 runActionUseDefault,
                                    bool                 sipParserEnabled);

  static void AppendLinkedResource (cmGeneratedFileStream& fout,
                                    const std::string&     name,
                                    const std::string&     path,
                                    LinkType linkType);

  bool AppendOutLinkedResource(cmGeneratedFileStream& fout,
                               const std::string&     defname,
                               const std::string&     altdefname);

  static void AppendIncludeDirectories(cmGeneratedFileStream& fout,
                                   const std::vector<std::string>& includeDirs,
                                   std::set<std::string>& emittedDirs);

  static void AddEnvVar(cmGeneratedFileStream& fout, const char* envVar,
                        cmMakefile* mf);

  void CreateLinksToSubprojects(cmGeneratedFileStream& fout,
                                const std::string& baseDir);
  void CreateLinksForTargets(cmGeneratedFileStream& fout);

  std::vector<std::string> SrcLinkedResources;
  std::vector<std::string> OutLinkedResources;
  std::string HomeDirectory;
  std::string HomeOutputDirectory;
  bool IsOutOfSourceBuild;
  bool GenerateSourceProject;
  bool SupportsVirtualFolders;

};

#endif