cmGlobalVisualStudio10Generator.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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, bool verbose,
  28. std::vector<std::string> const& makeOptions =
  29. std::vector<std::string>()) override;
  30. ///! create the correct local generator
  31. cmLocalGenerator* CreateLocalGenerator(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 WriteSLNHeader(std::ostream& fout) override;
  39. bool IsCudaEnabled() const { return this->CudaEnabled; }
  40. /** Generating for Nsight Tegra VS plugin? */
  41. bool IsNsightTegra() const;
  42. std::string GetNsightTegraVersion() const;
  43. /** The toolset name for the target platform. */
  44. const char* GetPlatformToolset() const;
  45. std::string const& GetPlatformToolsetString() const;
  46. /** The toolset host architecture name (e.g. x64 for 64-bit host tools). */
  47. const char* GetPlatformToolsetHostArchitecture() const;
  48. /** The cuda toolset version. */
  49. const char* GetPlatformToolsetCuda() const;
  50. std::string const& GetPlatformToolsetCudaString() const;
  51. /** Return whether we need to use No/Debug instead of false/true
  52. for GenerateDebugInformation. */
  53. bool GetPlatformToolsetNeedsDebugEnum() const
  54. {
  55. return this->PlatformToolsetNeedsDebugEnum;
  56. }
  57. /** Return the CMAKE_SYSTEM_NAME. */
  58. std::string const& GetSystemName() const { return this->SystemName; }
  59. /** Return the CMAKE_SYSTEM_VERSION. */
  60. std::string const& GetSystemVersion() const { return this->SystemVersion; }
  61. /** Return the Windows version targeted on VS 2015 and above. */
  62. std::string const& GetWindowsTargetPlatformVersion() const
  63. {
  64. return this->WindowsTargetPlatformVersion;
  65. }
  66. /** Return true if building for WindowsCE */
  67. bool TargetsWindowsCE() const { return this->SystemIsWindowsCE; }
  68. /** Return true if building for WindowsPhone */
  69. bool TargetsWindowsPhone() const { return this->SystemIsWindowsPhone; }
  70. /** Return true if building for WindowsStore */
  71. bool TargetsWindowsStore() const { return this->SystemIsWindowsStore; }
  72. const char* GetCMakeCFGIntDir() const override { return "$(Configuration)"; }
  73. bool Find64BitTools(cmMakefile* mf);
  74. /** Generate an <output>.rule file path for a given command output. */
  75. std::string GenerateRuleFile(std::string const& output) const override;
  76. void PathTooLong(cmGeneratorTarget* target, cmSourceFile const* sf,
  77. std::string const& sfRel);
  78. std::string Encoding() override;
  79. virtual const char* GetToolsVersion() { return "4.0"; }
  80. bool FindMakeProgram(cmMakefile* mf) override;
  81. static std::string GetInstalledNsightTegraVersion();
  82. cmIDEFlagTable const* GetClFlagTable() const;
  83. cmIDEFlagTable const* GetCSharpFlagTable() const;
  84. cmIDEFlagTable const* GetRcFlagTable() const;
  85. cmIDEFlagTable const* GetLibFlagTable() const;
  86. cmIDEFlagTable const* GetLinkFlagTable() const;
  87. cmIDEFlagTable const* GetCudaFlagTable() const;
  88. cmIDEFlagTable const* GetCudaHostFlagTable() const;
  89. cmIDEFlagTable const* GetMasmFlagTable() const;
  90. cmIDEFlagTable const* GetNasmFlagTable() const;
  91. protected:
  92. void Generate() override;
  93. virtual bool InitializeSystem(cmMakefile* mf);
  94. virtual bool InitializeWindows(cmMakefile* mf);
  95. virtual bool InitializeWindowsCE(cmMakefile* mf);
  96. virtual bool InitializeWindowsPhone(cmMakefile* mf);
  97. virtual bool InitializeWindowsStore(cmMakefile* mf);
  98. virtual bool ProcessGeneratorToolsetField(std::string const& key,
  99. std::string const& value);
  100. virtual std::string SelectWindowsCEToolset() const;
  101. virtual bool SelectWindowsPhoneToolset(std::string& toolset) const;
  102. virtual bool SelectWindowsStoreToolset(std::string& toolset) const;
  103. const char* GetIDEVersion() override { return "10.0"; }
  104. std::string const& GetMSBuildCommand();
  105. std::string GeneratorToolset;
  106. std::string GeneratorToolsetHostArchitecture;
  107. std::string GeneratorToolsetCuda;
  108. std::string DefaultPlatformToolset;
  109. std::string WindowsTargetPlatformVersion;
  110. std::string SystemName;
  111. std::string SystemVersion;
  112. std::string NsightTegraVersion;
  113. cmIDEFlagTable const* DefaultClFlagTable;
  114. cmIDEFlagTable const* DefaultCSharpFlagTable;
  115. cmIDEFlagTable const* DefaultLibFlagTable;
  116. cmIDEFlagTable const* DefaultLinkFlagTable;
  117. cmIDEFlagTable const* DefaultCudaFlagTable;
  118. cmIDEFlagTable const* DefaultCudaHostFlagTable;
  119. cmIDEFlagTable const* DefaultMasmFlagTable;
  120. cmIDEFlagTable const* DefaultNasmFlagTable;
  121. cmIDEFlagTable const* DefaultRcFlagTable;
  122. bool SystemIsWindowsCE;
  123. bool SystemIsWindowsPhone;
  124. bool SystemIsWindowsStore;
  125. private:
  126. class Factory;
  127. struct LongestSourcePath
  128. {
  129. LongestSourcePath()
  130. : Length(0)
  131. , Target(0)
  132. , SourceFile(0)
  133. {
  134. }
  135. size_t Length;
  136. cmGeneratorTarget* Target;
  137. cmSourceFile const* SourceFile;
  138. std::string SourceRel;
  139. };
  140. LongestSourcePath LongestSource;
  141. std::string MSBuildCommand;
  142. bool MSBuildCommandInitialized;
  143. cmVisualStudio10ToolsetOptions ToolsetOptions;
  144. virtual std::string FindMSBuildCommand();
  145. std::string FindDevEnvCommand() override;
  146. std::string GetVSMakeProgram() override { return this->GetMSBuildCommand(); }
  147. bool PlatformToolsetNeedsDebugEnum;
  148. bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf);
  149. std::string VCTargetsPath;
  150. bool FindVCTargetsPath(cmMakefile* mf);
  151. bool CudaEnabled;
  152. // We do not use the reload macros for VS >= 10.
  153. std::string GetUserMacrosDirectory() override { return ""; }
  154. };
  155. #endif