cmGlobalVisualStudio10Generator.h 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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. #include <memory>
  5. #include <set>
  6. #include "cmGlobalVisualStudio8Generator.h"
  7. /** \class cmGlobalVisualStudio10Generator
  8. * \brief Write a Unix makefiles.
  9. *
  10. * cmGlobalVisualStudio10Generator manages UNIX build process for a tree
  11. */
  12. class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator
  13. {
  14. public:
  15. static std::unique_ptr<cmGlobalGeneratorFactory> NewFactory();
  16. bool MatchesGeneratorName(const std::string& name) const override;
  17. bool SetSystemName(std::string const& s, cmMakefile* mf) override;
  18. bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
  19. bool SetGeneratorToolset(std::string const& ts, bool build,
  20. cmMakefile* mf) override;
  21. std::vector<GeneratedMakeCommand> GenerateBuildCommand(
  22. const std::string& makeProgram, const std::string& projectName,
  23. const std::string& projectDir, std::vector<std::string> const& targetNames,
  24. const std::string& config, bool fast, int jobs, bool verbose,
  25. std::vector<std::string> const& makeOptions =
  26. std::vector<std::string>()) override;
  27. //! create the correct local generator
  28. std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
  29. cmMakefile* mf) override;
  30. /**
  31. * Try to determine system information such as shared library
  32. * extension, pthreads, byte order etc.
  33. */
  34. void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
  35. bool optional) override;
  36. void AddAndroidExecutableWarning(const std::string& name)
  37. {
  38. this->AndroidExecutableWarnings.insert(name);
  39. }
  40. bool IsCudaEnabled() const { return this->CudaEnabled; }
  41. /** Generating for Nsight Tegra VS plugin? */
  42. bool IsNsightTegra() const;
  43. std::string GetNsightTegraVersion() const;
  44. /** The vctargets path for the target platform. */
  45. const char* GetCustomVCTargetsPath() const;
  46. /** The toolset name for the target platform. */
  47. const char* GetPlatformToolset() const;
  48. std::string const& GetPlatformToolsetString() const;
  49. /** The toolset version. */
  50. const char* GetPlatformToolsetVersion() const;
  51. std::string const& GetPlatformToolsetVersionString() const;
  52. /** The toolset host architecture name (e.g. x64 for 64-bit host tools). */
  53. const char* GetPlatformToolsetHostArchitecture() const;
  54. std::string const& GetPlatformToolsetHostArchitectureString() const;
  55. /** The cuda toolset version. */
  56. const char* GetPlatformToolsetCuda() const;
  57. std::string const& GetPlatformToolsetCudaString() const;
  58. /** The custom cuda install directory */
  59. const char* GetPlatformToolsetCudaCustomDir() const;
  60. std::string const& GetPlatformToolsetCudaCustomDirString() const;
  61. /** Return whether we need to use No/Debug instead of false/true
  62. for GenerateDebugInformation. */
  63. bool GetPlatformToolsetNeedsDebugEnum() const
  64. {
  65. return this->PlatformToolsetNeedsDebugEnum;
  66. }
  67. /** Return the CMAKE_SYSTEM_NAME. */
  68. std::string const& GetSystemName() const { return this->SystemName; }
  69. /** Return the CMAKE_SYSTEM_VERSION. */
  70. std::string const& GetSystemVersion() const { return this->SystemVersion; }
  71. /** Return the Windows version targeted on VS 2015 and above. */
  72. std::string const& GetWindowsTargetPlatformVersion() const
  73. {
  74. return this->WindowsTargetPlatformVersion;
  75. }
  76. /** Return true if building for WindowsCE */
  77. bool TargetsWindowsCE() const override { return this->SystemIsWindowsCE; }
  78. /** Return true if building for WindowsPhone */
  79. bool TargetsWindowsPhone() const { return this->SystemIsWindowsPhone; }
  80. /** Return true if building for WindowsStore */
  81. bool TargetsWindowsStore() const { return this->SystemIsWindowsStore; }
  82. /** Return true if building for Android */
  83. bool TargetsAndroid() const { return this->SystemIsAndroid; }
  84. const char* GetCMakeCFGIntDir() const override { return "$(Configuration)"; }
  85. bool Find64BitTools(cmMakefile* mf);
  86. /** Generate an <output>.rule file path for a given command output. */
  87. std::string GenerateRuleFile(std::string const& output) const override;
  88. void PathTooLong(cmGeneratorTarget* target, cmSourceFile const* sf,
  89. std::string const& sfRel);
  90. std::string Encoding() override;
  91. const char* GetToolsVersion() const;
  92. virtual bool IsDefaultToolset(const std::string& version) const;
  93. virtual std::string GetAuxiliaryToolset() const;
  94. bool GetSupportsUnityBuilds() const { return this->SupportsUnityBuilds; }
  95. bool FindMakeProgram(cmMakefile* mf) override;
  96. bool IsIPOSupported() const override { return true; }
  97. virtual bool IsStdOutEncodingSupported() const { return false; }
  98. static std::string GetInstalledNsightTegraVersion();
  99. /** Return the first two components of CMAKE_SYSTEM_VERSION. */
  100. std::string GetApplicationTypeRevision() const;
  101. virtual const char* GetAndroidApplicationTypeRevision() const { return ""; }
  102. cmIDEFlagTable const* GetClFlagTable() const;
  103. cmIDEFlagTable const* GetCSharpFlagTable() const;
  104. cmIDEFlagTable const* GetRcFlagTable() const;
  105. cmIDEFlagTable const* GetLibFlagTable() const;
  106. cmIDEFlagTable const* GetLinkFlagTable() const;
  107. cmIDEFlagTable const* GetCudaFlagTable() const;
  108. cmIDEFlagTable const* GetCudaHostFlagTable() const;
  109. cmIDEFlagTable const* GetMasmFlagTable() const;
  110. cmIDEFlagTable const* GetNasmFlagTable() const;
  111. protected:
  112. cmGlobalVisualStudio10Generator(cmake* cm, const std::string& name,
  113. std::string const& platformInGeneratorName);
  114. void Generate() override;
  115. virtual bool InitializeSystem(cmMakefile* mf);
  116. virtual bool InitializeWindows(cmMakefile* mf);
  117. virtual bool InitializeWindowsCE(cmMakefile* mf);
  118. virtual bool InitializeWindowsPhone(cmMakefile* mf);
  119. virtual bool InitializeWindowsStore(cmMakefile* mf);
  120. virtual bool InitializeTegraAndroid(cmMakefile* mf);
  121. virtual bool InitializeAndroid(cmMakefile* mf);
  122. virtual bool ProcessGeneratorToolsetField(std::string const& key,
  123. std::string const& value);
  124. virtual std::string SelectWindowsCEToolset() const;
  125. virtual bool SelectWindowsPhoneToolset(std::string& toolset) const;
  126. virtual bool SelectWindowsStoreToolset(std::string& toolset) const;
  127. std::string const& GetMSBuildCommand();
  128. cmIDEFlagTable const* LoadFlagTable(std::string const& optionsName,
  129. std::string const& toolsetName,
  130. std::string const& defaultName,
  131. std::string const& table) const;
  132. std::string GeneratorToolset;
  133. std::string GeneratorToolsetVersion;
  134. std::string GeneratorToolsetHostArchitecture;
  135. std::string GeneratorToolsetCustomVCTargetsDir;
  136. std::string GeneratorToolsetCuda;
  137. std::string GeneratorToolsetCudaCustomDir;
  138. std::string DefaultPlatformToolset;
  139. std::string DefaultPlatformToolsetHostArchitecture;
  140. std::string DefaultAndroidToolset;
  141. std::string WindowsTargetPlatformVersion;
  142. std::string SystemName;
  143. std::string SystemVersion;
  144. std::string NsightTegraVersion;
  145. std::string DefaultCLFlagTableName;
  146. std::string DefaultCSharpFlagTableName;
  147. std::string DefaultLibFlagTableName;
  148. std::string DefaultLinkFlagTableName;
  149. std::string DefaultCudaFlagTableName;
  150. std::string DefaultCudaHostFlagTableName;
  151. std::string DefaultMasmFlagTableName;
  152. std::string DefaultNasmFlagTableName;
  153. std::string DefaultRCFlagTableName;
  154. bool SupportsUnityBuilds = false;
  155. bool SystemIsWindowsCE = false;
  156. bool SystemIsWindowsPhone = false;
  157. bool SystemIsWindowsStore = false;
  158. bool SystemIsAndroid = false;
  159. private:
  160. class Factory;
  161. friend class Factory;
  162. struct LongestSourcePath
  163. {
  164. LongestSourcePath()
  165. : Length(0)
  166. , Target(0)
  167. , SourceFile(0)
  168. {
  169. }
  170. size_t Length;
  171. cmGeneratorTarget* Target;
  172. cmSourceFile const* SourceFile;
  173. std::string SourceRel;
  174. };
  175. LongestSourcePath LongestSource;
  176. std::string MSBuildCommand;
  177. bool MSBuildCommandInitialized;
  178. std::set<std::string> AndroidExecutableWarnings;
  179. virtual std::string FindMSBuildCommand();
  180. std::string FindDevEnvCommand() override;
  181. std::string GetVSMakeProgram() override { return this->GetMSBuildCommand(); }
  182. bool PlatformToolsetNeedsDebugEnum;
  183. bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf);
  184. std::string GetClFlagTableName() const;
  185. std::string GetCSharpFlagTableName() const;
  186. std::string GetRcFlagTableName() const;
  187. std::string GetLibFlagTableName() const;
  188. std::string GetLinkFlagTableName() const;
  189. std::string GetMasmFlagTableName() const;
  190. std::string CanonicalToolsetName(std::string const& toolset) const;
  191. std::string CustomVCTargetsPath;
  192. std::string VCTargetsPath;
  193. bool FindVCTargetsPath(cmMakefile* mf);
  194. bool CudaEnabled;
  195. // We do not use the reload macros for VS >= 10.
  196. std::string GetUserMacrosDirectory() override { return ""; }
  197. };