cmLocalVisualStudio7Generator.h 5.51 KB
Newer Older
1 2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
Ken Martin's avatar
Ken Martin committed
3 4 5
#ifndef cmLocalVisualStudio7Generator_h
#define cmLocalVisualStudio7Generator_h

6
#include "cmConfigure.h" // IWYU pragma: keep
7 8 9 10

#include <iosfwd>
#include <string>
#include <vector>
11

12
#include "cmLocalVisualStudioGenerator.h"
13
#include "cmVisualStudioGeneratorOptions.h"
Ken Martin's avatar
Ken Martin committed
14

15
class cmCustomCommand;
16 17
class cmGeneratorTarget;
class cmGlobalGenerator;
18
class cmLocalVisualStudio7GeneratorFCInfo;
19
class cmLocalVisualStudio7GeneratorInternals;
20 21 22
class cmMakefile;
class cmSourceFile;
class cmSourceGroup;
23

24 25 26 27 28 29 30 31 32
class cmVS7GeneratorOptions : public cmVisualStudioGeneratorOptions
{
public:
  cmVS7GeneratorOptions(cmLocalVisualStudioGenerator* lg, Tool tool,
                        cmVS7FlagTable const* table = nullptr,
                        cmVS7FlagTable const* extraTable = nullptr)
    : cmVisualStudioGeneratorOptions(lg, tool, table, extraTable)
  {
  }
33
  void OutputFlag(std::ostream& fout, int indent, const char* tag,
34 35 36
                  const std::string& content) override;
};

Ken Martin's avatar
Ken Martin committed
37
/** \class cmLocalVisualStudio7Generator
38
 * \brief Write Visual Studio .NET project files.
Ken Martin's avatar
Ken Martin committed
39
 *
40 41
 * cmLocalVisualStudio7Generator produces a Visual Studio .NET project
 * file for each target in its directory.
Ken Martin's avatar
Ken Martin committed
42
 */
43
class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator
Ken Martin's avatar
Ken Martin committed
44 45
{
public:
46
  //! Set cache only and recurse to false by default.
47
  cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf);
Ken Martin's avatar
Ken Martin committed
48 49

  virtual ~cmLocalVisualStudio7Generator();
50

51
  void AddHelperCommands() override;
52

Ken Martin's avatar
Ken Martin committed
53
  /**
54
   * Generate the makefile for this directory.
Ken Martin's avatar
Ken Martin committed
55
   */
56
  void Generate() override;
Ken Martin's avatar
Ken Martin committed
57

58 59 60 61 62 63 64 65
  enum BuildType
  {
    STATIC_LIBRARY,
    DLL,
    EXECUTABLE,
    WIN32_EXECUTABLE,
    UTILITY
  };
Ken Martin's avatar
Ken Martin committed
66 67 68 69

  /**
   * Specify the type of the build: static, dll, or executable.
   */
70
  void SetBuildType(BuildType, const std::string& name);
Ken Martin's avatar
Ken Martin committed
71

72 73
  std::string GetTargetDirectory(
    cmGeneratorTarget const* target) const override;
74 75
  cmSourceFile* CreateVCProjBuildRule();
  void WriteStampFiles();
76 77
  std::string ComputeLongestObjectDirectory(
    cmGeneratorTarget const*) const override;
78

79
  virtual void ReadAndStoreExternalGUID(const std::string& name,
80
                                        const char* path);
81

82
protected:
83 84
  void CreateSingleVCProj(const std::string& lname, cmGeneratorTarget* tgt);

Ken Martin's avatar
Ken Martin committed
85
private:
86
  typedef cmVS7GeneratorOptions Options;
87
  typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo;
88
  std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
89
                                      const std::string& configName);
90
  void FixGlobalTargets();
91
  void WriteProjectFiles();
92
  void WriteVCProjHeader(std::ostream& fout, const std::string& libName,
93
                         cmGeneratorTarget* tgt,
94
                         std::vector<cmSourceGroup>& sgs);
95
  void WriteVCProjFooter(std::ostream& fout, cmGeneratorTarget* target);
96
  void WriteVCProjFile(std::ostream& fout, const std::string& libName,
97
                       cmGeneratorTarget* tgt);
Ken Martin's avatar
Ken Martin committed
98
  void WriteConfigurations(std::ostream& fout,
99
                           std::vector<std::string> const& configs,
100
                           const std::string& libName, cmGeneratorTarget* tgt);
101
  void WriteConfiguration(std::ostream& fout, const std::string& configName,
102
                          const std::string& libName, cmGeneratorTarget* tgt);
103
  std::string EscapeForXML(const std::string& s);
Ken Martin's avatar
Ken Martin committed
104 105
  std::string ConvertToXMLOutputPath(const char* path);
  std::string ConvertToXMLOutputPathSingle(const char* path);
106
  void OutputTargetRules(std::ostream& fout, const std::string& configName,
107 108
                         cmGeneratorTarget* target,
                         const std::string& libName);
109
  void OutputBuildTool(std::ostream& fout, const std::string& configName,
110
                       cmGeneratorTarget* t, const Options& targetOptions);
111 112 113
  void OutputDeploymentDebuggerTool(std::ostream& fout,
                                    std::string const& config,
                                    cmGeneratorTarget* target);
Ken Martin's avatar
Ken Martin committed
114
  void OutputLibraryDirectories(std::ostream& fout,
115
                                std::vector<std::string> const& dirs);
116
  void WriteProjectSCC(std::ostream& fout, cmGeneratorTarget* target);
117
  void WriteProjectStart(std::ostream& fout, const std::string& libName,
118
                         cmGeneratorTarget* tgt,
119
                         std::vector<cmSourceGroup>& sgs);
120
  void WriteProjectStartFortran(std::ostream& fout, const std::string& libName,
121
                                cmGeneratorTarget* tgt);
122 123
  void WriteVCProjBeginGroup(std::ostream& fout, const char* group,
                             const char* filter);
Ken Martin's avatar
Ken Martin committed
124
  void WriteVCProjEndGroup(std::ostream& fout);
125

Ken Martin's avatar
Ken Martin committed
126
  void WriteCustomRule(std::ostream& fout,
127
                       std::vector<std::string> const& configs,
128
                       const char* source, const cmCustomCommand& command,
129
                       FCInfo& fcinfo);
130
  void WriteTargetVersionAttribute(std::ostream& fout, cmGeneratorTarget* gt);
Ken Martin's avatar
Ken Martin committed
131

132
  class AllConfigSources;
133 134
  bool WriteGroup(const cmSourceGroup* sg, cmGeneratorTarget* target,
                  std::ostream& fout, const std::string& libName,
135
                  std::vector<std::string> const& configs,
136
                  AllConfigSources const& sources);
137

138
  friend class cmLocalVisualStudio7GeneratorFCInfo;
139
  friend class cmLocalVisualStudio7GeneratorInternals;
140

141
  class EventWriter;
142

143 144
  friend class EventWriter;

145
  bool FortranProject;
146
  bool WindowsCEProject;
147
  cmLocalVisualStudio7GeneratorInternals* Internal;
Ken Martin's avatar
Ken Martin committed
148 149 150
};

#endif