cmake/Source/cmGlobalVisualStudio10Generator.h

298 lines
10 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2021-09-14 00:13:48 +02:00
#pragma once
2009-10-04 10:30:41 +03:00
2022-03-29 21:10:50 +02:00
#include <cstddef>
2020-08-30 11:54:41 +02:00
#include <memory>
2021-09-14 00:13:48 +02:00
#include <set>
2022-03-29 21:10:50 +02:00
#include <string>
#include <vector>
2021-09-14 00:13:48 +02:00
#include <cm/optional>
#include <cm/string_view>
2020-08-30 11:54:41 +02:00
2009-10-04 10:30:41 +03:00
#include "cmGlobalVisualStudio8Generator.h"
2022-03-29 21:10:50 +02:00
class cmGeneratorTarget;
class cmGlobalGeneratorFactory;
class cmLocalGenerator;
class cmMakefile;
class cmSourceFile;
class cmake;
struct cmIDEFlagTable;
2009-10-04 10:30:41 +03:00
/** \class cmGlobalVisualStudio10Generator
* \brief Write a Unix makefiles.
*
* cmGlobalVisualStudio10Generator manages UNIX build process for a tree
*/
2016-07-09 11:21:54 +02:00
class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator
2009-10-04 10:30:41 +03:00
{
public:
2020-08-30 11:54:41 +02:00
static std::unique_ptr<cmGlobalGeneratorFactory> NewFactory();
2013-03-16 19:13:01 +02:00
2021-11-20 13:41:27 +01:00
bool IsVisualStudioAtLeast10() const override { return true; }
2018-04-23 21:13:27 +02:00
bool MatchesGeneratorName(const std::string& name) const override;
2014-08-03 19:52:23 +02:00
2018-04-23 21:13:27 +02:00
bool SetSystemName(std::string const& s, cmMakefile* mf) override;
bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf) override;
2020-08-30 11:54:41 +02:00
bool SetGeneratorToolset(std::string const& ts, bool build,
cmMakefile* mf) override;
2013-03-16 19:13:01 +02:00
2019-11-11 23:01:05 +01:00
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
2022-03-29 21:10:50 +02:00
const std::string& config, int jobs, bool verbose,
const cmBuildOptions& buildOptions = cmBuildOptions(),
2019-11-11 23:01:05 +01:00
std::vector<std::string> const& makeOptions =
std::vector<std::string>()) override;
//! create the correct local generator
2020-08-30 11:54:41 +02:00
std::unique_ptr<cmLocalGenerator> CreateLocalGenerator(
cmMakefile* mf) override;
2009-10-04 10:30:41 +03:00
/**
2015-04-27 22:25:09 +02:00
* Try to determine system information such as shared library
2013-03-16 19:13:01 +02:00
* extension, pthreads, byte order etc.
2009-10-04 10:30:41 +03:00
*/
2018-04-23 21:13:27 +02:00
void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*,
bool optional) override;
2009-10-04 10:30:41 +03:00
2021-09-14 00:13:48 +02:00
void AddAndroidExecutableWarning(const std::string& name)
{
this->AndroidExecutableWarnings.insert(name);
}
2017-07-20 19:35:53 +02:00
bool IsCudaEnabled() const { return this->CudaEnabled; }
2015-04-27 22:25:09 +02:00
/** Generating for Nsight Tegra VS plugin? */
bool IsNsightTegra() const;
std::string GetNsightTegraVersion() const;
2013-11-03 12:27:13 +02:00
2020-08-30 11:54:41 +02:00
/** The vctargets path for the target platform. */
const char* GetCustomVCTargetsPath() const;
2011-01-16 11:35:12 +01:00
/** The toolset name for the target platform. */
2015-04-27 22:25:09 +02:00
const char* GetPlatformToolset() const;
2017-04-14 19:02:05 +02:00
std::string const& GetPlatformToolsetString() const;
2021-09-14 00:13:48 +02:00
/** The toolset version props file, if any. */
std::string const& GetPlatformToolsetVersionProps() const;
2018-08-09 18:06:22 +02:00
2017-04-14 19:02:05 +02:00
/** The toolset host architecture name (e.g. x64 for 64-bit host tools). */
const char* GetPlatformToolsetHostArchitecture() const;
2019-11-11 23:01:05 +01:00
std::string const& GetPlatformToolsetHostArchitectureString() const;
2015-04-27 22:25:09 +02:00
2017-07-20 19:35:53 +02:00
/** The cuda toolset version. */
const char* GetPlatformToolsetCuda() const;
std::string const& GetPlatformToolsetCudaString() const;
2020-02-01 23:06:01 +01:00
/** The custom cuda install directory */
const char* GetPlatformToolsetCudaCustomDir() const;
std::string const& GetPlatformToolsetCudaCustomDirString() const;
2021-09-14 00:13:48 +02:00
/** The nvcc subdirectory of a custom cuda install directory */
std::string const& GetPlatformToolsetCudaNvccSubdirString() const;
/** The visual studio integration subdirectory of a custom cuda install
* directory */
std::string const& GetPlatformToolsetCudaVSIntegrationSubdirString() const;
2017-07-20 19:35:53 +02:00
/** Return whether we need to use No/Debug instead of false/true
for GenerateDebugInformation. */
bool GetPlatformToolsetNeedsDebugEnum() const
{
return this->PlatformToolsetNeedsDebugEnum;
}
2015-04-27 22:25:09 +02:00
/** Return the CMAKE_SYSTEM_NAME. */
std::string const& GetSystemName() const { return this->SystemName; }
/** Return the CMAKE_SYSTEM_VERSION. */
std::string const& GetSystemVersion() const { return this->SystemVersion; }
2015-11-17 17:22:37 +01:00
/** Return the Windows version targeted on VS 2015 and above. */
std::string const& GetWindowsTargetPlatformVersion() const
2016-07-09 11:21:54 +02:00
{
return this->WindowsTargetPlatformVersion;
}
2015-11-17 17:22:37 +01:00
2015-04-27 22:25:09 +02:00
/** Return true if building for WindowsCE */
2019-11-11 23:01:05 +01:00
bool TargetsWindowsCE() const override { return this->SystemIsWindowsCE; }
2015-04-27 22:25:09 +02:00
/** Return true if building for WindowsPhone */
2016-07-09 11:21:54 +02:00
bool TargetsWindowsPhone() const { return this->SystemIsWindowsPhone; }
2015-04-27 22:25:09 +02:00
/** Return true if building for WindowsStore */
2016-07-09 11:21:54 +02:00
bool TargetsWindowsStore() const { return this->SystemIsWindowsStore; }
2011-01-16 11:35:12 +01:00
2021-09-14 00:13:48 +02:00
/** Return true if building for Android */
bool TargetsAndroid() const { return this->SystemIsAndroid; }
2018-04-23 21:13:27 +02:00
const char* GetCMakeCFGIntDir() const override { return "$(Configuration)"; }
2012-02-18 12:40:36 +02:00
bool Find64BitTools(cmMakefile* mf);
2012-06-27 20:52:58 +03:00
/** Generate an <output>.rule file path for a given command output. */
2018-04-23 21:13:27 +02:00
std::string GenerateRuleFile(std::string const& output) const override;
2012-06-27 20:52:58 +03:00
2016-03-13 13:35:51 +01:00
void PathTooLong(cmGeneratorTarget* target, cmSourceFile const* sf,
2012-06-27 20:52:58 +03:00
std::string const& sfRel);
2013-11-03 12:27:13 +02:00
2018-04-23 21:13:27 +02:00
std::string Encoding() override;
2019-11-11 23:01:05 +01:00
const char* GetToolsVersion() const;
2013-11-03 12:27:13 +02:00
2021-09-14 00:13:48 +02:00
virtual cm::optional<std::string> GetVSInstanceVersion() const { return {}; }
2018-08-09 18:06:22 +02:00
2020-08-30 11:54:41 +02:00
bool GetSupportsUnityBuilds() const { return this->SupportsUnityBuilds; }
2021-11-20 13:41:27 +01:00
virtual cm::optional<std::string> FindMSBuildCommandEarly(cmMakefile* mf);
2018-01-26 17:06:56 +01:00
bool FindMakeProgram(cmMakefile* mf) override;
2014-08-03 19:52:23 +02:00
2018-10-28 12:09:07 +01:00
bool IsIPOSupported() const override { return true; }
2020-08-30 11:54:41 +02:00
virtual bool IsStdOutEncodingSupported() const { return false; }
2021-09-14 00:13:48 +02:00
virtual bool IsUtf8EncodingSupported() const { return false; }
2015-04-27 22:25:09 +02:00
static std::string GetInstalledNsightTegraVersion();
2019-11-11 23:01:05 +01:00
/** Return the first two components of CMAKE_SYSTEM_VERSION. */
std::string GetApplicationTypeRevision() const;
2021-09-14 00:13:48 +02:00
virtual const char* GetAndroidApplicationTypeRevision() const { return ""; }
2017-04-14 19:02:05 +02:00
cmIDEFlagTable const* GetClFlagTable() const;
cmIDEFlagTable const* GetCSharpFlagTable() const;
cmIDEFlagTable const* GetRcFlagTable() const;
cmIDEFlagTable const* GetLibFlagTable() const;
cmIDEFlagTable const* GetLinkFlagTable() const;
2017-07-20 19:35:53 +02:00
cmIDEFlagTable const* GetCudaFlagTable() const;
cmIDEFlagTable const* GetCudaHostFlagTable() const;
2017-04-14 19:02:05 +02:00
cmIDEFlagTable const* GetMasmFlagTable() const;
2017-07-20 19:35:53 +02:00
cmIDEFlagTable const* GetNasmFlagTable() const;
2017-04-14 19:02:05 +02:00
2022-03-29 21:10:50 +02:00
bool IsMsBuildRestoreSupported() const;
2009-10-04 10:30:41 +03:00
protected:
2019-11-11 23:01:05 +01:00
cmGlobalVisualStudio10Generator(cmake* cm, const std::string& name,
std::string const& platformInGeneratorName);
2018-04-23 21:13:27 +02:00
void Generate() override;
2015-04-27 22:25:09 +02:00
virtual bool InitializeSystem(cmMakefile* mf);
2015-11-17 17:22:37 +01:00
virtual bool InitializeWindows(cmMakefile* mf);
2015-04-27 22:25:09 +02:00
virtual bool InitializeWindowsCE(cmMakefile* mf);
virtual bool InitializeWindowsPhone(cmMakefile* mf);
virtual bool InitializeWindowsStore(cmMakefile* mf);
2021-09-14 00:13:48 +02:00
virtual bool InitializeTegraAndroid(cmMakefile* mf);
virtual bool InitializeAndroid(cmMakefile* mf);
2015-04-27 22:25:09 +02:00
2017-07-20 19:35:53 +02:00
virtual bool ProcessGeneratorToolsetField(std::string const& key,
std::string const& value);
2015-04-27 22:25:09 +02:00
virtual std::string SelectWindowsCEToolset() const;
virtual bool SelectWindowsPhoneToolset(std::string& toolset) const;
virtual bool SelectWindowsStoreToolset(std::string& toolset) const;
2021-09-14 00:13:48 +02:00
enum class AuxToolset
{
None,
Default,
PropsExist,
PropsMissing
};
virtual AuxToolset FindAuxToolset(std::string& version,
std::string& props) const;
2014-08-03 19:52:23 +02:00
std::string const& GetMSBuildCommand();
2021-09-14 00:13:48 +02:00
cmIDEFlagTable const* LoadFlagTable(std::string const& toolSpecificName,
2019-11-11 23:01:05 +01:00
std::string const& defaultName,
std::string const& table) const;
2015-04-27 22:25:09 +02:00
std::string GeneratorToolset;
2021-09-14 00:13:48 +02:00
std::string GeneratorToolsetVersionProps;
2017-04-14 19:02:05 +02:00
std::string GeneratorToolsetHostArchitecture;
2020-08-30 11:54:41 +02:00
std::string GeneratorToolsetCustomVCTargetsDir;
2017-07-20 19:35:53 +02:00
std::string GeneratorToolsetCuda;
2020-02-01 23:06:01 +01:00
std::string GeneratorToolsetCudaCustomDir;
2021-09-14 00:13:48 +02:00
std::string GeneratorToolsetCudaNvccSubdir;
std::string GeneratorToolsetCudaVSIntegrationSubdir;
2015-04-27 22:25:09 +02:00
std::string DefaultPlatformToolset;
2019-11-11 23:01:05 +01:00
std::string DefaultPlatformToolsetHostArchitecture;
2021-09-14 00:13:48 +02:00
std::string DefaultAndroidToolset;
2015-11-17 17:22:37 +01:00
std::string WindowsTargetPlatformVersion;
2015-04-27 22:25:09 +02:00
std::string SystemName;
std::string SystemVersion;
std::string NsightTegraVersion;
2019-11-11 23:01:05 +01:00
std::string DefaultCLFlagTableName;
std::string DefaultCSharpFlagTableName;
std::string DefaultLibFlagTableName;
std::string DefaultLinkFlagTableName;
std::string DefaultCudaFlagTableName;
std::string DefaultCudaHostFlagTableName;
std::string DefaultMasmFlagTableName;
std::string DefaultNasmFlagTableName;
std::string DefaultRCFlagTableName;
2020-08-30 11:54:41 +02:00
bool SupportsUnityBuilds = false;
2021-09-14 00:13:48 +02:00
bool SystemIsWindowsCE = false;
bool SystemIsWindowsPhone = false;
bool SystemIsWindowsStore = false;
bool SystemIsAndroid = false;
2021-11-20 13:41:27 +01:00
bool MSBuildCommandInitialized = false;
2012-06-27 20:52:58 +03:00
private:
2013-03-16 19:13:01 +02:00
class Factory;
2019-11-11 23:01:05 +01:00
friend class Factory;
2012-06-27 20:52:58 +03:00
struct LongestSourcePath
{
2016-07-09 11:21:54 +02:00
LongestSourcePath()
: Length(0)
, Target(0)
, SourceFile(0)
{
}
2012-06-27 20:52:58 +03:00
size_t Length;
2016-03-13 13:35:51 +01:00
cmGeneratorTarget* Target;
2015-04-27 22:25:09 +02:00
cmSourceFile const* SourceFile;
2012-06-27 20:52:58 +03:00
std::string SourceRel;
};
LongestSourcePath LongestSource;
2014-08-03 19:52:23 +02:00
std::string MSBuildCommand;
2021-09-14 00:13:48 +02:00
std::set<std::string> AndroidExecutableWarnings;
2014-08-03 19:52:23 +02:00
virtual std::string FindMSBuildCommand();
2018-04-23 21:13:27 +02:00
std::string FindDevEnvCommand() override;
std::string GetVSMakeProgram() override { return this->GetMSBuildCommand(); }
2015-08-17 11:37:30 +02:00
2021-09-14 00:13:48 +02:00
std::string GeneratorToolsetVersion;
2017-07-20 19:35:53 +02:00
bool PlatformToolsetNeedsDebugEnum;
bool ParseGeneratorToolset(std::string const& ts, cmMakefile* mf);
2021-09-14 00:13:48 +02:00
std::string GetClFlagTableName() const;
std::string GetCSharpFlagTableName() const;
std::string GetRcFlagTableName() const;
std::string GetLibFlagTableName() const;
std::string GetLinkFlagTableName() const;
std::string GetMasmFlagTableName() const;
std::string CanonicalToolsetName(std::string const& toolset) const;
cm::optional<std::string> FindFlagTable(cm::string_view toolsetName,
cm::string_view table) const;
std::string CustomFlagTableDir;
2020-08-30 11:54:41 +02:00
std::string CustomVCTargetsPath;
2017-07-20 19:35:53 +02:00
std::string VCTargetsPath;
bool FindVCTargetsPath(cmMakefile* mf);
bool CudaEnabled;
2015-08-17 11:37:30 +02:00
// We do not use the reload macros for VS >= 10.
2018-04-23 21:13:27 +02:00
std::string GetUserMacrosDirectory() override { return ""; }
2009-10-04 10:30:41 +03:00
};