cmGlobalVisualStudio10Generator.h 8.1 KB

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