cmake/Source/cmGlobalGenerator.h

642 lines
23 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. */
#ifndef cmGlobalGenerator_h
#define cmGlobalGenerator_h
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-10-30 18:24:19 +01:00
#include <iosfwd>
#include <map>
#include <set>
#include <string>
2018-01-26 17:06:56 +01:00
#include <unordered_map>
2016-10-30 18:24:19 +01:00
#include <utility>
#include <vector>
2013-03-16 19:13:01 +02:00
2017-04-14 19:02:05 +02:00
#include "cmCustomCommandLines.h"
2018-04-23 21:13:27 +02:00
#include "cmDuration.h"
2017-04-14 19:02:05 +02:00
#include "cmExportSetMap.h"
#include "cmStateSnapshot.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
#include "cmTargetDepend.h"
#include "cm_codecvt.hxx"
2015-04-27 22:25:09 +02:00
#if defined(CMAKE_BUILD_WITH_CMAKE)
2018-08-09 18:06:22 +02:00
# include "cmFileLockPool.h"
2015-04-27 22:25:09 +02:00
#endif
2018-10-28 12:09:07 +01:00
#define CMAKE_DIRECTORY_ID_SEP "::@"
class cmDirectoryId;
2016-10-30 18:24:19 +01:00
class cmExportBuildFileGenerator;
class cmExternalMakefileProjectGenerator;
2012-04-19 19:04:21 +03:00
class cmGeneratorTarget;
2017-04-14 19:02:05 +02:00
class cmLinkLineComputer;
class cmLocalGenerator;
2016-10-30 18:24:19 +01:00
class cmMakefile;
2017-04-14 19:02:05 +02:00
class cmOutputConverter;
class cmSourceFile;
class cmStateDirectory;
2016-10-30 18:24:19 +01:00
class cmake;
/** \class cmGlobalGenerator
2015-04-27 22:25:09 +02:00
* \brief Responsible for overseeing the generation process for the entire tree
*
* Subclasses of this class generate makefiles for various
* platforms.
*/
class cmGlobalGenerator
{
public:
///! Free any memory allocated with the GlobalGenerator
2015-08-17 11:37:30 +02:00
cmGlobalGenerator(cmake* cm);
virtual ~cmGlobalGenerator();
2011-01-16 11:35:12 +01:00
2016-07-09 11:21:54 +02:00
virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
///! Get the name for this generator
2015-04-27 22:25:09 +02:00
virtual std::string GetName() const { return "Generic"; }
2011-01-16 11:35:12 +01:00
2014-08-03 19:52:23 +02:00
/** Check whether the given name matches the current generator. */
2015-04-27 22:25:09 +02:00
virtual bool MatchesGeneratorName(const std::string& name) const
2016-07-09 11:21:54 +02:00
{
return this->GetName() == name;
}
2015-04-27 22:25:09 +02:00
2017-04-14 19:02:05 +02:00
/** Get encoding used by generator for makefile files */
virtual codecvt::Encoding GetMakefileEncoding() const
{
return codecvt::None;
}
2015-04-27 22:25:09 +02:00
/** Tell the generator about the target system. */
2016-07-09 11:21:54 +02:00
virtual bool SetSystemName(std::string const&, cmMakefile*) { return true; }
2015-04-27 22:25:09 +02:00
2018-04-23 21:13:27 +02:00
/** Set the generator-specific instance. Returns true if supported. */
virtual bool SetGeneratorInstance(std::string const& i, cmMakefile* mf);
2015-04-27 22:25:09 +02:00
/** Set the generator-specific platform name. Returns true if platform
is supported and false otherwise. */
virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf);
2014-08-03 19:52:23 +02:00
2013-03-16 19:13:01 +02:00
/** Set the generator-specific toolset name. Returns true if toolset
is supported and false otherwise. */
2015-04-27 22:25:09 +02:00
virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
2011-01-16 11:35:12 +01:00
/**
* Create LocalGenerators and process the CMakeLists files. This does not
2011-01-16 11:35:12 +01:00
* actually produce any makefiles, DSPs, etc.
*/
virtual void Configure();
2016-03-13 13:35:51 +01:00
bool Compute();
virtual void AddExtraIDETargets() {}
2015-11-17 17:22:37 +01:00
2016-07-09 11:21:54 +02:00
enum TargetTypes
{
2015-11-17 17:22:37 +01:00
AllTargets,
ImportedOnly
};
2016-07-09 11:21:54 +02:00
void CreateImportedGenerationObjects(
cmMakefile* mf, std::vector<std::string> const& targets,
std::vector<cmGeneratorTarget const*>& exports);
2015-11-17 17:22:37 +01:00
void CreateGenerationObjects(TargetTypes targetTypes = AllTargets);
/**
* Generate the all required files for building this project/tree. This
* basically creates a series of LocalGenerators for each directory and
2011-01-16 11:35:12 +01:00
* requests that they Generate.
*/
2015-11-17 17:22:37 +01:00
virtual void Generate();
2017-04-14 19:02:05 +02:00
virtual cmLinkLineComputer* CreateLinkLineComputer(
2017-07-20 19:35:53 +02:00
cmOutputConverter* outputConverter,
cmStateDirectory const& stateDir) const;
2017-04-14 19:02:05 +02:00
cmLinkLineComputer* CreateMSVC60LinkLineComputer(
2017-07-20 19:35:53 +02:00
cmOutputConverter* outputConverter,
cmStateDirectory const& stateDir) const;
2017-04-14 19:02:05 +02:00
/**
2011-01-16 11:35:12 +01:00
* Set/Get and Clear the enabled languages.
*/
2015-04-27 22:25:09 +02:00
void SetLanguageEnabled(const std::string&, cmMakefile* mf);
bool GetLanguageEnabled(const std::string&) const;
void ClearEnabledLanguages();
2014-08-03 19:52:23 +02:00
void GetEnabledLanguages(std::vector<std::string>& lang) const;
/**
2015-04-27 22:25:09 +02:00
* Try to determine system information such as shared library
2011-01-16 11:35:12 +01:00
* extension, pthreads, byte order etc.
*/
2016-07-09 11:21:54 +02:00
virtual void EnableLanguage(std::vector<std::string> const& languages,
cmMakefile*, bool optional);
2012-02-18 12:40:36 +02:00
/**
* Resolve the CMAKE_<lang>_COMPILER setting for the given language.
* Intended to be called from EnableLanguage.
*/
2016-07-09 11:21:54 +02:00
void ResolveLanguageCompiler(const std::string& lang, cmMakefile* mf,
2014-08-03 19:52:23 +02:00
bool optional) const;
2012-02-18 12:40:36 +02:00
/**
2015-04-27 22:25:09 +02:00
* Try to determine system information, get it from another generator
*/
2016-07-09 11:21:54 +02:00
void EnableLanguagesFromGenerator(cmGlobalGenerator* gen, cmMakefile* mf);
/**
2012-02-18 12:40:36 +02:00
* Try running cmake and building a file. This is used for dynamically
* loaded commands, not as part of the usual build process.
*/
2018-08-09 18:06:22 +02:00
int TryCompile(int jobs, const std::string& srcdir,
const std::string& bindir, const std::string& projectName,
const std::string& targetName, bool fast, std::string& output,
cmMakefile* mf);
2011-01-16 11:35:12 +01:00
/**
* Build a file given the following information. This is a more direct call
* that is used by both CTest and TryCompile. If target name is NULL or
* empty then all is assumed. clean indicates if a "make clean" should be
* done first.
*/
2018-08-09 18:06:22 +02:00
int Build(
int jobs, const std::string& srcdir, const std::string& bindir,
const std::string& projectName, const std::string& targetName,
std::string& output, const std::string& makeProgram,
const std::string& config, bool clean, bool fast, bool verbose,
cmDuration timeout,
cmSystemTools::OutputOption outputflag = cmSystemTools::OUTPUT_NONE,
std::vector<std::string> const& nativeOptions =
std::vector<std::string>());
2011-01-16 11:35:12 +01:00
2018-04-23 21:13:27 +02:00
/**
* Open a generated IDE project given the following information.
*/
virtual bool Open(const std::string& bindir, const std::string& projectName,
bool dryRun);
2014-08-03 19:52:23 +02:00
virtual void GenerateBuildCommand(
2016-07-09 11:21:54 +02:00
std::vector<std::string>& makeCommand, const std::string& makeProgram,
2015-04-27 22:25:09 +02:00
const std::string& projectName, const std::string& projectDir,
2016-07-09 11:21:54 +02:00
const std::string& targetName, const std::string& config, bool fast,
2018-08-09 18:06:22 +02:00
int jobs, bool verbose,
2016-07-09 11:21:54 +02:00
std::vector<std::string> const& makeOptions = std::vector<std::string>());
2011-01-16 11:35:12 +01:00
2018-08-09 18:06:22 +02:00
virtual void PrintBuildCommandAdvice(std::ostream& os, int jobs) const;
2014-08-03 19:52:23 +02:00
/** Generate a "cmake --build" call for a given target and config. */
2015-04-27 22:25:09 +02:00
std::string GenerateCMakeBuildCommand(const std::string& target,
const std::string& config,
const std::string& native,
2014-08-03 19:52:23 +02:00
bool ignoreErrors);
///! Get the CMake instance
2016-07-09 11:21:54 +02:00
cmake* GetCMakeInstance() const { return this->CMakeInstance; }
2009-10-04 10:30:41 +03:00
void SetConfiguredFilesPath(cmGlobalGenerator* gen);
2016-07-09 11:21:54 +02:00
const std::vector<cmMakefile*>& GetMakefiles() const
{
return this->Makefiles;
}
const std::vector<cmLocalGenerator*>& GetLocalGenerators() const
2015-11-17 17:22:37 +01:00
{
2016-07-09 11:21:54 +02:00
return this->LocalGenerators;
2015-11-17 17:22:37 +01:00
}
2018-01-26 17:06:56 +01:00
cmMakefile* GetCurrentMakefile() const
{
return this->CurrentConfigureMakefile;
}
2018-01-26 17:06:56 +01:00
void SetCurrentMakefile(cmMakefile* mf)
{
this->CurrentConfigureMakefile = mf;
}
2016-07-09 11:21:54 +02:00
void AddMakefile(cmMakefile* mf);
///! Set an generator for an "external makefile based project"
void SetExternalMakefileProjectGenerator(
2016-07-09 11:21:54 +02:00
cmExternalMakefileProjectGenerator* extraGenerator);
2015-04-27 22:25:09 +02:00
std::string GetExtraGeneratorName() const;
2018-10-28 12:09:07 +01:00
void AddInstallComponent(const std::string& component);
2015-04-27 22:25:09 +02:00
const std::set<std::string>* GetInstallComponents() const
2016-07-09 11:21:54 +02:00
{
return &this->InstallComponents;
}
2013-03-16 19:13:01 +02:00
2016-07-09 11:21:54 +02:00
cmExportSetMap& GetExportSets() { return this->ExportSets; }
2016-10-30 18:24:19 +01:00
const char* GetGlobalSetting(std::string const& name) const;
bool GlobalSettingIsOn(std::string const& name) const;
2018-10-28 12:09:07 +01:00
std::string GetSafeGlobalSetting(std::string const& name) const;
2016-10-30 18:24:19 +01:00
/** Add a file to the manifest of generated targets for a configuration. */
2015-11-17 17:22:37 +01:00
void AddToManifest(std::string const& f);
void EnableInstallTarget();
2018-04-23 21:13:27 +02:00
cmDuration TryCompileTimeout;
2011-01-16 11:35:12 +01:00
2012-02-18 12:40:36 +02:00
bool GetForceUnixPaths() const { return this->ForceUnixPaths; }
bool GetToolSupportsColor() const { return this->ToolSupportsColor; }
///! return the language for the given extension
2015-04-27 22:25:09 +02:00
std::string GetLanguageFromExtension(const char* ext) const;
///! is an extension to be ignored
2014-08-03 19:52:23 +02:00
bool IgnoreFile(const char* ext) const;
2015-04-27 22:25:09 +02:00
///! What is the preference for linkers and this language (None or Preferred)
int GetLinkerPreference(const std::string& lang) const;
///! What is the object file extension for a given source file?
2015-04-27 22:25:09 +02:00
std::string GetLanguageOutputExtension(cmSourceFile const&) const;
///! What is the configurations directory variable called?
2012-04-19 19:04:21 +03:00
virtual const char* GetCMakeCFGIntDir() const { return "."; }
2014-08-03 19:52:23 +02:00
///! expand CFGIntDir for a configuration
virtual std::string ExpandCFGIntDir(const std::string& str,
const std::string& config) const;
/** Get whether the generator should use a script for link commands. */
2012-02-18 12:40:36 +02:00
bool GetUseLinkScript() const { return this->UseLinkScript; }
/** Get whether the generator should produce special marks on rules
producing symbolic (non-file) outputs. */
2012-02-18 12:40:36 +02:00
bool GetNeedSymbolicMark() const { return this->NeedSymbolicMark; }
/*
* Determine what program to use for building the project.
*/
2017-04-14 19:02:05 +02:00
virtual bool FindMakeProgram(cmMakefile*);
///! Find a target by name by searching the local generators.
2015-04-27 22:25:09 +02:00
cmTarget* FindTarget(const std::string& name,
2014-08-03 19:52:23 +02:00
bool excludeAliases = false) const;
2013-11-03 12:27:13 +02:00
2016-03-13 13:35:51 +01:00
cmGeneratorTarget* FindGeneratorTarget(const std::string& name) const;
void AddAlias(const std::string& name, const std::string& tgtName);
2015-04-27 22:25:09 +02:00
bool IsAlias(const std::string& name) const;
/** Determine if a name resolves to a framework on disk or a built target
that is a framework. */
2014-08-03 19:52:23 +02:00
bool NameResolvesToFramework(const std::string& libname) const;
2015-11-17 17:22:37 +01:00
cmMakefile* FindMakefile(const std::string& start_dir) const;
2018-10-28 12:09:07 +01:00
cmLocalGenerator* FindLocalGenerator(cmDirectoryId const& id) const;
/** Append the subdirectory for the given configuration. If anything is
appended the given prefix and suffix will be appended around it, which
is useful for leading or trailing slashes. */
2015-04-27 22:25:09 +02:00
virtual void AppendDirectoryForConfig(const std::string& prefix,
const std::string& config,
const std::string& suffix,
std::string& dir);
2015-04-27 22:25:09 +02:00
/** Get the content of a directory. Directory listings are cached
and re-loaded from disk only when modified. During the generation
step the content will include the target files to be built even if
they do not yet exist. */
2015-04-27 22:25:09 +02:00
std::set<std::string> const& GetDirectoryContent(std::string const& dir,
bool needDisk = true);
2016-03-13 13:35:51 +01:00
void IndexTarget(cmTarget* t);
void IndexGeneratorTarget(cmGeneratorTarget* gt);
2018-10-28 12:09:07 +01:00
// Index the target using a name that is unique to that target
// even if other targets have the same name.
std::string IndexGeneratorTargetUniquely(cmGeneratorTarget const* gt);
2014-08-03 19:52:23 +02:00
static bool IsReservedTarget(std::string const& name);
2016-07-09 11:21:54 +02:00
virtual const char* GetAllTargetName() const { return "ALL_BUILD"; }
virtual const char* GetInstallTargetName() const { return "INSTALL"; }
2018-01-26 17:06:56 +01:00
virtual const char* GetInstallLocalTargetName() const { return nullptr; }
virtual const char* GetInstallStripTargetName() const { return nullptr; }
virtual const char* GetPreinstallTargetName() const { return nullptr; }
2016-07-09 11:21:54 +02:00
virtual const char* GetTestTargetName() const { return "RUN_TESTS"; }
virtual const char* GetPackageTargetName() const { return "PACKAGE"; }
2018-01-26 17:06:56 +01:00
virtual const char* GetPackageSourceTargetName() const { return nullptr; }
virtual const char* GetEditCacheTargetName() const { return nullptr; }
virtual const char* GetRebuildCacheTargetName() const { return nullptr; }
virtual const char* GetCleanTargetName() const { return nullptr; }
2014-08-03 19:52:23 +02:00
// Lookup edit_cache target command preferred by this generator.
virtual std::string GetEditCacheCommand() const { return ""; }
// Class to track a set of dependencies.
2011-01-16 11:35:12 +01:00
typedef cmTargetDependSet TargetDependSet;
// what targets does the specified target depend on directly
// via a target_link_libraries or add_dependencies
2015-11-17 17:22:37 +01:00
TargetDependSet const& GetTargetDirectDepends(
2016-07-09 11:21:54 +02:00
const cmGeneratorTarget* target);
2018-01-26 17:06:56 +01:00
const std::map<std::string, std::vector<cmLocalGenerator*>>& GetProjectMap()
2016-07-09 11:21:54 +02:00
const
{
return this->ProjectMap;
}
// track files replaced during a Generate
void FileReplacedDuringGenerate(const std::string& filename);
void GetFilesReplacedDuringGenerate(std::vector<std::string>& filenames);
void AddRuleHash(const std::vector<std::string>& outputs,
2009-10-04 10:30:41 +03:00
std::string const& content);
2009-05-01 17:43:35 +03:00
/** Return whether the given binary directory is unused. */
2015-04-27 22:25:09 +02:00
bool BinaryDirectoryIsNew(const std::string& dir)
2016-07-09 11:21:54 +02:00
{
2009-05-01 17:43:35 +03:00
return this->BinaryDirectories.insert(dir).second;
2016-07-09 11:21:54 +02:00
}
2009-05-01 17:43:35 +03:00
2010-03-17 14:00:29 +02:00
/** Return true if the generated build tree may contain multiple builds.
i.e. "Can I build Debug and Release in the same tree?" */
2016-10-30 18:24:19 +01:00
virtual bool IsMultiConfig() const { return false; }
2010-03-17 14:00:29 +02:00
2018-10-28 12:09:07 +01:00
virtual bool IsXcode() const { return false; }
2017-07-20 19:35:53 +02:00
/** Return true if we know the exact location of object files.
If false, store the reason in the given string.
This is meaningful only after EnableLanguage has been called. */
virtual bool HasKnownObjectFileLocation(std::string*) const { return true; }
2017-04-14 19:02:05 +02:00
virtual bool UseFolderProperty() const;
2017-07-20 19:35:53 +02:00
virtual bool IsIPOSupported() const { return false; }
2018-04-23 21:13:27 +02:00
/** Return whether the generator can import external visual studio project
using INCLUDE_EXTERNAL_MSPROJECT */
virtual bool IsIncludeExternalMSProjectSupported() const { return false; }
2017-04-14 19:02:05 +02:00
/** Return whether the generator should use EFFECTIVE_PLATFORM_NAME. This is
relevant for mixed macOS and iOS builds. */
virtual bool UseEffectivePlatformName(cmMakefile*) const { return false; }
2017-07-20 19:35:53 +02:00
/** Return whether the "Resources" folder prefix should be stripped from
MacFolder. */
virtual bool ShouldStripResourcePath(cmMakefile*) const;
2014-08-03 19:52:23 +02:00
std::string GetSharedLibFlagsForLanguage(std::string const& lang) const;
2012-06-27 20:52:58 +03:00
/** Generate an <output>.rule file path for a given command output. */
virtual std::string GenerateRuleFile(std::string const& output) const;
static std::string EscapeJSON(const std::string& s);
2013-11-03 12:27:13 +02:00
void ProcessEvaluationFiles();
2014-08-03 19:52:23 +02:00
std::map<std::string, cmExportBuildFileGenerator*>& GetBuildExportSets()
2016-07-09 11:21:54 +02:00
{
return this->BuildExportSets;
}
2014-08-03 19:52:23 +02:00
void AddBuildExportSet(cmExportBuildFileGenerator*);
void AddBuildExportExportSet(cmExportBuildFileGenerator*);
2016-07-09 11:21:54 +02:00
bool IsExportedTargetsFile(const std::string& filename) const;
bool GenerateImportFile(const std::string& file);
cmExportBuildFileGenerator* GetExportedTargetsFile(
const std::string& filename) const;
2014-08-03 19:52:23 +02:00
void AddCMP0042WarnTarget(const std::string& target);
2017-07-20 19:35:53 +02:00
void AddCMP0068WarnTarget(const std::string& target);
2014-08-03 19:52:23 +02:00
2015-04-27 22:25:09 +02:00
virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
bool GenerateCPackPropertiesFile();
void CreateEvaluationSourceFiles(std::string const& config) const;
2016-07-09 11:21:54 +02:00
void SetFilenameTargetDepends(
cmSourceFile* sf, std::set<cmGeneratorTarget const*> const& tgts);
const std::set<const cmGeneratorTarget*>& GetFilenameTargetDepends(
cmSourceFile* sf) const;
2015-04-27 22:25:09 +02:00
#if defined(CMAKE_BUILD_WITH_CMAKE)
cmFileLockPool& GetFileLockPool() { return FileLockPool; }
#endif
2016-03-13 13:35:51 +01:00
bool GetConfigureDoneCMP0026() const
2016-07-09 11:21:54 +02:00
{
return this->ConfigureDoneCMP0026AndCMP0024;
}
2015-11-17 17:22:37 +01:00
2015-08-17 11:37:30 +02:00
std::string MakeSilentFlag;
2016-07-09 11:21:54 +02:00
protected:
2009-10-04 10:30:41 +03:00
typedef std::vector<cmLocalGenerator*> GeneratorVector;
// for a project collect all its targets by following depend
// information, and also collect all the targets
2015-08-17 11:37:30 +02:00
void GetTargetSets(TargetDependSet& projectTargets,
2016-07-09 11:21:54 +02:00
TargetDependSet& originalTargets, cmLocalGenerator* root,
GeneratorVector const&);
2016-03-13 13:35:51 +01:00
bool IsRootOnlyTarget(cmGeneratorTarget* target) const;
2015-11-17 17:22:37 +01:00
void AddTargetDepends(const cmGeneratorTarget* target,
2014-08-03 19:52:23 +02:00
TargetDependSet& projectTargets);
2015-04-27 22:25:09 +02:00
void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf);
void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf);
void FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf);
2016-10-30 18:24:19 +01:00
virtual bool CheckLanguages(std::vector<std::string> const& languages,
cmMakefile* mf) const;
2015-11-17 17:22:37 +01:00
virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
const char* envVar) const;
2010-11-13 01:00:53 +02:00
virtual bool ComputeTargetDepends();
2014-08-03 19:52:23 +02:00
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const;
2018-10-28 12:09:07 +01:00
/// @brief Qt AUTOMOC/UIC/RCC target generation
/// @return true on success
bool QtAutoGen();
2012-02-18 12:40:36 +02:00
2015-04-27 22:25:09 +02:00
std::string SelectMakeProgram(const std::string& makeProgram,
const std::string& makeDefault = "") const;
2011-01-16 11:35:12 +01:00
// Fill the ProjectMap, this must be called after LocalGenerators
// has been populated.
void FillProjectMap();
2015-11-17 17:22:37 +01:00
void CheckTargetProperties();
2017-04-14 19:02:05 +02:00
bool IsExcluded(cmStateSnapshot const& root,
cmStateSnapshot const& snp) const;
2014-08-03 19:52:23 +02:00
bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const;
2015-11-17 17:22:37 +01:00
bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const;
virtual void InitializeProgressMarks() {}
2016-10-30 18:24:19 +01:00
struct GlobalTargetInfo
{
std::string Name;
std::string Message;
cmCustomCommandLines CommandLines;
std::vector<std::string> Depends;
std::string WorkingDir;
bool UsesTerminal;
GlobalTargetInfo()
: UsesTerminal(false)
{
}
};
void CreateDefaultGlobalTargets(std::vector<GlobalTargetInfo>& targets);
void AddGlobalTarget_Package(std::vector<GlobalTargetInfo>& targets);
void AddGlobalTarget_PackageSource(std::vector<GlobalTargetInfo>& targets);
void AddGlobalTarget_Test(std::vector<GlobalTargetInfo>& targets);
void AddGlobalTarget_EditCache(std::vector<GlobalTargetInfo>& targets);
void AddGlobalTarget_RebuildCache(std::vector<GlobalTargetInfo>& targets);
void AddGlobalTarget_Install(std::vector<GlobalTargetInfo>& targets);
cmTarget CreateGlobalTarget(GlobalTargetInfo const& gti, cmMakefile* mf);
2015-04-27 22:25:09 +02:00
std::string FindMakeProgramFile;
std::string ConfiguredFilesPath;
2016-07-09 11:21:54 +02:00
cmake* CMakeInstance;
2015-11-17 17:22:37 +01:00
std::vector<cmMakefile*> Makefiles;
2016-07-09 11:21:54 +02:00
std::vector<cmLocalGenerator*> LocalGenerators;
2018-01-26 17:06:56 +01:00
cmMakefile* CurrentConfigureMakefile;
// map from project name to vector of local generators in that project
2018-01-26 17:06:56 +01:00
std::map<std::string, std::vector<cmLocalGenerator*>> ProjectMap;
// Set of named installation components requested by the project.
2015-04-27 22:25:09 +02:00
std::set<std::string> InstallComponents;
// Sets of named target exports
2013-03-16 19:13:01 +02:00
cmExportSetMap ExportSets;
2014-08-03 19:52:23 +02:00
std::map<std::string, cmExportBuildFileGenerator*> BuildExportSets;
std::map<std::string, cmExportBuildFileGenerator*> BuildExportExportSets;
2016-03-13 13:35:51 +01:00
std::map<std::string, std::string> AliasTargets;
cmTarget* FindTargetImpl(std::string const& name) const;
cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const;
2016-07-09 11:21:54 +02:00
cmGeneratorTarget* FindImportedGeneratorTargetImpl(
std::string const& name) const;
2016-03-13 13:35:51 +01:00
const char* GetPredefinedTargetsFolder();
private:
2018-01-26 17:06:56 +01:00
typedef std::unordered_map<std::string, cmTarget*> TargetMap;
typedef std::unordered_map<std::string, cmGeneratorTarget*>
GeneratorTargetMap;
typedef std::unordered_map<std::string, cmMakefile*> MakefileMap;
2018-10-28 12:09:07 +01:00
typedef std::unordered_map<std::string, cmLocalGenerator*> LocalGeneratorMap;
2016-03-13 13:35:51 +01:00
// Map efficiently from target name to cmTarget instance.
// Do not use this structure for looping over all targets.
// It contains both normal and globally visible imported targets.
TargetMap TargetSearchIndex;
GeneratorTargetMap GeneratorTargetSearchIndex;
2009-10-04 10:30:41 +03:00
2016-10-30 18:24:19 +01:00
// Map efficiently from source directory path to cmMakefile instance.
// Do not use this structure for looping over all directories.
// It may not contain all of them (see note in IndexMakefile method).
MakefileMap MakefileSearchIndex;
2018-10-28 12:09:07 +01:00
// Map efficiently from source directory path to cmLocalGenerator instance.
// Do not use this structure for looping over all directories.
// Its order is not deterministic.
LocalGeneratorMap LocalGeneratorSearchIndex;
2011-02-07 16:37:25 +01:00
cmMakefile* TryCompileOuterMakefile;
// If you add a new map here, make sure it is copied
2011-01-16 11:35:12 +01:00
// in EnableLanguagesFromGenerator
2015-04-27 22:25:09 +02:00
std::map<std::string, bool> IgnoreExtensions;
std::set<std::string> LanguagesReady; // Ready for try_compile
2016-07-09 11:21:54 +02:00
std::set<std::string> LanguagesInProgress;
2015-04-27 22:25:09 +02:00
std::map<std::string, std::string> OutputExtensions;
std::map<std::string, std::string> LanguageToOutputExtension;
std::map<std::string, std::string> ExtensionToLanguage;
std::map<std::string, int> LanguageToLinkerPreference;
std::map<std::string, std::string> LanguageToOriginalSharedLibFlags;
// Record hashes for rules and outputs.
2016-07-09 11:21:54 +02:00
struct RuleHash
{
char Data[32];
};
2015-04-27 22:25:09 +02:00
std::map<std::string, RuleHash> RuleHashes;
void CheckRuleHashes();
2010-03-17 14:00:29 +02:00
void CheckRuleHashes(std::string const& pfile, std::string const& home);
void WriteRuleHashes(std::string const& pfile);
2009-10-04 10:30:41 +03:00
void WriteSummary();
2016-03-13 13:35:51 +01:00
void WriteSummary(cmGeneratorTarget* target);
2014-08-03 19:52:23 +02:00
void FinalizeTargetCompileInfo();
2015-04-27 22:25:09 +02:00
virtual void ForceLinkerLanguages();
2018-04-23 21:13:27 +02:00
bool CheckTargetsForMissingSources() const;
2015-11-17 17:22:37 +01:00
void CreateLocalGenerators();
2015-04-27 22:25:09 +02:00
void CheckCompilerIdCompatibility(cmMakefile* mf,
std::string const& lang) const;
2009-10-04 10:30:41 +03:00
2016-03-13 13:35:51 +01:00
void ComputeBuildFileGenerators();
cmExternalMakefileProjectGenerator* ExtraGenerator;
// track files replaced during a Generate
std::vector<std::string> FilesReplacedDuringGenerate;
// Store computed inter-target dependencies.
2015-11-17 17:22:37 +01:00
typedef std::map<cmGeneratorTarget const*, TargetDependSet> TargetDependMap;
TargetDependMap TargetDependencies;
2014-08-03 19:52:23 +02:00
friend class cmake;
2016-07-09 11:21:54 +02:00
void CreateGeneratorTargets(
TargetTypes targetTypes, cmMakefile* mf, cmLocalGenerator* lg,
std::map<cmTarget*, cmGeneratorTarget*> const& importedMap);
2015-11-17 17:22:37 +01:00
void CreateGeneratorTargets(TargetTypes targetTypes);
2012-04-19 19:04:21 +03:00
2014-08-03 19:52:23 +02:00
void ClearGeneratorMembers();
2018-04-23 21:13:27 +02:00
bool CheckCMP0037(std::string const& targetName,
std::string const& reason) const;
2016-10-30 18:24:19 +01:00
void IndexMakefile(cmMakefile* mf);
2018-10-28 12:09:07 +01:00
void IndexLocalGenerator(cmLocalGenerator* lg);
2016-10-30 18:24:19 +01:00
2018-01-26 17:06:56 +01:00
virtual const char* GetBuildIgnoreErrorsFlag() const { return nullptr; }
2014-08-03 19:52:23 +02:00
// Cache directory content and target files to be built.
2015-04-27 22:25:09 +02:00
struct DirectoryContent
{
2015-04-27 22:25:09 +02:00
long LastDiskTime;
std::set<std::string> All;
std::set<std::string> Generated;
2016-07-09 11:21:54 +02:00
DirectoryContent()
: LastDiskTime(-1)
{
}
};
2015-04-27 22:25:09 +02:00
std::map<std::string, DirectoryContent> DirectoryContentMap;
2009-05-01 17:43:35 +03:00
// Set of binary directories on disk.
2015-04-27 22:25:09 +02:00
std::set<std::string> BinaryDirectories;
2014-08-03 19:52:23 +02:00
// track targets to issue CMP0042 warning for.
std::set<std::string> CMP0042WarnTargets;
2017-07-20 19:35:53 +02:00
// track targets to issue CMP0068 warning for.
std::set<std::string> CMP0068WarnTargets;
2015-04-27 22:25:09 +02:00
2018-01-26 17:06:56 +01:00
mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*>>
2016-07-09 11:21:54 +02:00
FilenameTargetDepends;
2015-04-27 22:25:09 +02:00
#if defined(CMAKE_BUILD_WITH_CMAKE)
// Pool of file locks
cmFileLockPool FileLockPool;
#endif
2015-11-17 17:22:37 +01:00
protected:
float FirstTimeProgress;
bool NeedSymbolicMark;
bool UseLinkScript;
bool ForceUnixPaths;
bool ToolSupportsColor;
bool InstallTargetEnabled;
2016-03-13 13:35:51 +01:00
bool ConfigureDoneCMP0026AndCMP0024;
};
#endif