CMake Nightly Date Stamp
[kiteware-cmake.git] / Source / cmGlobalVisualStudio10Generator.h
bloba2b351cbe67d1e97de28362de840cf891d15d904
1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #pragma once
5 #include <cstddef>
6 #include <memory>
7 #include <set>
8 #include <string>
9 #include <vector>
11 #include <cm/optional>
12 #include <cm/string_view>
14 #include "cmGlobalVisualStudio8Generator.h"
16 class cmGeneratorTarget;
17 class cmLocalGenerator;
18 class cmMakefile;
19 class cmSourceFile;
20 class cmake;
21 struct cmIDEFlagTable;
23 /** \class cmGlobalVisualStudio10Generator
24 * \brief Write a Unix makefiles.
26 * cmGlobalVisualStudio10Generator manages UNIX build process for a tree
28 class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator
30 public:
31 bool IsVisualStudioAtLeast10() const override { return true; }
33 bool SetSystemName(std::string const& s, cmMakefile* mf) override;
34 bool SetGeneratorToolset(std::string const& ts, bool build,
35 cmMakefile* mf) override;
37 std::vector<GeneratedMakeCommand> GenerateBuildCommand(
38 const std::string& makeProgram, const std::string& projectName,
39 const std::string& projectDir, std::vector<std::string> const& targetNames,
40 const std::string& config, int jobs, bool verbose,
41 const cmBuildOptions& buildOptions = cmBuildOptions(),
42 std::vector<std::string> const& makeOptions =
43 std::vector<std::string>()) override;
45 //! create the correct local generator
46 std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
47 cmMakefile* mf) override;
49 /**
50 * Try to determine system information such as shared library
51 * extension, pthreads, byte order etc.
53 void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
54 bool optional) override;
56 void AddAndroidExecutableWarning(const std::string& name)
58 this->AndroidExecutableWarnings.insert(name);
61 bool IsCudaEnabled() const { return this->CudaEnabled; }
63 /** Generating for Nsight Tegra VS plugin? */
64 bool IsNsightTegra() const;
65 std::string GetNsightTegraVersion() const;
67 /** The vctargets path for the target platform. */
68 const char* GetCustomVCTargetsPath() const;
70 /** The toolset name for the target platform. */
71 const char* GetPlatformToolset() const;
72 std::string const& GetPlatformToolsetString() const;
74 /** The toolset version props file, if any. */
75 std::string const& GetPlatformToolsetVersionProps() const;
77 /** The toolset host architecture name (e.g. x64 for 64-bit host tools). */
78 const char* GetPlatformToolsetHostArchitecture() const;
79 std::string const& GetPlatformToolsetHostArchitectureString() const;
81 /** The cuda toolset version. */
82 const char* GetPlatformToolsetCuda() const;
83 std::string const& GetPlatformToolsetCudaString() const;
85 /** The custom cuda install directory */
86 const char* GetPlatformToolsetCudaCustomDir() const;
87 std::string const& GetPlatformToolsetCudaCustomDirString() const;
89 /** The nvcc subdirectory of a custom cuda install directory */
90 std::string const& GetPlatformToolsetCudaNvccSubdirString() const;
92 /** The visual studio integration subdirectory of a custom cuda install
93 * directory */
94 std::string const& GetPlatformToolsetCudaVSIntegrationSubdirString() const;
96 /** The fortran toolset name. */
97 cm::optional<std::string> GetPlatformToolsetFortran() const override
99 return this->GeneratorToolsetFortran;
102 /** Return whether we need to use No/Debug instead of false/true
103 for GenerateDebugInformation. */
104 bool GetPlatformToolsetNeedsDebugEnum() const
106 return this->PlatformToolsetNeedsDebugEnum;
109 /** Return the CMAKE_SYSTEM_NAME. */
110 std::string const& GetSystemName() const { return this->SystemName; }
112 /** Return the CMAKE_SYSTEM_VERSION. */
113 std::string const& GetSystemVersion() const { return this->SystemVersion; }
115 /** Return the Windows version targeted on VS 2015 and above. */
116 std::string const& GetWindowsTargetPlatformVersion() const
118 return this->WindowsTargetPlatformVersion;
121 /** Return true if building for WindowsCE */
122 bool TargetsWindowsCE() const override { return this->SystemIsWindowsCE; }
124 /** Return true if building for WindowsPhone */
125 bool TargetsWindowsPhone() const { return this->SystemIsWindowsPhone; }
127 /** Return true if building for WindowsStore */
128 bool TargetsWindowsStore() const { return this->SystemIsWindowsStore; }
130 /** Return true if building for Android */
131 bool TargetsAndroid() const { return this->SystemIsAndroid; }
133 const char* GetCMakeCFGIntDir() const override { return "$(Configuration)"; }
135 /** Generate an <output>.rule file path for a given command output. */
136 std::string GenerateRuleFile(std::string const& output) const override;
138 void PathTooLong(cmGeneratorTarget* target, cmSourceFile const* sf,
139 std::string const& sfRel);
141 std::string Encoding() override;
142 const char* GetToolsVersion() const;
144 virtual cm::optional<std::string> GetVSInstanceVersion() const { return {}; }
146 bool GetSupportsUnityBuilds() const { return this->SupportsUnityBuilds; }
148 virtual cm::optional<std::string> FindMSBuildCommandEarly(cmMakefile* mf);
150 bool FindMakeProgram(cmMakefile* mf) override;
152 bool IsIPOSupported() const override { return true; }
154 virtual bool IsStdOutEncodingSupported() const { return false; }
156 virtual bool IsUtf8EncodingSupported() const { return false; }
158 virtual bool IsScanDependenciesSupported() const { return false; }
160 static std::string GetInstalledNsightTegraVersion();
162 /** Return the first two components of CMAKE_SYSTEM_VERSION. */
163 std::string GetApplicationTypeRevision() const;
165 virtual const char* GetAndroidApplicationTypeRevision() const { return ""; }
167 cmIDEFlagTable const* GetClFlagTable() const;
168 cmIDEFlagTable const* GetCSharpFlagTable() const;
169 cmIDEFlagTable const* GetRcFlagTable() const;
170 cmIDEFlagTable const* GetLibFlagTable() const;
171 cmIDEFlagTable const* GetLinkFlagTable() const;
172 cmIDEFlagTable const* GetCudaFlagTable() const;
173 cmIDEFlagTable const* GetCudaHostFlagTable() const;
174 cmIDEFlagTable const* GetMarmasmFlagTable() const;
175 cmIDEFlagTable const* GetMasmFlagTable() const;
176 cmIDEFlagTable const* GetNasmFlagTable() const;
178 bool IsMsBuildRestoreSupported() const;
179 bool IsBuildInParallelSupported() const;
181 protected:
182 cmGlobalVisualStudio10Generator(cmake* cm, const std::string& name,
183 std::string const& platformInGeneratorName);
185 void Generate() override;
186 virtual bool InitializeSystem(cmMakefile* mf);
187 virtual bool InitializeWindows(cmMakefile* mf);
188 virtual bool InitializeWindowsCE(cmMakefile* mf);
189 virtual bool InitializeWindowsPhone(cmMakefile* mf);
190 virtual bool InitializeWindowsStore(cmMakefile* mf);
191 virtual bool InitializeTegraAndroid(cmMakefile* mf);
192 virtual bool InitializeAndroid(cmMakefile* mf);
194 bool InitializePlatform(cmMakefile* mf) override;
195 virtual bool InitializePlatformWindows(cmMakefile* mf);
196 virtual bool VerifyNoGeneratorPlatformVersion(cmMakefile* mf) const;
198 virtual bool ProcessGeneratorToolsetField(std::string const& key,
199 std::string const& value);
201 virtual std::string SelectWindowsCEToolset() const;
202 virtual bool SelectWindowsPhoneToolset(std::string& toolset) const;
203 virtual bool SelectWindowsStoreToolset(std::string& toolset) const;
205 enum class AuxToolset
207 None,
208 Default,
209 PropsExist,
210 PropsMissing,
211 PropsIndeterminate
213 virtual AuxToolset FindAuxToolset(std::string& version,
214 std::string& props) const;
216 std::string const& GetMSBuildCommand();
218 cmIDEFlagTable const* LoadFlagTable(std::string const& toolSpecificName,
219 std::string const& defaultName,
220 std::string const& table) const;
222 std::string GeneratorToolset;
223 std::string GeneratorToolsetVersionProps;
224 std::string GeneratorToolsetHostArchitecture;
225 std::string GeneratorToolsetCustomVCTargetsDir;
226 std::string GeneratorToolsetCuda;
227 std::string GeneratorToolsetCudaCustomDir;
228 std::string GeneratorToolsetCudaNvccSubdir;
229 std::string GeneratorToolsetCudaVSIntegrationSubdir;
230 cm::optional<std::string> GeneratorToolsetFortran;
231 std::string DefaultPlatformToolset;
232 std::string DefaultPlatformToolsetHostArchitecture;
233 std::string DefaultAndroidToolset;
234 std::string WindowsTargetPlatformVersion;
235 std::string SystemName;
236 std::string SystemVersion;
237 std::string NsightTegraVersion;
238 std::string DefaultCLFlagTableName;
239 std::string DefaultCSharpFlagTableName;
240 std::string DefaultLibFlagTableName;
241 std::string DefaultLinkFlagTableName;
242 std::string DefaultCudaFlagTableName;
243 std::string DefaultCudaHostFlagTableName;
244 std::string DefaultMarmasmFlagTableName;
245 std::string DefaultMasmFlagTableName;
246 std::string DefaultNasmFlagTableName;
247 std::string DefaultRCFlagTableName;
248 bool SupportsUnityBuilds = false;
249 bool SystemIsWindowsCE = false;
250 bool SystemIsWindowsPhone = false;
251 bool SystemIsWindowsStore = false;
252 bool SystemIsAndroid = false;
253 bool MSBuildCommandInitialized = false;
255 private:
256 struct LongestSourcePath
258 LongestSourcePath() = default;
259 size_t Length = 0;
260 cmGeneratorTarget* Target = nullptr;
261 cmSourceFile const* SourceFile = nullptr;
262 std::string SourceRel;
264 LongestSourcePath LongestSource;
266 std::string MSBuildCommand;
267 std::set<std::string> AndroidExecutableWarnings;
268 virtual std::string FindMSBuildCommand();
269 std::string FindDevEnvCommand() override;
270 std::string GetVSMakeProgram() override { return this->GetMSBuildCommand(); }
272 std::string GeneratorToolsetVersion;
274 bool PlatformToolsetNeedsDebugEnum = false;
276 bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf);
278 std::string GetClFlagTableName() const;
279 std::string GetCSharpFlagTableName() const;
280 std::string GetRcFlagTableName() const;
281 std::string GetLibFlagTableName() const;
282 std::string GetLinkFlagTableName() const;
283 std::string GetMasmFlagTableName() const;
284 std::string CanonicalToolsetName(std::string const& toolset) const;
286 cm::optional<std::string> FindFlagTable(cm::string_view toolsetName,
287 cm::string_view table) const;
289 std::string CustomFlagTableDir;
291 std::string CustomVCTargetsPath;
292 std::string VCTargetsPath;
293 bool FindVCTargetsPath(cmMakefile* mf);
295 bool CudaEnabled = false;
297 // We do not use the reload macros for VS >= 10.
298 std::string GetUserMacrosDirectory() override { return ""; }