cmGlobalVisualStudio10Generator.h 8.8 KB

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