cmGlobalVisualStudio10Generator.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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 cmGlobalVisualStudio10Generator_h
  4. #define cmGlobalVisualStudio10Generator_h
  5. #include <memory>
  6. #include <set>
  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. */
  52. const char* GetPlatformToolsetVersion() const;
  53. std::string const& GetPlatformToolsetVersionString() const;
  54. /** The toolset host architecture name (e.g. x64 for 64-bit host tools). */
  55. const char* GetPlatformToolsetHostArchitecture() const;
  56. std::string const& GetPlatformToolsetHostArchitectureString() const;
  57. /** The cuda toolset version. */
  58. const char* GetPlatformToolsetCuda() const;
  59. std::string const& GetPlatformToolsetCudaString() const;
  60. /** The custom cuda install directory */
  61. const char* GetPlatformToolsetCudaCustomDir() const;
  62. std::string const& GetPlatformToolsetCudaCustomDirString() const;
  63. /** Return whether we need to use No/Debug instead of false/true
  64. for GenerateDebugInformation. */
  65. bool GetPlatformToolsetNeedsDebugEnum() const
  66. {
  67. return this->PlatformToolsetNeedsDebugEnum;
  68. }
  69. /** Return the CMAKE_SYSTEM_NAME. */
  70. std::string const& GetSystemName() const { return this->SystemName; }
  71. /** Return the CMAKE_SYSTEM_VERSION. */
  72. std::string const& GetSystemVersion() const { return this->SystemVersion; }
  73. /** Return the Windows version targeted on VS 2015 and above. */
  74. std::string const& GetWindowsTargetPlatformVersion() const
  75. {
  76. return this->WindowsTargetPlatformVersion;
  77. }
  78. /** Return true if building for WindowsCE */
  79. bool TargetsWindowsCE() const override { return this->SystemIsWindowsCE; }
  80. /** Return true if building for WindowsPhone */
  81. bool TargetsWindowsPhone() const { return this->SystemIsWindowsPhone; }
  82. /** Return true if building for WindowsStore */
  83. bool TargetsWindowsStore() const { return this->SystemIsWindowsStore; }
  84. /** Return true if building for Android */
  85. bool TargetsAndroid() const { return this->SystemIsAndroid; }
  86. const char* GetCMakeCFGIntDir() const override { return "$(Configuration)"; }
  87. bool Find64BitTools(cmMakefile* mf);
  88. /** Generate an <output>.rule file path for a given command output. */
  89. std::string GenerateRuleFile(std::string const& output) const override;
  90. void PathTooLong(cmGeneratorTarget* target, cmSourceFile const* sf,
  91. std::string const& sfRel);
  92. std::string Encoding() override;
  93. const char* GetToolsVersion() const;
  94. virtual bool IsDefaultToolset(const std::string& version) const;
  95. virtual std::string GetAuxiliaryToolset() const;
  96. bool GetSupportsUnityBuilds() const { return this->SupportsUnityBuilds; }
  97. bool FindMakeProgram(cmMakefile* mf) override;
  98. bool IsIPOSupported() const override { return true; }
  99. virtual bool IsStdOutEncodingSupported() const { return false; }
  100. static std::string GetInstalledNsightTegraVersion();
  101. /** Return the first two components of CMAKE_SYSTEM_VERSION. */
  102. std::string GetApplicationTypeRevision() const;
  103. virtual const char* GetAndroidApplicationTypeRevision() const { return ""; }
  104. cmIDEFlagTable const* GetClFlagTable() const;
  105. cmIDEFlagTable const* GetCSharpFlagTable() const;
  106. cmIDEFlagTable const* GetRcFlagTable() const;
  107. cmIDEFlagTable const* GetLibFlagTable() const;
  108. cmIDEFlagTable const* GetLinkFlagTable() const;
  109. cmIDEFlagTable const* GetCudaFlagTable() const;
  110. cmIDEFlagTable const* GetCudaHostFlagTable() const;
  111. cmIDEFlagTable const* GetMasmFlagTable() const;
  112. cmIDEFlagTable const* GetNasmFlagTable() const;
  113. protected:
  114. cmGlobalVisualStudio10Generator(cmake* cm, const std::string& name,
  115. std::string const& platformInGeneratorName);
  116. void Generate() override;
  117. virtual bool InitializeSystem(cmMakefile* mf);
  118. virtual bool InitializeWindows(cmMakefile* mf);
  119. virtual bool InitializeWindowsCE(cmMakefile* mf);
  120. virtual bool InitializeWindowsPhone(cmMakefile* mf);
  121. virtual bool InitializeWindowsStore(cmMakefile* mf);
  122. virtual bool InitializeTegraAndroid(cmMakefile* mf);
  123. virtual bool InitializeAndroid(cmMakefile* mf);
  124. virtual bool ProcessGeneratorToolsetField(std::string const& key,
  125. std::string const& value);
  126. virtual std::string SelectWindowsCEToolset() const;
  127. virtual bool SelectWindowsPhoneToolset(std::string& toolset) const;
  128. virtual bool SelectWindowsStoreToolset(std::string& toolset) const;
  129. std::string const& GetMSBuildCommand();
  130. cmIDEFlagTable const* LoadFlagTable(std::string const& optionsName,
  131. std::string const& toolsetName,
  132. std::string const& defaultName,
  133. std::string const& table) const;
  134. std::string GeneratorToolset;
  135. std::string GeneratorToolsetVersion;
  136. std::string GeneratorToolsetHostArchitecture;
  137. std::string GeneratorToolsetCustomVCTargetsDir;
  138. std::string GeneratorToolsetCuda;
  139. std::string GeneratorToolsetCudaCustomDir;
  140. std::string DefaultPlatformToolset;
  141. std::string DefaultPlatformToolsetHostArchitecture;
  142. std::string DefaultAndroidToolset;
  143. std::string WindowsTargetPlatformVersion;
  144. std::string SystemName;
  145. std::string SystemVersion;
  146. std::string NsightTegraVersion;
  147. std::string DefaultCLFlagTableName;
  148. std::string DefaultCSharpFlagTableName;
  149. std::string DefaultLibFlagTableName;
  150. std::string DefaultLinkFlagTableName;
  151. std::string DefaultCudaFlagTableName;
  152. std::string DefaultCudaHostFlagTableName;
  153. std::string DefaultMasmFlagTableName;
  154. std::string DefaultNasmFlagTableName;
  155. std::string DefaultRCFlagTableName;
  156. bool SupportsUnityBuilds = false;
  157. bool SystemIsWindowsCE = false;
  158. bool SystemIsWindowsPhone = false;
  159. bool SystemIsWindowsStore = false;
  160. bool SystemIsAndroid = false;
  161. private:
  162. class Factory;
  163. friend class Factory;
  164. struct LongestSourcePath
  165. {
  166. LongestSourcePath()
  167. : Length(0)
  168. , Target(0)
  169. , SourceFile(0)
  170. {
  171. }
  172. size_t Length;
  173. cmGeneratorTarget* Target;
  174. cmSourceFile const* SourceFile;
  175. std::string SourceRel;
  176. };
  177. LongestSourcePath LongestSource;
  178. std::string MSBuildCommand;
  179. bool MSBuildCommandInitialized;
  180. cmVisualStudio10ToolsetOptions ToolsetOptions;
  181. std::set<std::string> AndroidExecutableWarnings;
  182. virtual std::string FindMSBuildCommand();
  183. std::string FindDevEnvCommand() override;
  184. std::string GetVSMakeProgram() override { return this->GetMSBuildCommand(); }
  185. bool PlatformToolsetNeedsDebugEnum;
  186. bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf);
  187. std::string CustomVCTargetsPath;
  188. std::string VCTargetsPath;
  189. bool FindVCTargetsPath(cmMakefile* mf);
  190. bool CudaEnabled;
  191. // We do not use the reload macros for VS >= 10.
  192. std::string GetUserMacrosDirectory() override { return ""; }
  193. };
  194. #endif