cmGlobalVisualStudio10Generator.h 7.5 KB

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