1
0

cmVisualStudio10TargetGenerator.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 cmVisualStudioTargetGenerator_h
  4. #define cmVisualStudioTargetGenerator_h
  5. #include "cmConfigure.h"
  6. #include <iosfwd>
  7. #include <map>
  8. #include <set>
  9. #include <string>
  10. #include <vector>
  11. class cmComputeLinkInformation;
  12. class cmCustomCommand;
  13. class cmGeneratedFileStream;
  14. class cmGeneratorTarget;
  15. class cmGlobalVisualStudio10Generator;
  16. class cmLocalVisualStudio7Generator;
  17. class cmMakefile;
  18. class cmSourceFile;
  19. class cmSourceGroup;
  20. class cmVisualStudioGeneratorOptions;
  21. class cmVisualStudio10TargetGenerator
  22. {
  23. public:
  24. cmVisualStudio10TargetGenerator(cmGeneratorTarget* target,
  25. cmGlobalVisualStudio10Generator* gg);
  26. ~cmVisualStudio10TargetGenerator();
  27. void Generate();
  28. // used by cmVisualStudioGeneratorOptions
  29. void WritePlatformConfigTag(const char* tag, const std::string& config,
  30. int indentLevel, const char* attribute = 0,
  31. const char* end = 0, std::ostream* strm = 0);
  32. private:
  33. struct ToolSource
  34. {
  35. cmSourceFile const* SourceFile;
  36. bool RelativePath;
  37. };
  38. struct ToolSources : public std::vector<ToolSource>
  39. {
  40. };
  41. struct TargetsFileAndConfigs
  42. {
  43. std::string File;
  44. std::vector<std::string> Configs;
  45. };
  46. std::string ConvertPath(std::string const& path, bool forceRelative);
  47. static void ConvertToWindowsSlash(std::string& s);
  48. void WriteString(const char* line, int indentLevel);
  49. void WriteProjectConfigurations();
  50. void WriteProjectConfigurationValues();
  51. void WriteMSToolConfigurationValues(std::string const& config);
  52. void WriteMSToolConfigurationValuesManaged(std::string const& config);
  53. void WriteHeaderSource(cmSourceFile const* sf);
  54. void WriteExtraSource(cmSourceFile const* sf);
  55. void WriteNsightTegraConfigurationValues(std::string const& config);
  56. void WriteSource(std::string const& tool, cmSourceFile const* sf,
  57. const char* end = 0);
  58. void WriteExcludeFromBuild(std::vector<size_t> const& exclude_configs);
  59. void WriteAllSources();
  60. void WriteDotNetReferences();
  61. void WriteDotNetReference(std::string const& ref, std::string const& hint);
  62. void WriteEmbeddedResourceGroup();
  63. void WriteWinRTReferences();
  64. void WriteWinRTPackageCertificateKeyFile();
  65. void WriteXamlFilesGroup();
  66. void WritePathAndIncrementalLinkOptions();
  67. void WriteItemDefinitionGroups();
  68. void VerifyNecessaryFiles();
  69. void WriteMissingFiles();
  70. void WriteMissingFilesWP80();
  71. void WriteMissingFilesWP81();
  72. void WriteMissingFilesWS80();
  73. void WriteMissingFilesWS81();
  74. void WriteMissingFilesWS10_0();
  75. void WritePlatformExtensions();
  76. void WriteSinglePlatformExtension(std::string const& extension,
  77. std::string const& version);
  78. void WriteSDKReferences();
  79. void WriteSingleSDKReference(std::string const& extension,
  80. std::string const& version);
  81. void WriteCommonMissingFiles(const std::string& manifestFile);
  82. void WriteTargetSpecificReferences();
  83. void WriteTargetsFileReferences();
  84. bool ComputeClOptions();
  85. bool ComputeClOptions(std::string const& configName);
  86. void WriteClOptions(std::string const& config,
  87. std::vector<std::string> const& includes);
  88. bool ComputeRcOptions();
  89. bool ComputeRcOptions(std::string const& config);
  90. void WriteRCOptions(std::string const& config,
  91. std::vector<std::string> const& includes);
  92. bool ComputeCudaOptions();
  93. bool ComputeCudaOptions(std::string const& config);
  94. void WriteCudaOptions(std::string const& config,
  95. std::vector<std::string> const& includes);
  96. bool ComputeMasmOptions();
  97. bool ComputeMasmOptions(std::string const& config);
  98. void WriteMasmOptions(std::string const& config,
  99. std::vector<std::string> const& includes);
  100. bool ComputeNasmOptions();
  101. bool ComputeNasmOptions(std::string const& config);
  102. void WriteNasmOptions(std::string const& config,
  103. std::vector<std::string> includes);
  104. bool ComputeLinkOptions();
  105. bool ComputeLinkOptions(std::string const& config);
  106. bool ComputeLibOptions();
  107. bool ComputeLibOptions(std::string const& config);
  108. void WriteLinkOptions(std::string const& config);
  109. void WriteMidlOptions(std::string const& config,
  110. std::vector<std::string> const& includes);
  111. void WriteAntBuildOptions(std::string const& config);
  112. void OutputLinkIncremental(std::string const& configName);
  113. void WriteCustomRule(cmSourceFile const* source,
  114. cmCustomCommand const& command);
  115. void WriteCustomCommands();
  116. void WriteCustomCommand(cmSourceFile const* sf);
  117. void WriteGroups();
  118. void WriteProjectReferences();
  119. void WriteApplicationTypeSettings();
  120. bool OutputSourceSpecificFlags(cmSourceFile const* source);
  121. void AddLibraries(cmComputeLinkInformation& cli,
  122. std::vector<std::string>& libVec,
  123. std::vector<std::string>& vsTargetVec);
  124. void AddTargetsFileAndConfigPair(std::string const& targetsFile,
  125. std::string const& config);
  126. void WriteLibOptions(std::string const& config);
  127. void WriteManifestOptions(std::string const& config);
  128. void WriteEvents(std::string const& configName);
  129. void WriteEvent(const char* name,
  130. std::vector<cmCustomCommand> const& commands,
  131. std::string const& configName);
  132. void WriteGroupSources(const char* name, ToolSources const& sources,
  133. std::vector<cmSourceGroup>&);
  134. void AddMissingSourceGroups(std::set<cmSourceGroup*>& groupsUsed,
  135. const std::vector<cmSourceGroup>& allGroups);
  136. bool IsResxHeader(const std::string& headerFile);
  137. bool IsXamlHeader(const std::string& headerFile);
  138. bool IsXamlSource(const std::string& headerFile);
  139. bool ForceOld(const std::string& source) const;
  140. private:
  141. typedef cmVisualStudioGeneratorOptions Options;
  142. typedef std::map<std::string, Options*> OptionsMap;
  143. OptionsMap ClOptions;
  144. OptionsMap RcOptions;
  145. OptionsMap CudaOptions;
  146. OptionsMap MasmOptions;
  147. OptionsMap NasmOptions;
  148. OptionsMap LinkOptions;
  149. std::string PathToProjectFile;
  150. std::string ProjectFileExtension;
  151. enum VsProjectType
  152. {
  153. vcxproj,
  154. csproj
  155. } ProjectType;
  156. bool InSourceBuild;
  157. std::vector<std::string> Configurations;
  158. std::vector<TargetsFileAndConfigs> TargetsFileAndConfigsVec;
  159. cmGeneratorTarget* GeneratorTarget;
  160. cmMakefile* Makefile;
  161. std::string Platform;
  162. std::string GUID;
  163. std::string Name;
  164. bool MSTools;
  165. bool Managed;
  166. bool NsightTegra;
  167. int NsightTegraVersion[4];
  168. bool TargetCompileAsWinRT;
  169. cmGlobalVisualStudio10Generator* GlobalGenerator;
  170. cmGeneratedFileStream* BuildFileStream;
  171. cmLocalVisualStudio7Generator* LocalGenerator;
  172. std::set<cmSourceFile const*> SourcesVisited;
  173. bool IsMissingFiles;
  174. std::vector<std::string> AddedFiles;
  175. std::string DefaultArtifactDir;
  176. typedef std::map<std::string, ToolSources> ToolSourceMap;
  177. ToolSourceMap Tools;
  178. std::string GetCMakeFilePath(const char* name) const;
  179. };
  180. #endif