cmVisualStudio10TargetGenerator.h 9.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.  */
3 4
#ifndef cmVisualStudioTargetGenerator_h
#define cmVisualStudioTargetGenerator_h
5

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

8 9
#include <iosfwd>
#include <map>
10
#include <memory>
11 12 13
#include <set>
#include <string>
#include <vector>
14

15 16
class cmComputeLinkInformation;
class cmCustomCommand;
17
class cmGeneratedFileStream;
18
class cmGeneratorTarget;
Brad King's avatar
Brad King committed
19
class cmGlobalVisualStudio10Generator;
20
class cmLocalVisualStudio10Generator;
21 22 23
class cmMakefile;
class cmSourceFile;
class cmSourceGroup;
24
class cmVS10GeneratorOptions;
25 26 27 28

class cmVisualStudio10TargetGenerator
{
public:
29
  cmVisualStudio10TargetGenerator(cmGeneratorTarget* target,
Brad King's avatar
Brad King committed
30
                                  cmGlobalVisualStudio10Generator* gg);
31
  ~cmVisualStudio10TargetGenerator();
wahikihiki's avatar
wahikihiki committed
32 33 34 35 36 37

  cmVisualStudio10TargetGenerator(cmVisualStudio10TargetGenerator const&) =
    delete;
  cmVisualStudio10TargetGenerator& operator=(
    cmVisualStudio10TargetGenerator const&) = delete;

38
  void Generate();
39

40
private:
41 42
  struct ToolSource
  {
43
    cmSourceFile const* SourceFile;
44 45
    bool RelativePath;
  };
46 47 48
  struct ToolSources : public std::vector<ToolSource>
  {
  };
49

50 51 52 53 54 55
  struct TargetsFileAndConfigs
  {
    std::string File;
    std::vector<std::string> Configs;
  };

56
  struct Elem;
57
  struct OptionsHelper;
58

59
  std::string ConvertPath(std::string const& path, bool forceRelative);
60
  std::string CalcCondition(const std::string& config) const;
61 62 63
  void WriteProjectConfigurations(Elem& e0);
  void WriteProjectConfigurationValues(Elem& e0);
  void WriteMSToolConfigurationValues(Elem& e1, std::string const& config);
64
  void WriteCEDebugProjectConfigurationValues(Elem& e0);
65 66 67 68 69 70
  void WriteMSToolConfigurationValuesManaged(Elem& e1,
                                             std::string const& config);
  void WriteHeaderSource(Elem& e1, cmSourceFile const* sf);
  void WriteExtraSource(Elem& e1, cmSourceFile const* sf);
  void WriteNsightTegraConfigurationValues(Elem& e1,
                                           std::string const& config);
71
  void WriteSource(Elem& e2, cmSourceFile const* sf);
72
  void WriteExcludeFromBuild(Elem& e2,
73
                             std::vector<size_t> const& exclude_configs);
74
  void WriteAllSources(Elem& e0);
75 76 77
  void WritePackageReferences(Elem& e0);
  void WritePackageReference(Elem& e1, std::string const& ref,
                             std::string const& version);
78 79 80
  void WriteDotNetReferences(Elem& e0);
  void WriteDotNetReference(Elem& e1, std::string const& ref,
                            std::string const& hint,
81
                            std::string const& config);
82
  void WriteImports(Elem& e0);
83 84 85 86 87 88 89
  void WriteDotNetReferenceCustomTags(Elem& e2, std::string const& ref);
  void WriteEmbeddedResourceGroup(Elem& e0);
  void WriteWinRTReferences(Elem& e0);
  void WriteWinRTPackageCertificateKeyFile(Elem& e0);
  void WriteXamlFilesGroup(Elem& e0);
  void WritePathAndIncrementalLinkOptions(Elem& e0);
  void WriteItemDefinitionGroups(Elem& e0);
90
  void VerifyNecessaryFiles();
91 92 93 94 95 96 97 98
  void WriteMissingFiles(Elem& e1);
  void WriteMissingFilesWP80(Elem& e1);
  void WriteMissingFilesWP81(Elem& e1);
  void WriteMissingFilesWS80(Elem& e1);
  void WriteMissingFilesWS81(Elem& e1);
  void WriteMissingFilesWS10_0(Elem& e1);
  void WritePlatformExtensions(Elem& e1);
  void WriteSinglePlatformExtension(Elem& e1, std::string const& extension,
99
                                    std::string const& version);
100 101
  void WriteSDKReferences(Elem& e0);
  void WriteSingleSDKReference(Elem& e1, std::string const& extension,
102
                               std::string const& version);
103 104 105
  void WriteCommonMissingFiles(Elem& e1, const std::string& manifestFile);
  void WriteTargetSpecificReferences(Elem& e0);
  void WriteTargetsFileReferences(Elem& e1);
106

107 108 109
  std::vector<std::string> GetIncludes(std::string const& config,
                                       std::string const& lang) const;

110 111
  bool ComputeClOptions();
  bool ComputeClOptions(std::string const& configName);
112
  void WriteClOptions(Elem& e1, std::string const& config);
113 114
  bool ComputeRcOptions();
  bool ComputeRcOptions(std::string const& config);
115
  void WriteRCOptions(Elem& e1, std::string const& config);
116 117
  bool ComputeCudaOptions();
  bool ComputeCudaOptions(std::string const& config);
118
  void WriteCudaOptions(Elem& e1, std::string const& config);
119 120 121

