cmGlobalVisualStudio10Generator.h 7.4 KB

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