2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2002-08-30 20:00:35 +00:00
|
|
|
#ifndef cmGlobalGenerator_h
|
|
|
|
#define cmGlobalGenerator_h
|
|
|
|
|
2016-09-01 18:05:48 +00:00
|
|
|
#include <cmConfigure.h>
|
|
|
|
|
2016-09-01 18:59:28 +00:00
|
|
|
#include "cmExportSetMap.h"
|
2015-05-24 09:50:55 +00:00
|
|
|
#include "cmState.h"
|
2016-09-01 18:59:28 +00:00
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmTarget.h"
|
|
|
|
#include "cmTargetDepend.h"
|
2016-10-05 13:46:20 +00:00
|
|
|
#include "cm_codecvt.hxx"
|
2016-09-01 18:59:28 +00:00
|
|
|
|
|
|
|
#include <iosfwd>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
2012-09-24 20:06:20 +00:00
|
|
|
|
2014-04-30 19:40:39 +00:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
2016-05-16 14:34:04 +00:00
|
|
|
#include "cmFileLockPool.h"
|
2016-06-22 22:16:15 +00:00
|
|
|
#ifdef CMake_HAVE_CXX_UNORDERED_MAP
|
2016-05-16 14:34:04 +00:00
|
|
|
#include <unordered_map>
|
|
|
|
#else
|
|
|
|
#include <cmsys/hash_map.hxx>
|
|
|
|
#endif
|
2014-04-30 19:40:39 +00:00
|
|
|
#endif
|
|
|
|
|
2016-09-01 18:59:28 +00:00
|
|
|
class cmCustomCommandLines;
|
|
|
|
class cmSourceFile;
|
|
|
|
class cmExportBuildFileGenerator;
|
|
|
|
class cmExternalMakefileProjectGenerator;
|
2012-03-07 16:50:41 +00:00
|
|
|
class cmGeneratorTarget;
|
2002-08-30 20:00:35 +00:00
|
|
|
class cmLocalGenerator;
|
2016-10-08 10:21:36 +00:00
|
|
|
class cmLinkLineComputer;
|
2016-09-01 18:59:28 +00:00
|
|
|
class cmMakefile;
|
2016-10-08 10:21:38 +00:00
|
|
|
class cmOutputConverter;
|
2016-09-01 18:59:28 +00:00
|
|
|
class cmake;
|
2002-08-30 20:00:35 +00:00
|
|
|
|
|
|
|
/** \class cmGlobalGenerator
|
2014-10-09 23:22:45 +00:00
|
|
|
* \brief Responsible for overseeing the generation process for the entire tree
|
2002-08-30 20:00:35 +00:00
|
|
|
*
|
|
|
|
* Subclasses of this class generate makefiles for various
|
|
|
|
* platforms.
|
|
|
|
*/
|
|
|
|
class cmGlobalGenerator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
///! Free any memory allocated with the GlobalGenerator
|
2015-05-24 09:31:14 +00:00
|
|
|
cmGlobalGenerator(cmake* cm);
|
2002-08-30 20:00:35 +00:00
|
|
|
virtual ~cmGlobalGenerator();
|
2010-11-11 21:02:07 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
|
2002-08-30 20:00:35 +00:00
|
|
|
|
|
|
|
///! Get the name for this generator
|
2014-04-03 19:35:22 +00:00
|
|
|
virtual std::string GetName() const { return "Generic"; }
|
2010-11-11 21:02:07 +00:00
|
|
|
|
2013-10-28 14:08:11 +00:00
|
|
|
/** Check whether the given name matches the current generator. */
|
2014-02-24 22:36:27 +00:00
|
|
|
virtual bool MatchesGeneratorName(const std::string& name) const
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
|
|
|
return this->GetName() == name;
|
|
|
|
}
|
2013-10-28 14:08:11 +00:00
|
|
|
|
2016-10-05 13:46:20 +00:00
|
|
|
/** Get encoding used by generator for makefile files */
|
|
|
|
virtual codecvt::Encoding GetMakefileEncoding() const
|
|
|
|
{
|
|
|
|
return codecvt::None;
|
|
|
|
}
|
|
|
|
|
2014-07-17 19:05:17 +00:00
|
|
|
/** Tell the generator about the target system. */
|
2016-05-16 14:34:04 +00:00
|
|
|
virtual bool SetSystemName(std::string const&, cmMakefile*) { return true; }
|
2014-07-17 19:05:17 +00:00
|
|
|
|
2014-09-05 18:25:27 +00: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);
|
|
|
|
|
2012-12-10 15:42:33 +00:00
|
|
|
/** Set the generator-specific toolset name. Returns true if toolset
|
|
|
|
is supported and false otherwise. */
|
2014-06-04 17:21:55 +00:00
|
|
|
virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
|
2012-12-10 15:42:33 +00:00
|
|
|
|
2002-08-30 20:00:35 +00:00
|
|
|
/**
|
|
|
|
* Create LocalGenerators and process the CMakeLists files. This does not
|
2010-11-11 21:02:07 +00:00
|
|
|
* actually produce any makefiles, DSPs, etc.
|
2002-08-30 20:00:35 +00:00
|
|
|
*/
|
|
|
|
virtual void Configure();
|
|
|
|
|
2015-09-15 18:50:11 +00:00
|
|
|
bool Compute();
|
2015-09-15 18:37:57 +00:00
|
|
|
virtual void AddExtraIDETargets() {}
|
2015-07-25 18:44:35 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
enum TargetTypes
|
|
|
|
{
|
2015-07-25 18:44:35 +00:00
|
|
|
AllTargets,
|
|
|
|
ImportedOnly
|
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void CreateImportedGenerationObjects(
|
|
|
|
cmMakefile* mf, std::vector<std::string> const& targets,
|
|
|
|
std::vector<cmGeneratorTarget const*>& exports);
|
2015-07-25 18:44:35 +00:00
|
|
|
void CreateGenerationObjects(TargetTypes targetTypes = AllTargets);
|
2015-07-25 18:00:27 +00:00
|
|
|
|
2002-08-30 20:00:35 +00:00
|
|
|
/**
|
|
|
|
* Generate the all required files for building this project/tree. This
|
|
|
|
* basically creates a series of LocalGenerators for each directory and
|
2010-11-11 21:02:07 +00:00
|
|
|
* requests that they Generate.
|
2002-08-30 20:00:35 +00:00
|
|
|
*/
|
2015-07-25 16:43:28 +00:00
|
|
|
virtual void Generate();
|
2002-08-30 20:00:35 +00:00
|
|
|
|
2016-10-08 10:21:36 +00:00
|
|
|
virtual cmLinkLineComputer* CreateLinkLineComputer(
|
2016-10-08 10:21:38 +00:00
|
|
|
cmOutputConverter* outputConverter, cmState::Directory stateDir) const;
|
2016-10-08 10:21:36 +00:00
|
|
|
|
|
|
|
cmLinkLineComputer* CreateMSVC60LinkLineComputer(
|
2016-10-08 10:21:38 +00:00
|
|
|
cmOutputConverter* outputConverter, cmState::Directory stateDir) const;
|
2016-10-08 10:21:36 +00:00
|
|
|
|
2002-08-30 20:00:35 +00:00
|
|
|
/**
|
2010-11-11 21:02:07 +00:00
|
|
|
* Set/Get and Clear the enabled languages.
|
2002-08-30 20:00:35 +00:00
|
|
|
*/
|
2014-02-04 02:20:56 +00:00
|
|
|
void SetLanguageEnabled(const std::string&, cmMakefile* mf);
|
|
|
|
bool GetLanguageEnabled(const std::string&) const;
|
2002-08-30 20:00:35 +00:00
|
|
|
void ClearEnabledLanguages();
|
2014-01-10 12:21:15 +00:00
|
|
|
void GetEnabledLanguages(std::vector<std::string>& lang) const;
|
2002-08-30 20:00:35 +00:00
|
|
|
/**
|
2014-10-09 23:22:45 +00:00
|
|
|
* Try to determine system information such as shared library
|
2010-11-11 21:02:07 +00:00
|
|
|
* extension, pthreads, byte order etc.
|
2002-08-30 20:00:35 +00:00
|
|
|
*/
|
2016-05-16 14:34:04 +00:00
|
|
|
virtual void EnableLanguage(std::vector<std::string> const& languages,
|
|
|
|
cmMakefile*, bool optional);
|
2002-08-30 20:00:35 +00:00
|
|
|
|
2011-09-10 02:52:53 +00:00
|
|
|
/**
|
|
|
|
* Resolve the CMAKE_<lang>_COMPILER setting for the given language.
|
|
|
|
* Intended to be called from EnableLanguage.
|
|
|
|
*/
|
2016-05-16 14:34:04 +00:00
|
|
|
void ResolveLanguageCompiler(const std::string& lang, cmMakefile* mf,
|
2014-01-10 12:51:29 +00:00
|
|
|
bool optional) const;
|
2011-09-10 02:52:53 +00:00
|
|
|
|
2002-09-13 14:42:50 +00:00
|
|
|
/**
|
2014-10-09 23:22:45 +00:00
|
|
|
* Try to determine system information, get it from another generator
|
2002-09-13 14:42:50 +00:00
|
|
|
*/
|
2016-05-16 14:34:04 +00:00
|
|
|
void EnableLanguagesFromGenerator(cmGlobalGenerator* gen, cmMakefile* mf);
|
2002-09-13 14:42:50 +00:00
|
|
|
|
2002-08-30 20:00:35 +00:00
|
|
|
/**
|
2011-03-19 10:41:00 +00:00
|
|
|
* Try running cmake and building a file. This is used for dynamically
|
2002-08-30 20:00:35 +00:00
|
|
|
* loaded commands, not as part of the usual build process.
|
|
|
|
*/
|
2015-05-23 12:52:55 +00:00
|
|
|
int TryCompile(const std::string& srcdir, const std::string& bindir,
|
2016-05-16 14:34:04 +00:00
|
|
|
const std::string& projectName, const std::string& targetName,
|
|
|
|
bool fast, std::string& output, cmMakefile* mf);
|
2010-11-11 21:02:07 +00:00
|
|
|
|
2005-02-22 14:12:10 +00: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.
|
|
|
|
*/
|
2014-02-24 22:38:30 +00:00
|
|
|
int Build(const std::string& srcdir, const std::string& bindir,
|
2014-02-07 20:40:05 +00:00
|
|
|
const std::string& projectName, const std::string& targetName,
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string& output, const std::string& makeProgram,
|
|
|
|
const std::string& config, bool clean, bool fast, bool verbose,
|
|
|
|
double timeout, cmSystemTools::OutputOption outputflag =
|
|
|
|
cmSystemTools::OUTPUT_NONE,
|
2009-03-04 20:38:47 +00:00
|
|
|
std::vector<std::string> const& nativeOptions =
|
2016-05-16 14:34:04 +00:00
|
|
|
std::vector<std::string>());
|
2010-11-11 21:02:07 +00:00
|
|
|
|
2013-11-15 18:33:32 +00:00
|
|
|
virtual void GenerateBuildCommand(
|
2016-05-16 14:34:04 +00:00
|
|
|
std::vector<std::string>& makeCommand, const std::string& makeProgram,
|
2014-02-24 22:38:30 +00:00
|
|
|
const std::string& projectName, const std::string& projectDir,
|
2016-05-16 14:34:04 +00:00
|
|
|
const std::string& targetName, const std::string& config, bool fast,
|
|
|
|
bool verbose,
|
|
|
|
std::vector<std::string> const& makeOptions = std::vector<std::string>());
|
2010-11-11 21:02:07 +00:00
|
|
|
|
2013-11-13 20:59:32 +00:00
|
|
|
/** Generate a "cmake --build" call for a given target and config. */
|
2014-02-06 22:31:47 +00:00
|
|
|
std::string GenerateCMakeBuildCommand(const std::string& target,
|
2014-02-10 03:48:34 +00:00
|
|
|
const std::string& config,
|
2014-02-22 00:05:55 +00:00
|
|
|
const std::string& native,
|
2013-11-13 20:59:32 +00:00
|
|
|
bool ignoreErrors);
|
2005-02-22 14:12:10 +00:00
|
|
|
|
2002-08-30 20:00:35 +00:00
|
|
|
///! Get the CMake instance
|
2016-05-16 14:34:04 +00:00
|
|
|
cmake* GetCMakeInstance() const { return this->CMakeInstance; }
|
2006-03-15 16:02:08 +00:00
|
|
|
|
2009-08-03 17:37:36 +00:00
|
|
|
void SetConfiguredFilesPath(cmGlobalGenerator* gen);
|
2016-05-16 14:34:04 +00:00
|
|
|
const std::vector<cmMakefile*>& GetMakefiles() const
|
|
|
|
{
|
|
|
|
return this->Makefiles;
|
|
|
|
}
|
|
|
|
const std::vector<cmLocalGenerator*>& GetLocalGenerators() const
|
2015-05-30 21:50:28 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
return this->LocalGenerators;
|
2015-05-30 21:50:28 +00:00
|
|
|
}
|
2007-07-17 13:25:08 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmMakefile* GetCurrentMakefile() const { return this->CurrentMakefile; }
|
|
|
|
|
|
|
|
void SetCurrentMakefile(cmMakefile* mf) { this->CurrentMakefile = mf; }
|
2007-07-17 13:25:08 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void AddMakefile(cmMakefile* mf);
|
2006-03-30 18:33:48 +00:00
|
|
|
|
2007-06-08 15:57:16 +00:00
|
|
|
///! Set an generator for an "external makefile based project"
|
|
|
|
void SetExternalMakefileProjectGenerator(
|
2016-05-16 14:34:04 +00:00
|
|
|
cmExternalMakefileProjectGenerator* extraGenerator);
|
2007-06-08 15:57:16 +00:00
|
|
|
|
2014-02-24 22:36:27 +00:00
|
|
|
std::string GetExtraGeneratorName() const;
|
2007-06-08 15:57:16 +00:00
|
|
|
|
2006-03-30 18:33:48 +00:00
|
|
|
void AddInstallComponent(const char* component);
|
2007-06-19 17:10:21 +00:00
|
|
|
|
2014-02-10 05:21:34 +00:00
|
|
|
const std::set<std::string>* GetInstallComponents() const
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
|
|
|
return &this->InstallComponents;
|
|
|
|
}
|
2008-07-08 15:52:25 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmExportSetMap& GetExportSets() { return this->ExportSets; }
|
2007-06-19 17:10:21 +00:00
|
|
|
|
cmGlobalGenerator: Add API to get settings from top-level cmMakefile
At generate-time, definitions are sometimes read from a nearby cmMakefile,
making the value directory-specific because they are read once per
directory. Often however, the intention is more
often to create a 'global' setting, such that the user writes for
example:
set(CMAKE_IMPORT_LIBRARY_SUFFIX something)
once at the top level of their project.
Many of these are also set by internal platform files, such as
CMAKE_EXTRA_LINK_EXTENSIONS.
The set() definitions are not really suitable for 'global' settings
because they can be different for each directory, and code consuming the
settings must assume they are different for each directory, and read it
freshly each time with new allocations.
CMake has other variable types which are global in scope, such as global
properties, and cache variables. These are less convenient to populate
for users, so establish a convention and API using the value as it is at
the end of the top-level CMakeLists file.
2016-10-06 16:01:36 +00:00
|
|
|
const char* GetGlobalSetting(std::string const& name) const;
|
|
|
|
bool GlobalSettingIsOn(std::string const& name) const;
|
|
|
|
const char* GetSafeGlobalSetting(std::string const& name) const;
|
|
|
|
|
2008-01-22 14:13:04 +00:00
|
|
|
/** Add a file to the manifest of generated targets for a configuration. */
|
2015-07-25 17:10:44 +00:00
|
|
|
void AddToManifest(std::string const& f);
|
2008-01-22 14:13:04 +00:00
|
|
|
|
2006-08-31 14:47:00 +00:00
|
|
|
void EnableInstallTarget();
|
2007-06-19 17:10:21 +00:00
|
|
|
|
2007-01-30 16:35:17 +00:00
|
|
|
int TryCompileTimeout;
|
2010-11-11 21:02:07 +00:00
|
|
|
|
2011-03-26 13:52:19 +00:00
|
|
|
bool GetForceUnixPaths() const { return this->ForceUnixPaths; }
|
|
|
|
bool GetToolSupportsColor() const { return this->ToolSupportsColor; }
|
2007-06-08 15:57:16 +00:00
|
|
|
|
2004-09-03 16:03:41 +00:00
|
|
|
///! return the language for the given extension
|
2014-02-04 02:20:56 +00:00
|
|
|
std::string GetLanguageFromExtension(const char* ext) const;
|
2004-09-22 18:42:05 +00:00
|
|
|
///! is an extension to be ignored
|
2014-01-10 12:21:15 +00:00
|
|
|
bool IgnoreFile(const char* ext) const;
|
2014-10-09 23:22:45 +00:00
|
|
|
///! What is the preference for linkers and this language (None or Preferred)
|
2014-02-04 02:20:56 +00:00
|
|
|
int GetLinkerPreference(const std::string& lang) const;
|
2007-06-18 15:59:23 +00:00
|
|
|
///! What is the object file extension for a given source file?
|
2014-02-04 02:20:56 +00:00
|
|
|
std::string GetLanguageOutputExtension(cmSourceFile const&) const;
|
2005-02-24 21:04:54 +00:00
|
|
|
|
2006-02-24 22:35:35 +00:00
|
|
|
///! What is the configurations directory variable called?
|
2012-03-08 21:18:55 +00:00
|
|
|
virtual const char* GetCMakeCFGIntDir() const { return "."; }
|
2006-02-24 22:35:35 +00:00
|
|
|
|
2014-02-02 04:18:04 +00:00
|
|
|
///! expand CFGIntDir for a configuration
|
|
|
|
virtual std::string ExpandCFGIntDir(const std::string& str,
|
|
|
|
const std::string& config) const;
|
|
|
|
|
2006-06-15 20:17:11 +00:00
|
|
|
/** Get whether the generator should use a script for link commands. */
|
2011-03-26 13:52:19 +00:00
|
|
|
bool GetUseLinkScript() const { return this->UseLinkScript; }
|
2006-06-15 20:17:11 +00:00
|
|
|
|
2006-10-02 14:20:53 +00:00
|
|
|
/** Get whether the generator should produce special marks on rules
|
|
|
|
producing symbolic (non-file) outputs. */
|
2011-03-26 13:52:19 +00:00
|
|
|
bool GetNeedSymbolicMark() const { return this->NeedSymbolicMark; }
|
2006-10-02 14:20:53 +00:00
|
|
|
|
2005-05-02 19:50:42 +00:00
|
|
|
/*
|
|
|
|
* Determine what program to use for building the project.
|
|
|
|
*/
|
2013-11-15 15:41:45 +00:00
|
|
|
virtual void FindMakeProgram(cmMakefile*);
|
2005-05-02 19:50:42 +00:00
|
|
|
|
2005-06-20 18:00:48 +00:00
|
|
|
///! Find a target by name by searching the local generators.
|
2014-02-08 16:39:22 +00:00
|
|
|
cmTarget* FindTarget(const std::string& name,
|
2013-11-19 10:48:19 +00:00
|
|
|
bool excludeAliases = false) const;
|
2013-07-12 07:14:31 +00:00
|
|
|
|
2015-10-25 12:06:59 +00:00
|
|
|
cmGeneratorTarget* FindGeneratorTarget(const std::string& name) const;
|
|
|
|
|
2015-10-25 11:43:00 +00:00
|
|
|
void AddAlias(const std::string& name, const std::string& tgtName);
|
2014-02-06 22:31:47 +00:00
|
|
|
bool IsAlias(const std::string& name) const;
|
2005-06-20 18:00:48 +00:00
|
|
|
|
2007-10-10 15:06:15 +00:00
|
|
|
/** Determine if a name resolves to a framework on disk or a built target
|
|
|
|
that is a framework. */
|
2013-11-19 10:48:19 +00:00
|
|
|
bool NameResolvesToFramework(const std::string& libname) const;
|
2007-10-10 15:06:15 +00:00
|
|
|
|
2015-08-02 10:39:51 +00:00
|
|
|
cmMakefile* FindMakefile(const std::string& start_dir) const;
|
2005-09-13 14:39:42 +00:00
|
|
|
///! Find a local generator by its startdirectory
|
2014-02-06 22:31:47 +00:00
|
|
|
cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const;
|
2005-09-13 14:39:42 +00:00
|
|
|
|
2006-03-03 17:58:48 +00:00
|
|
|
/** 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. */
|
2014-02-22 00:05:55 +00:00
|
|
|
virtual void AppendDirectoryForConfig(const std::string& prefix,
|
2014-02-10 03:48:34 +00:00
|
|
|
const std::string& config,
|
2014-02-22 00:05:55 +00:00
|
|
|
const std::string& suffix,
|
2006-03-03 17:58:48 +00:00
|
|
|
std::string& dir);
|
2006-02-03 16:36:11 +00:00
|
|
|
|
2014-12-08 20:12:51 +00: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
|
2008-09-22 14:56:48 +00:00
|
|
|
they do not yet exist. */
|
2014-02-10 05:21:34 +00:00
|
|
|
std::set<std::string> const& GetDirectoryContent(std::string const& dir,
|
2008-09-22 14:56:48 +00:00
|
|
|
bool needDisk = true);
|
2008-01-22 14:13:04 +00:00
|
|
|
|
2016-02-08 17:37:47 +00:00
|
|
|
void IndexTarget(cmTarget* t);
|
2016-02-08 17:50:56 +00:00
|
|
|
void IndexGeneratorTarget(cmGeneratorTarget* gt);
|
2016-02-08 17:37:47 +00:00
|
|
|
|
2013-11-16 10:07:24 +00:00
|
|
|
static bool IsReservedTarget(std::string const& name);
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
virtual const char* GetAllTargetName() const { return "ALL_BUILD"; }
|
|
|
|
virtual const char* GetInstallTargetName() const { return "INSTALL"; }
|
2016-06-27 20:44:16 +00:00
|
|
|
virtual const char* GetInstallLocalTargetName() const { return CM_NULLPTR; }
|
|
|
|
virtual const char* GetInstallStripTargetName() const { return CM_NULLPTR; }
|
|
|
|
virtual const char* GetPreinstallTargetName() const { return CM_NULLPTR; }
|
2016-05-16 14:34:04 +00:00
|
|
|
virtual const char* GetTestTargetName() const { return "RUN_TESTS"; }
|
|
|
|
virtual const char* GetPackageTargetName() const { return "PACKAGE"; }
|
2016-06-27 20:44:16 +00:00
|
|
|
virtual const char* GetPackageSourceTargetName() const { return CM_NULLPTR; }
|
|
|
|
virtual const char* GetEditCacheTargetName() const { return CM_NULLPTR; }
|
|
|
|
virtual const char* GetRebuildCacheTargetName() const { return CM_NULLPTR; }
|
|
|
|
virtual const char* GetCleanTargetName() const { return CM_NULLPTR; }
|
2006-04-10 17:44:39 +00:00
|
|
|
|
2013-11-12 13:44:08 +00:00
|
|
|
// Lookup edit_cache target command preferred by this generator.
|
|
|
|
virtual std::string GetEditCacheCommand() const { return ""; }
|
|
|
|
|
2007-12-23 20:03:42 +00:00
|
|
|
// Class to track a set of dependencies.
|
2010-08-25 14:07:25 +00:00
|
|
|
typedef cmTargetDependSet TargetDependSet;
|
2007-12-23 20:03:42 +00:00
|
|
|
|
2008-01-30 17:04:38 +00:00
|
|
|
// what targets does the specified target depend on directly
|
|
|
|
// via a target_link_libraries or add_dependencies
|
2015-06-06 11:08:17 +00:00
|
|
|
TargetDependSet const& GetTargetDirectDepends(
|
2016-05-16 14:34:04 +00:00
|
|
|
const cmGeneratorTarget* target);
|
2007-04-12 19:46:14 +00:00
|
|
|
|
2014-02-10 05:21:34 +00:00
|
|
|
const std::map<std::string, std::vector<cmLocalGenerator*> >& GetProjectMap()
|
2016-05-16 14:34:04 +00:00
|
|
|
const
|
|
|
|
{
|
|
|
|
return this->ProjectMap;
|
|
|
|
}
|
2007-11-16 12:01:58 +00:00
|
|
|
|
|
|
|
// track files replaced during a Generate
|
|
|
|
void FileReplacedDuringGenerate(const std::string& filename);
|
|
|
|
void GetFilesReplacedDuringGenerate(std::vector<std::string>& filenames);
|
|
|
|
|
2008-06-02 20:44:58 +00:00
|
|
|
void AddRuleHash(const std::vector<std::string>& outputs,
|
2009-02-02 18:28:12 +00:00
|
|
|
std::string const& content);
|
2008-06-02 20:44:58 +00:00
|
|
|
|
2009-02-27 16:23:14 +00:00
|
|
|
/** Return whether the given binary directory is unused. */
|
2014-02-07 20:33:35 +00:00
|
|
|
bool BinaryDirectoryIsNew(const std::string& dir)
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
2009-02-27 16:23:14 +00:00
|
|
|
return this->BinaryDirectories.insert(dir).second;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2009-02-27 16:23:14 +00:00
|
|
|
|
2009-12-04 17:09:01 +00: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-05-31 11:53:19 +00:00
|
|
|
virtual bool IsMultiConfig() const { return false; }
|
2009-12-04 17:09:01 +00:00
|
|
|
|
2016-08-30 18:55:37 +00:00
|
|
|
virtual bool UseFolderProperty() const;
|
|
|
|
|
2014-01-10 12:21:15 +00:00
|
|
|
std::string GetSharedLibFlagsForLanguage(std::string const& lang) const;
|
2012-05-30 18:13:09 +00:00
|
|
|
|
2012-04-18 19:28:12 +00:00
|
|
|
/** Generate an <output>.rule file path for a given command output. */
|
|
|
|
virtual std::string GenerateRuleFile(std::string const& output) const;
|
|
|
|
|
2012-05-06 13:07:19 +00:00
|
|
|
static std::string EscapeJSON(const std::string& s);
|
|
|
|
|
2013-01-02 16:10:04 +00:00
|
|
|
void ProcessEvaluationFiles();
|
|
|
|
|
2012-10-06 15:27:40 +00:00
|
|
|
std::map<std::string, cmExportBuildFileGenerator*>& GetBuildExportSets()
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
|
|
|
return this->BuildExportSets;
|
|
|
|
}
|
2012-10-06 15:27:40 +00:00
|
|
|
void AddBuildExportSet(cmExportBuildFileGenerator*);
|
2013-12-26 13:34:27 +00:00
|
|
|
void AddBuildExportExportSet(cmExportBuildFileGenerator*);
|
2016-05-16 14:34:04 +00:00
|
|
|
bool IsExportedTargetsFile(const std::string& filename) const;
|
|
|
|
bool GenerateImportFile(const std::string& file);
|
|
|
|
cmExportBuildFileGenerator* GetExportedTargetsFile(
|
|
|
|
const std::string& filename) const;
|
2013-12-19 04:25:29 +00:00
|
|
|
void AddCMP0042WarnTarget(const std::string& target);
|
|
|
|
|
2014-03-12 20:09:20 +00:00
|
|
|
virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
|
|
|
|
|
2014-05-15 17:12:40 +00:00
|
|
|
bool GenerateCPackPropertiesFile();
|
|
|
|
|
2014-11-04 22:24:54 +00:00
|
|
|
void CreateEvaluationSourceFiles(std::string const& config) const;
|
|
|
|
|
2016-05-26 19:58:51 +00:00
|
|
|
void SetFilenameTargetDepends(
|
|
|
|
cmSourceFile* sf, std::set<cmGeneratorTarget const*> const& tgts);
|
2016-05-16 14:34:04 +00:00
|
|
|
const std::set<const cmGeneratorTarget*>& GetFilenameTargetDepends(
|
|
|
|
cmSourceFile* sf) const;
|
2014-11-04 22:24:54 +00:00
|
|
|
|
2014-11-25 22:49:25 +00:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
cmFileLockPool& GetFileLockPool() { return FileLockPool; }
|
|
|
|
#endif
|
|
|
|
|
2015-09-16 20:08:22 +00:00
|
|
|
bool GetConfigureDoneCMP0026() const
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
|
|
|
return this->ConfigureDoneCMP0026AndCMP0024;
|
|
|
|
}
|
2015-09-16 20:08:22 +00:00
|
|
|
|
2015-05-16 03:23:06 +00:00
|
|
|
std::string MakeSilentFlag;
|
2016-05-16 14:34:04 +00:00
|
|
|
|
2002-08-30 20:00:35 +00:00
|
|
|
protected:
|
2009-10-01 14:26:54 +00:00
|
|
|
typedef std::vector<cmLocalGenerator*> GeneratorVector;
|
2008-01-30 17:04:38 +00:00
|
|
|
// for a project collect all its targets by following depend
|
|
|
|
// information, and also collect all the targets
|
2015-05-23 12:52:55 +00:00
|
|
|
void GetTargetSets(TargetDependSet& projectTargets,
|
2016-05-16 14:34:04 +00:00
|
|
|
TargetDependSet& originalTargets, cmLocalGenerator* root,
|
|
|
|
GeneratorVector const&);
|
2015-10-18 22:41:14 +00:00
|
|
|
bool IsRootOnlyTarget(cmGeneratorTarget* target) const;
|
2015-06-06 11:08:17 +00:00
|
|
|
void AddTargetDepends(const cmGeneratorTarget* target,
|
2013-12-10 14:16:23 +00:00
|
|
|
TargetDependSet& projectTargets);
|
2014-02-04 02:20:56 +00: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-09-21 17:52:01 +00:00
|
|
|
virtual bool CheckLanguages(std::vector<std::string> const& languages,
|
|
|
|
cmMakefile* mf) const;
|
2015-08-05 21:23:07 +00:00
|
|
|
virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
|
|
|
|
const char* envVar) const;
|
2007-06-11 19:31:42 +00:00
|
|
|
|
2010-08-24 22:12:44 +00:00
|
|
|
virtual bool ComputeTargetDepends();
|
|
|
|
|
2014-01-10 12:35:58 +00:00
|
|
|
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const;
|
2008-02-14 21:42:29 +00:00
|
|
|
|
2015-10-05 17:21:59 +00:00
|
|
|
std::vector<const cmGeneratorTarget*> CreateQtAutoGeneratorsTargets();
|
2011-08-15 23:45:05 +00:00
|
|
|
|
2014-02-24 22:38:55 +00:00
|
|
|
std::string SelectMakeProgram(const std::string& makeProgram,
|
|
|
|
const std::string& makeDefault = "") const;
|
2008-05-12 21:43:45 +00:00
|
|
|
|
2010-11-11 21:02:07 +00:00
|
|
|
// Fill the ProjectMap, this must be called after LocalGenerators
|
2006-03-10 18:54:57 +00:00
|
|
|
// has been populated.
|
2005-01-21 17:26:32 +00:00
|
|
|
void FillProjectMap();
|
2015-08-02 10:44:07 +00:00
|
|
|
void CheckTargetProperties();
|
2015-08-02 07:58:57 +00:00
|
|
|
bool IsExcluded(cmState::Snapshot const& root,
|
|
|
|
cmState::Snapshot const& snp) const;
|
2014-01-10 12:21:15 +00:00
|
|
|
bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const;
|
2015-06-06 12:09:35 +00:00
|
|
|
bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const;
|
2015-08-02 08:23:12 +00:00
|
|
|
virtual void InitializeProgressMarks() {}
|
2016-09-15 19:56:49 +00: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);
|
2006-02-23 15:07:24 +00:00
|
|
|
|
2014-02-10 05:21:34 +00:00
|
|
|
std::string FindMakeProgramFile;
|
|
|
|
std::string ConfiguredFilesPath;
|
2016-05-16 14:34:04 +00:00
|
|
|
cmake* CMakeInstance;
|
2015-08-02 18:21:22 +00:00
|
|
|
std::vector<cmMakefile*> Makefiles;
|
2016-05-16 14:34:04 +00:00
|
|
|
std::vector<cmLocalGenerator*> LocalGenerators;
|
2015-05-30 21:50:28 +00:00
|
|
|
cmMakefile* CurrentMakefile;
|
2005-01-21 17:26:32 +00:00
|
|
|
// map from project name to vector of local generators in that project
|
2014-02-10 05:21:34 +00:00
|
|
|
std::map<std::string, std::vector<cmLocalGenerator*> > ProjectMap;
|
2002-08-30 20:00:35 +00:00
|
|
|
|
2006-03-30 18:33:48 +00:00
|
|
|
// Set of named installation components requested by the project.
|
2014-02-10 05:21:34 +00:00
|
|
|
std::set<std::string> InstallComponents;
|
2007-06-19 17:10:21 +00:00
|
|
|
// Sets of named target exports
|
2012-02-29 22:02:56 +00:00
|
|
|
cmExportSetMap ExportSets;
|
2012-10-06 15:27:40 +00:00
|
|
|
std::map<std::string, cmExportBuildFileGenerator*> BuildExportSets;
|
2013-12-26 13:34:27 +00:00
|
|
|
std::map<std::string, cmExportBuildFileGenerator*> BuildExportExportSets;
|
2006-03-30 18:33:48 +00:00
|
|
|
|
2015-10-25 11:43:00 +00:00
|
|
|
std::map<std::string, std::string> AliasTargets;
|
2015-10-25 11:22:51 +00:00
|
|
|
|
|
|
|
cmTarget* FindTargetImpl(std::string const& name) const;
|
2009-07-10 20:51:44 +00:00
|
|
|
|
2015-10-25 12:06:59 +00:00
|
|
|
cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const;
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorTarget* FindImportedGeneratorTargetImpl(
|
|
|
|
std::string const& name) const;
|
2015-10-25 12:06:59 +00:00
|
|
|
|
2015-05-23 12:52:55 +00:00
|
|
|
const char* GetPredefinedTargetsFolder();
|
2010-09-03 17:53:22 +00:00
|
|
|
|
2002-08-30 20:00:35 +00:00
|
|
|
private:
|
2016-02-08 17:37:47 +00:00
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
2016-06-22 22:16:15 +00:00
|
|
|
#ifdef CMake_HAVE_CXX_UNORDERED_MAP
|
2016-02-08 17:37:47 +00:00
|
|
|
typedef std::unordered_map<std::string, cmTarget*> TargetMap;
|
2016-02-08 17:50:56 +00:00
|
|
|
typedef std::unordered_map<std::string, cmGeneratorTarget*>
|
|
|
|
GeneratorTargetMap;
|
2016-09-26 19:29:53 +00:00
|
|
|
typedef std::unordered_map<std::string, cmMakefile*> MakefileMap;
|
2016-05-16 14:34:04 +00:00
|
|
|
#else
|
2016-02-08 17:37:47 +00:00
|
|
|
typedef cmsys::hash_map<std::string, cmTarget*> TargetMap;
|
2016-02-08 17:50:56 +00:00
|
|
|
typedef cmsys::hash_map<std::string, cmGeneratorTarget*> GeneratorTargetMap;
|
2016-09-26 19:29:53 +00:00
|
|
|
typedef cmsys::hash_map<std::string, cmMakefile*> MakefileMap;
|
2016-05-16 14:34:04 +00:00
|
|
|
#endif
|
2016-02-08 17:37:47 +00:00
|
|
|
#else
|
2016-05-16 14:34:04 +00:00
|
|
|
typedef std::map<std::string, cmTarget*> TargetMap;
|
|
|
|
typedef std::map<std::string, cmGeneratorTarget*> GeneratorTargetMap;
|
2016-09-26 19:29:53 +00:00
|
|
|
typedef std::map<std::string, cmMakefile*> MakefileMap;
|
2016-02-08 17:37:47 +00:00
|
|
|
#endif
|
|
|
|
// 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;
|
2016-02-08 17:50:56 +00:00
|
|
|
GeneratorTargetMap GeneratorTargetSearchIndex;
|
2016-02-08 17:37:47 +00:00
|
|
|
|
2016-09-26 19:29:53 +00: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;
|
|
|
|
|
2011-01-24 15:00:45 +00:00
|
|
|
cmMakefile* TryCompileOuterMakefile;
|
2004-09-22 18:42:05 +00:00
|
|
|
// If you add a new map here, make sure it is copied
|
2010-11-11 21:02:07 +00:00
|
|
|
// in EnableLanguagesFromGenerator
|
2014-02-10 05:21:34 +00:00
|
|
|
std::map<std::string, bool> IgnoreExtensions;
|
|
|
|
std::set<std::string> LanguagesReady; // Ready for try_compile
|
2016-03-07 18:31:25 +00:00
|
|
|
std::set<std::string> LanguagesInProgress;
|
2014-02-10 05:21:34 +00: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;
|
2005-02-24 21:04:54 +00:00
|
|
|
|
2008-06-02 20:44:58 +00:00
|
|
|
// Record hashes for rules and outputs.
|
2016-05-16 14:34:04 +00:00
|
|
|
struct RuleHash
|
|
|
|
{
|
|
|
|
char Data[32];
|
|
|
|
};
|
2014-02-10 05:21:34 +00:00
|
|
|
std::map<std::string, RuleHash> RuleHashes;
|
2008-06-02 20:44:58 +00:00
|
|
|
void CheckRuleHashes();
|
2010-02-12 13:00:53 +00:00
|
|
|
void CheckRuleHashes(std::string const& pfile, std::string const& home);
|
|
|
|
void WriteRuleHashes(std::string const& pfile);
|
2008-06-02 20:44:58 +00:00
|
|
|
|
2009-03-09 16:19:27 +00:00
|
|
|
void WriteSummary();
|
2015-10-09 22:29:47 +00:00
|
|
|
void WriteSummary(cmGeneratorTarget* target);
|
2013-11-07 13:09:04 +00:00
|
|
|
void FinalizeTargetCompileInfo();
|
2009-02-10 13:50:21 +00:00
|
|
|
|
2014-03-19 08:11:11 +00:00
|
|
|
virtual void ForceLinkerLanguages();
|
|
|
|
|
2015-09-13 18:36:06 +00:00
|
|
|
void CreateLocalGenerators();
|
|
|
|
|
2014-02-04 02:20:56 +00:00
|
|
|
void CheckCompilerIdCompatibility(cmMakefile* mf,
|
|
|
|
std::string const& lang) const;
|
2013-10-02 18:10:38 +00:00
|
|
|
|
2015-10-17 11:29:46 +00:00
|
|
|
void ComputeBuildFileGenerators();
|
|
|
|
|
2007-06-08 15:57:16 +00:00
|
|
|
cmExternalMakefileProjectGenerator* ExtraGenerator;
|
2007-11-16 12:01:58 +00:00
|
|
|
|
|
|
|
// track files replaced during a Generate
|
|
|
|
std::vector<std::string> FilesReplacedDuringGenerate;
|
2007-12-23 20:03:42 +00:00
|
|
|
|
2008-02-06 04:10:41 +00:00
|
|
|
// Store computed inter-target dependencies.
|
2015-06-06 11:08:17 +00:00
|
|
|
typedef std::map<cmGeneratorTarget const*, TargetDependSet> TargetDependMap;
|
2007-12-23 20:03:42 +00:00
|
|
|
TargetDependMap TargetDependencies;
|
2008-01-22 14:13:04 +00:00
|
|
|
|
2014-01-11 13:17:03 +00:00
|
|
|
friend class cmake;
|
2016-05-16 14:34:04 +00:00
|
|
|
void CreateGeneratorTargets(
|
|
|
|
TargetTypes targetTypes, cmMakefile* mf, cmLocalGenerator* lg,
|
|
|
|
std::map<cmTarget*, cmGeneratorTarget*> const& importedMap);
|
2015-07-25 18:44:35 +00:00
|
|
|
void CreateGeneratorTargets(TargetTypes targetTypes);
|
2012-03-07 16:50:41 +00:00
|
|
|
|
2013-11-04 21:06:51 +00:00
|
|
|
void ClearGeneratorMembers();
|
|
|
|
|
2016-09-26 19:29:53 +00:00
|
|
|
void IndexMakefile(cmMakefile* mf);
|
|
|
|
|
2016-06-27 20:44:16 +00:00
|
|
|
virtual const char* GetBuildIgnoreErrorsFlag() const { return CM_NULLPTR; }
|
2013-11-13 20:59:32 +00:00
|
|
|
|
2008-01-22 14:13:04 +00:00
|
|
|
// Cache directory content and target files to be built.
|
2014-12-08 20:12:51 +00:00
|
|
|
struct DirectoryContent
|
2008-01-22 14:13:04 +00:00
|
|
|
{
|
2014-12-08 20:12:51 +00:00
|
|
|
long LastDiskTime;
|
|
|
|
std::set<std::string> All;
|
|
|
|
std::set<std::string> Generated;
|
2016-05-16 14:34:04 +00:00
|
|
|
DirectoryContent()
|
|
|
|
: LastDiskTime(-1)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
DirectoryContent(DirectoryContent const& dc)
|
|
|
|
: LastDiskTime(dc.LastDiskTime)
|
|
|
|
, All(dc.All)
|
|
|
|
, Generated(dc.Generated)
|
|
|
|
{
|
|
|
|
}
|
2008-01-22 14:13:04 +00:00
|
|
|
};
|
2014-02-10 05:21:34 +00:00
|
|
|
std::map<std::string, DirectoryContent> DirectoryContentMap;
|
2009-02-27 16:23:14 +00:00
|
|
|
|
|
|
|
// Set of binary directories on disk.
|
2014-02-10 05:21:34 +00:00
|
|
|
std::set<std::string> BinaryDirectories;
|
2013-12-19 04:25:29 +00:00
|
|
|
|
|
|
|
// track targets to issue CMP0042 warning for.
|
|
|
|
std::set<std::string> CMP0042WarnTargets;
|
2014-11-04 22:24:54 +00:00
|
|
|
|
2015-10-10 16:41:51 +00:00
|
|
|
mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*> >
|
2016-05-16 14:34:04 +00:00
|
|
|
FilenameTargetDepends;
|
2014-11-25 22:49:25 +00:00
|
|
|
|
|
|
|
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
|
|
|
// Pool of file locks
|
|
|
|
cmFileLockPool FileLockPool;
|
|
|
|
#endif
|
2015-06-07 07:47:37 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
float FirstTimeProgress;
|
|
|
|
bool NeedSymbolicMark;
|
|
|
|
bool UseLinkScript;
|
|
|
|
bool ForceUnixPaths;
|
|
|
|
bool ToolSupportsColor;
|
|
|
|
bool InstallTargetEnabled;
|
2015-09-16 20:08:22 +00:00
|
|
|
bool ConfigureDoneCMP0026AndCMP0024;
|
2002-08-30 20:00:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|