  bool ComputeCudaLinkOptions();
  bool ComputeCudaLinkOptions(std::string const& config);
122
  void WriteCudaLinkOptions(Elem& e1, std::string const& config);
123

124 125
  bool ComputeMasmOptions();
  bool ComputeMasmOptions(std::string const& config);
126
  void WriteMasmOptions(Elem& e1, std::string const& config);
127 128
  bool ComputeNasmOptions();
  bool ComputeNasmOptions(std::string const& config);
129
  void WriteNasmOptions(Elem& e1, std::string const& config);
130

131 132
  bool ComputeLinkOptions();
  bool ComputeLinkOptions(std::string const& config);
133 134
  bool ComputeLibOptions();
  bool ComputeLibOptions(std::string const& config);
135 136 137 138 139
  void WriteLinkOptions(Elem& e1, std::string const& config);
  void WriteMidlOptions(Elem& e1, std::string const& config);
  void WriteAntBuildOptions(Elem& e1, std::string const& config);
  void OutputLinkIncremental(Elem& e1, std::string const& configName);
  void WriteCustomRule(Elem& e0, cmSourceFile const* source,
140
                       cmCustomCommand const& command);
141
  void WriteCustomRuleCpp(Elem& e2, std::string const& config,
142 143
                          std::string const& script,
                          std::string const& additional_inputs,
144 145
                          std::string const& outputs,
                          std::string const& comment);
146
  void WriteCustomRuleCSharp(Elem& e0, std::string const& config,
147 148 149 150 151
                             std::string const& commandName,
                             std::string const& script,
                             std::string const& inputs,
                             std::string const& outputs,
                             std::string const& comment);
152 153
  void WriteCustomCommands(Elem& e0);
  void WriteCustomCommand(Elem& e0, cmSourceFile const* sf);
154
  void WriteGroups();
155 156
  void WriteProjectReferences(Elem& e0);
  void WriteApplicationTypeSettings(Elem& e1);
157
  void OutputSourceSpecificFlags(Elem& e2, cmSourceFile const* source);
158
  void AddLibraries(const cmComputeLinkInformation& cli,
159
                    std::vector<std::string>& libVec,
160 161
                    std::vector<std::string>& vsTargetVec,
                    const std::string& config);
162 163
  void AddTargetsFileAndConfigPair(std::string const& targetsFile,
                                   std::string const& config);
164 165 166 167
  void WriteLibOptions(Elem& e1, std::string const& config);
  void WriteManifestOptions(Elem& e1, std::string const& config);
  void WriteEvents(Elem& e1, std::string const& configName);
  void WriteEvent(Elem& e1, const char* name,
168
                  std::vector<cmCustomCommand> const& commands,
169
                  std::string const& configName);
170 171
  void WriteGroupSources(Elem& e0, std::string const& name,
                         ToolSources const& sources,
172
                         std::vector<cmSourceGroup>&);
173
  void AddMissingSourceGroups(std::set<cmSourceGroup const*>& groupsUsed,
174
                              const std::vector<cmSourceGroup>& allGroups);
175
  bool IsResxHeader(const std::string& headerFile);
176 177
  bool IsXamlHeader(const std::string& headerFile);
  bool IsXamlSource(const std::string& headerFile);
178

179 180
  bool ForceOld(const std::string& source) const;

181 182 183
  void GetCSharpSourceProperties(cmSourceFile const* sf,
                                 std::map<std::string, std::string>& tags);
  void WriteCSharpSourceProperties(
184
    Elem& e2, const std::map<std::string, std::string>& tags);
185
  void GetCSharpSourceLink(cmSourceFile const* sf, std::string& link);
186

187
private:
188
  friend class cmVS10GeneratorOptions;
189
  typedef cmVS10GeneratorOptions Options;
190
  typedef std::map<std::string, std::unique_ptr<Options>> OptionsMap;
191
  OptionsMap ClOptions;
192
  OptionsMap RcOptions;
193
  OptionsMap CudaOptions;
194
  OptionsMap CudaLinkOptions;
195
  OptionsMap MasmOptions;
196
  OptionsMap NasmOptions;
197
  OptionsMap LinkOptions;
198
  std::string LangForClCompile;
199 200 201 202 203 204
  enum VsProjectType
  {
    vcxproj,
    csproj
  } ProjectType;
  bool InSourceBuild;
205
  std::vector<std::string> Configurations;
206
  std::vector<TargetsFileAndConfigs> TargetsFileAndConfigsVec;
207 208 209 210 211
  cmGeneratorTarget* const GeneratorTarget;
  cmMakefile* const Makefile;
  std::string const Platform;
  std::string const Name;
  std::string const GUID;
212
  bool MSTools;
213
  bool Managed;
214
  bool NsightTegra;
215
  unsigned int NsightTegraVersion[4];
216
  bool TargetCompileAsWinRT;
217
  std::set<std::string> IPOEnabledConfigurations;
218
  std::set<std::string> SpectreMitigationConfigurations;
219
  cmGlobalVisualStudio10Generator* const GlobalGenerator;
220
  cmLocalVisualStudio10Generator* const LocalGenerator;
221
  std::set<std::string> CSharpCustomCommandNames;
222 223 224
  bool IsMissingFiles;
  std::vector<std::string> AddedFiles;
  std::string DefaultArtifactDir;
225
  bool AddedDefaultCertificate = false;
226 227 228 229 230 231 232 233 234
  // managed C++/C# relevant members
  typedef std::pair<std::string, std::string> DotNetHintReference;
  typedef std::vector<DotNetHintReference> DotNetHintReferenceList;
  typedef std::map<std::string, DotNetHintReferenceList>
    DotNetHintReferenceMap;
  DotNetHintReferenceMap DotNetHintReferences;
  typedef std::set<std::string> UsingDirectories;
  typedef std::map<std::string, UsingDirectories> UsingDirectoriesMap;
  UsingDirectoriesMap AdditionalUsingDirectories;
235

236
  typedef std::map<std::string, ToolSources> ToolSourceMap;
237
  ToolSourceMap Tools;
238
  std::string GetCMakeFilePath(const char* name) const;
239 240 241
};

#endif