cmGlobalGenerator.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  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 cmGlobalGenerator_h
  4. #define cmGlobalGenerator_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <iosfwd>
  7. #include <map>
  8. #include <memory>
  9. #include <set>
  10. #include <string>
  11. #include <unordered_map>
  12. #include <utility>
  13. #include <vector>
  14. #include "cm_codecvt.hxx"
  15. #include "cmAlgorithms.h"
  16. #include "cmCustomCommandLines.h"
  17. #include "cmDuration.h"
  18. #include "cmExportSet.h"
  19. #include "cmStateSnapshot.h"
  20. #include "cmStringAlgorithms.h"
  21. #include "cmSystemTools.h"
  22. #include "cmTarget.h"
  23. #include "cmTargetDepend.h"
  24. #if !defined(CMAKE_BOOTSTRAP)
  25. # include "cm_jsoncpp_value.h"
  26. # include "cmFileLockPool.h"
  27. #endif
  28. #define CMAKE_DIRECTORY_ID_SEP "::@"
  29. class cmDirectoryId;
  30. class cmExportBuildFileGenerator;
  31. class cmExternalMakefileProjectGenerator;
  32. class cmGeneratorTarget;
  33. class cmLinkLineComputer;
  34. class cmLocalGenerator;
  35. class cmMakefile;
  36. class cmOutputConverter;
  37. class cmSourceFile;
  38. class cmStateDirectory;
  39. class cmake;
  40. namespace detail {
  41. inline void AppendStrs(std::vector<std::string>&)
  42. {
  43. }
  44. template <typename T, typename... Ts>
  45. inline void AppendStrs(std::vector<std::string>& command, T&& s, Ts&&... ts)
  46. {
  47. command.emplace_back(std::forward<T>(s));
  48. AppendStrs(command, std::forward<Ts>(ts)...);
  49. }
  50. struct GeneratedMakeCommand
  51. {
  52. // Add each argument as a separate element to the vector
  53. template <typename... T>
  54. void Add(T&&... args)
  55. {
  56. // iterate the args and append each one
  57. AppendStrs(PrimaryCommand, std::forward<T>(args)...);
  58. }
  59. // Add each value in the iterators as a separate element to the vector
  60. void Add(std::vector<std::string>::const_iterator start,
  61. std::vector<std::string>::const_iterator end)
  62. {
  63. cmAppend(PrimaryCommand, start, end);
  64. }
  65. std::string Printable() const { return cmJoin(PrimaryCommand, " "); }
  66. std::vector<std::string> PrimaryCommand;
  67. bool RequiresOutputForward = false;
  68. };
  69. }
  70. /** \class cmGlobalGenerator
  71. * \brief Responsible for overseeing the generation process for the entire tree
  72. *
  73. * Subclasses of this class generate makefiles for various
  74. * platforms.
  75. */
  76. class cmGlobalGenerator
  77. {
  78. public:
  79. //! Free any memory allocated with the GlobalGenerator
  80. cmGlobalGenerator(cmake* cm);
  81. virtual ~cmGlobalGenerator();
  82. virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf);
  83. //! Get the name for this generator
  84. virtual std::string GetName() const { return "Generic"; }
  85. /** Check whether the given name matches the current generator. */
  86. virtual bool MatchesGeneratorName(const std::string& name) const
  87. {
  88. return this->GetName() == name;
  89. }
  90. /** Get encoding used by generator for makefile files */
  91. virtual codecvt::Encoding GetMakefileEncoding() const
  92. {
  93. return codecvt::None;
  94. }
  95. #if !defined(CMAKE_BOOTSTRAP)
  96. /** Get a JSON object describing the generator. */
  97. virtual Json::Value GetJson() const;
  98. #endif
  99. /** Tell the generator about the target system. */
  100. virtual bool SetSystemName(std::string const&, cmMakefile*) { return true; }
  101. /** Set the generator-specific instance. Returns true if supported. */
  102. virtual bool SetGeneratorInstance(std::string const& i, cmMakefile* mf);
  103. /** Set the generator-specific platform name. Returns true if platform
  104. is supported and false otherwise. */
  105. virtual bool SetGeneratorPlatform(std::string const& p, cmMakefile* mf);
  106. /** Set the generator-specific toolset name. Returns true if toolset
  107. is supported and false otherwise. */
  108. virtual bool SetGeneratorToolset(std::string const& ts, cmMakefile* mf);
  109. /**
  110. * Create LocalGenerators and process the CMakeLists files. This does not
  111. * actually produce any makefiles, DSPs, etc.
  112. */
  113. virtual void Configure();
  114. bool Compute();
  115. virtual void AddExtraIDETargets() {}
  116. enum TargetTypes
  117. {
  118. AllTargets,
  119. ImportedOnly
  120. };
  121. void CreateImportedGenerationObjects(
  122. cmMakefile* mf, std::vector<std::string> const& targets,
  123. std::vector<cmGeneratorTarget const*>& exports);
  124. void CreateGenerationObjects(TargetTypes targetTypes = AllTargets);
  125. /**
  126. * Generate the all required files for building this project/tree. This
  127. * basically creates a series of LocalGenerators for each directory and
  128. * requests that they Generate.
  129. */
  130. virtual void Generate();
  131. virtual cmLinkLineComputer* CreateLinkLineComputer(
  132. cmOutputConverter* outputConverter,
  133. cmStateDirectory const& stateDir) const;
  134. cmLinkLineComputer* CreateMSVC60LinkLineComputer(
  135. cmOutputConverter* outputConverter,
  136. cmStateDirectory const& stateDir) const;
  137. /**
  138. * Set/Get and Clear the enabled languages.
  139. */
  140. void SetLanguageEnabled(const std::string&, cmMakefile* mf);
  141. bool GetLanguageEnabled(const std::string&) const;
  142. void ClearEnabledLanguages();
  143. void GetEnabledLanguages(std::vector<std::string>& lang) const;
  144. /**
  145. * Try to determine system information such as shared library
  146. * extension, pthreads, byte order etc.
  147. */
  148. virtual void EnableLanguage(std::vector<std::string> const& languages,
  149. cmMakefile*, bool optional);
  150. /**
  151. * Resolve the CMAKE_<lang>_COMPILER setting for the given language.
  152. * Intended to be called from EnableLanguage.
  153. */
  154. void ResolveLanguageCompiler(const std::string& lang, cmMakefile* mf,
  155. bool optional) const;
  156. /**
  157. * Try to determine system information, get it from another generator
  158. */
  159. void EnableLanguagesFromGenerator(cmGlobalGenerator* gen, cmMakefile* mf);
  160. /**
  161. * Try running cmake and building a file. This is used for dynamically
  162. * loaded commands, not as part of the usual build process.
  163. */
  164. int TryCompile(int jobs, const std::string& srcdir,
  165. const std::string& bindir, const std::string& projectName,
  166. const std::string& targetName, bool fast, std::string& output,
  167. cmMakefile* mf);
  168. /**
  169. * Build a file given the following information. This is a more direct call
  170. * that is used by both CTest and TryCompile. If target name is NULL or
  171. * empty then all is assumed. clean indicates if a "make clean" should be
  172. * done first.
  173. */
  174. int Build(
  175. int jobs, const std::string& srcdir, const std::string& bindir,
  176. const std::string& projectName,
  177. std::vector<std::string> const& targetNames, std::string& output,
  178. const std::string& makeProgram, const std::string& config, bool clean,
  179. bool fast, bool verbose, cmDuration timeout,
  180. cmSystemTools::OutputOption outputflag = cmSystemTools::OUTPUT_NONE,
  181. std::vector<std::string> const& nativeOptions =
  182. std::vector<std::string>());
  183. /**
  184. * Open a generated IDE project given the following information.
  185. */
  186. virtual bool Open(const std::string& bindir, const std::string& projectName,
  187. bool dryRun);
  188. struct GeneratedMakeCommand final : public detail::GeneratedMakeCommand
  189. {
  190. };
  191. virtual std::vector<GeneratedMakeCommand> GenerateBuildCommand(
  192. const std::string& makeProgram, const std::string& projectName,
  193. const std::string& projectDir, std::vector<std::string> const& targetNames,
  194. const std::string& config, bool fast, int jobs, bool verbose,
  195. std::vector<std::string> const& makeOptions = std::vector<std::string>());
  196. virtual void PrintBuildCommandAdvice(std::ostream& os, int jobs) const;
  197. /** Generate a "cmake --build" call for a given target and config. */
  198. std::string GenerateCMakeBuildCommand(const std::string& target,
  199. const std::string& config,
  200. const std::string& native,
  201. bool ignoreErrors);
  202. //! Get the CMake instance
  203. cmake* GetCMakeInstance() const { return this->CMakeInstance; }
  204. void SetConfiguredFilesPath(cmGlobalGenerator* gen);
  205. const std::vector<cmMakefile*>& GetMakefiles() const
  206. {
  207. return this->Makefiles;
  208. }
  209. const std::vector<cmLocalGenerator*>& GetLocalGenerators() const
  210. {
  211. return this->LocalGenerators;
  212. }
  213. cmMakefile* GetCurrentMakefile() const
  214. {
  215. return this->CurrentConfigureMakefile;
  216. }
  217. void SetCurrentMakefile(cmMakefile* mf)
  218. {
  219. this->CurrentConfigureMakefile = mf;
  220. }
  221. void AddMakefile(cmMakefile* mf);
  222. //! Set an generator for an "external makefile based project"
  223. void SetExternalMakefileProjectGenerator(
  224. cmExternalMakefileProjectGenerator* extraGenerator);
  225. std::string GetExtraGeneratorName() const;
  226. void AddInstallComponent(const std::string& component);
  227. const std::set<std::string>* GetInstallComponents() const
  228. {
  229. return &this->InstallComponents;
  230. }
  231. cmExportSetMap& GetExportSets() { return this->ExportSets; }
  232. const char* GetGlobalSetting(std::string const& name) const;
  233. bool GlobalSettingIsOn(std::string const& name) const;
  234. std::string GetSafeGlobalSetting(std::string const& name) const;
  235. /** Add a file to the manifest of generated targets for a configuration. */
  236. void AddToManifest(std::string const& f);
  237. void EnableInstallTarget();
  238. cmDuration TryCompileTimeout;
  239. bool GetForceUnixPaths() const { return this->ForceUnixPaths; }
  240. bool GetToolSupportsColor() const { return this->ToolSupportsColor; }
  241. //! return the language for the given extension
  242. std::string GetLanguageFromExtension(const char* ext) const;
  243. //! is an extension to be ignored
  244. bool IgnoreFile(const char* ext) const;
  245. //! What is the preference for linkers and this language (None or Preferred)
  246. int GetLinkerPreference(const std::string& lang) const;
  247. //! What is the object file extension for a given source file?
  248. std::string GetLanguageOutputExtension(cmSourceFile const&) const;
  249. //! What is the configurations directory variable called?
  250. virtual const char* GetCMakeCFGIntDir() const { return "."; }
  251. //! expand CFGIntDir for a configuration
  252. virtual std::string ExpandCFGIntDir(const std::string& str,
  253. const std::string& config) const;
  254. /** Get whether the generator should use a script for link commands. */
  255. bool GetUseLinkScript() const { return this->UseLinkScript; }
  256. /** Get whether the generator should produce special marks on rules
  257. producing symbolic (non-file) outputs. */
  258. bool GetNeedSymbolicMark() const { return this->NeedSymbolicMark; }
  259. /*
  260. * Determine what program to use for building the project.
  261. */
  262. virtual bool FindMakeProgram(cmMakefile*);
  263. //! Find a target by name by searching the local generators.
  264. cmTarget* FindTarget(const std::string& name,
  265. bool excludeAliases = false) const;
  266. cmGeneratorTarget* FindGeneratorTarget(const std::string& name) const;
  267. void AddAlias(const std::string& name, const std::string& tgtName);
  268. bool IsAlias(const std::string& name) const;
  269. /** Determine if a name resolves to a framework on disk or a built target
  270. that is a framework. */
  271. bool NameResolvesToFramework(const std::string& libname) const;
  272. cmMakefile* FindMakefile(const std::string& start_dir) const;
  273. cmLocalGenerator* FindLocalGenerator(cmDirectoryId const& id) const;
  274. /** Append the subdirectory for the given configuration. If anything is
  275. appended the given prefix and suffix will be appended around it, which
  276. is useful for leading or trailing slashes. */
  277. virtual void AppendDirectoryForConfig(const std::string& prefix,
  278. const std::string& config,
  279. const std::string& suffix,
  280. std::string& dir);
  281. /** Get the content of a directory. Directory listings are cached
  282. and re-loaded from disk only when modified. During the generation
  283. step the content will include the target files to be built even if
  284. they do not yet exist. */
  285. std::set<std::string> const& GetDirectoryContent(std::string const& dir,
  286. bool needDisk = true);
  287. void IndexTarget(cmTarget* t);
  288. void IndexGeneratorTarget(cmGeneratorTarget* gt);
  289. // Index the target using a name that is unique to that target
  290. // even if other targets have the same name.
  291. std::string IndexGeneratorTargetUniquely(cmGeneratorTarget const* gt);
  292. static bool IsReservedTarget(std::string const& name);
  293. virtual const char* GetAllTargetName() const { return "ALL_BUILD"; }
  294. virtual const char* GetInstallTargetName() const { return "INSTALL"; }
  295. virtual const char* GetInstallLocalTargetName() const { return nullptr; }
  296. virtual const char* GetInstallStripTargetName() const { return nullptr; }
  297. virtual const char* GetPreinstallTargetName() const { return nullptr; }
  298. virtual const char* GetTestTargetName() const { return "RUN_TESTS"; }
  299. virtual const char* GetPackageTargetName() const { return "PACKAGE"; }
  300. virtual const char* GetPackageSourceTargetName() const { return nullptr; }
  301. virtual const char* GetEditCacheTargetName() const { return nullptr; }
  302. virtual const char* GetRebuildCacheTargetName() const { return nullptr; }
  303. virtual const char* GetCleanTargetName() const { return nullptr; }
  304. // Lookup edit_cache target command preferred by this generator.
  305. virtual std::string GetEditCacheCommand() const { return ""; }
  306. // Class to track a set of dependencies.
  307. using TargetDependSet = cmTargetDependSet;
  308. // what targets does the specified target depend on directly
  309. // via a target_link_libraries or add_dependencies
  310. TargetDependSet const& GetTargetDirectDepends(
  311. const cmGeneratorTarget* target);
  312. const std::map<std::string, std::vector<cmLocalGenerator*>>& GetProjectMap()
  313. const
  314. {
  315. return this->ProjectMap;
  316. }
  317. // track files replaced during a Generate
  318. void FileReplacedDuringGenerate(const std::string& filename);
  319. void GetFilesReplacedDuringGenerate(std::vector<std::string>& filenames);
  320. void AddRuleHash(const std::vector<std::string>& outputs,
  321. std::string const& content);
  322. /** Return whether the given binary directory is unused. */
  323. bool BinaryDirectoryIsNew(const std::string& dir)
  324. {
  325. return this->BinaryDirectories.insert(dir).second;
  326. }
  327. /** Return true if the generated build tree may contain multiple builds.
  328. i.e. "Can I build Debug and Release in the same tree?" */
  329. virtual bool IsMultiConfig() const { return false; }
  330. virtual bool IsXcode() const { return false; }
  331. /** Return true if we know the exact location of object files.
  332. If false, store the reason in the given string.
  333. This is meaningful only after EnableLanguage has been called. */
  334. virtual bool HasKnownObjectFileLocation(std::string*) const { return true; }
  335. virtual bool UseFolderProperty() const;
  336. virtual bool IsIPOSupported() const { return false; }
  337. /** Return whether the generator can import external visual studio project
  338. using INCLUDE_EXTERNAL_MSPROJECT */
  339. virtual bool IsIncludeExternalMSProjectSupported() const { return false; }
  340. /** Return whether the generator should use EFFECTIVE_PLATFORM_NAME. This is
  341. relevant for mixed macOS and iOS builds. */
  342. virtual bool UseEffectivePlatformName(cmMakefile*) const { return false; }
  343. /** Return whether the "Resources" folder prefix should be stripped from
  344. MacFolder. */
  345. virtual bool ShouldStripResourcePath(cmMakefile*) const;
  346. std::string GetSharedLibFlagsForLanguage(std::string const& lang) const;
  347. /** Generate an <output>.rule file path for a given command output. */
  348. virtual std::string GenerateRuleFile(std::string const& output) const;
  349. static std::string EscapeJSON(const std::string& s);
  350. void ProcessEvaluationFiles();
  351. std::map<std::string, cmExportBuildFileGenerator*>& GetBuildExportSets()
  352. {
  353. return this->BuildExportSets;
  354. }
  355. void AddBuildExportSet(cmExportBuildFileGenerator*);
  356. void AddBuildExportExportSet(cmExportBuildFileGenerator*);
  357. bool IsExportedTargetsFile(const std::string& filename) const;
  358. bool GenerateImportFile(const std::string& file);
  359. cmExportBuildFileGenerator* GetExportedTargetsFile(
  360. const std::string& filename) const;
  361. void AddCMP0042WarnTarget(const std::string& target);
  362. void AddCMP0068WarnTarget(const std::string& target);
  363. virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
  364. bool GenerateCPackPropertiesFile();
  365. void CreateEvaluationSourceFiles(std::string const& config) const;
  366. void SetFilenameTargetDepends(
  367. cmSourceFile* sf, std::set<cmGeneratorTarget const*> const& tgts);
  368. const std::set<const cmGeneratorTarget*>& GetFilenameTargetDepends(
  369. cmSourceFile* sf) const;
  370. #if !defined(CMAKE_BOOTSTRAP)
  371. cmFileLockPool& GetFileLockPool() { return FileLockPool; }
  372. #endif
  373. bool GetConfigureDoneCMP0026() const
  374. {
  375. return this->ConfigureDoneCMP0026AndCMP0024;
  376. }
  377. std::string MakeSilentFlag;
  378. int RecursionDepth;
  379. protected:
  380. using GeneratorVector = std::vector<cmLocalGenerator*>;
  381. // for a project collect all its targets by following depend
  382. // information, and also collect all the targets
  383. void GetTargetSets(TargetDependSet& projectTargets,
  384. TargetDependSet& originalTargets, cmLocalGenerator* root,
  385. GeneratorVector const&);
  386. bool IsRootOnlyTarget(cmGeneratorTarget* target) const;
  387. void AddTargetDepends(const cmGeneratorTarget* target,
  388. TargetDependSet& projectTargets);
  389. void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf);
  390. void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf);
  391. void FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf);
  392. virtual bool CheckLanguages(std::vector<std::string> const& languages,
  393. cmMakefile* mf) const;
  394. virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
  395. const char* envVar) const;
  396. virtual bool ComputeTargetDepends();
  397. virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const;
  398. /// @brief Qt AUTOMOC/UIC/RCC target generation
  399. /// @return true on success
  400. bool QtAutoGen();
  401. bool AddAutomaticSources();
  402. std::string SelectMakeProgram(const std::string& makeProgram,
  403. const std::string& makeDefault = "") const;
  404. // Fill the ProjectMap, this must be called after LocalGenerators
  405. // has been populated.
  406. void FillProjectMap();
  407. void CheckTargetProperties();
  408. bool IsExcluded(cmStateSnapshot const& root,
  409. cmStateSnapshot const& snp) const;
  410. bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const;
  411. bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const;
  412. virtual void InitializeProgressMarks() {}
  413. struct GlobalTargetInfo
  414. {
  415. std::string Name;
  416. std::string Message;
  417. cmCustomCommandLines CommandLines;
  418. std::vector<std::string> Depends;
  419. std::string WorkingDir;
  420. bool UsesTerminal = false;
  421. };
  422. void CreateDefaultGlobalTargets(std::vector<GlobalTargetInfo>& targets);
  423. void AddGlobalTarget_Package(std::vector<GlobalTargetInfo>& targets);
  424. void AddGlobalTarget_PackageSource(std::vector<GlobalTargetInfo>& targets);
  425. void AddGlobalTarget_Test(std::vector<GlobalTargetInfo>& targets);
  426. void AddGlobalTarget_EditCache(std::vector<GlobalTargetInfo>& targets);
  427. void AddGlobalTarget_RebuildCache(std::vector<GlobalTargetInfo>& targets);
  428. void AddGlobalTarget_Install(std::vector<GlobalTargetInfo>& targets);
  429. cmTarget CreateGlobalTarget(GlobalTargetInfo const& gti, cmMakefile* mf);
  430. std::string FindMakeProgramFile;
  431. std::string ConfiguredFilesPath;
  432. cmake* CMakeInstance;
  433. std::vector<cmMakefile*> Makefiles;
  434. std::vector<cmLocalGenerator*> LocalGenerators;
  435. cmMakefile* CurrentConfigureMakefile;
  436. // map from project name to vector of local generators in that project
  437. std::map<std::string, std::vector<cmLocalGenerator*>> ProjectMap;
  438. // Set of named installation components requested by the project.
  439. std::set<std::string> InstallComponents;
  440. // Sets of named target exports
  441. cmExportSetMap ExportSets;
  442. std::map<std::string, cmExportBuildFileGenerator*> BuildExportSets;
  443. std::map<std::string, cmExportBuildFileGenerator*> BuildExportExportSets;
  444. std::map<std::string, std::string> AliasTargets;
  445. cmTarget* FindTargetImpl(std::string const& name) const;
  446. cmGeneratorTarget* FindGeneratorTargetImpl(std::string const& name) const;
  447. const char* GetPredefinedTargetsFolder();
  448. private:
  449. using TargetMap = std::unordered_map<std::string, cmTarget*>;
  450. using GeneratorTargetMap =
  451. std::unordered_map<std::string, cmGeneratorTarget*>;
  452. using MakefileMap = std::unordered_map<std::string, cmMakefile*>;
  453. using LocalGeneratorMap = std::unordered_map<std::string, cmLocalGenerator*>;
  454. // Map efficiently from target name to cmTarget instance.
  455. // Do not use this structure for looping over all targets.
  456. // It contains both normal and globally visible imported targets.
  457. TargetMap TargetSearchIndex;
  458. GeneratorTargetMap GeneratorTargetSearchIndex;
  459. // Map efficiently from source directory path to cmMakefile instance.
  460. // Do not use this structure for looping over all directories.
  461. // It may not contain all of them (see note in IndexMakefile method).
  462. MakefileMap MakefileSearchIndex;
  463. // Map efficiently from source directory path to cmLocalGenerator instance.
  464. // Do not use this structure for looping over all directories.
  465. // Its order is not deterministic.
  466. LocalGeneratorMap LocalGeneratorSearchIndex;
  467. cmMakefile* TryCompileOuterMakefile;
  468. // If you add a new map here, make sure it is copied
  469. // in EnableLanguagesFromGenerator
  470. std::map<std::string, bool> IgnoreExtensions;
  471. std::set<std::string> LanguagesReady; // Ready for try_compile
  472. std::set<std::string> LanguagesInProgress;
  473. std::map<std::string, std::string> OutputExtensions;
  474. std::map<std::string, std::string> LanguageToOutputExtension;
  475. std::map<std::string, std::string> ExtensionToLanguage;
  476. std::map<std::string, int> LanguageToLinkerPreference;
  477. std::map<std::string, std::string> LanguageToOriginalSharedLibFlags;
  478. // Record hashes for rules and outputs.
  479. struct RuleHash
  480. {
  481. char Data[32];
  482. };
  483. std::map<std::string, RuleHash> RuleHashes;
  484. void CheckRuleHashes();
  485. void CheckRuleHashes(std::string const& pfile, std::string const& home);
  486. void WriteRuleHashes(std::string const& pfile);
  487. void WriteSummary();
  488. void WriteSummary(cmGeneratorTarget* target);
  489. void FinalizeTargetCompileInfo();
  490. virtual void ForceLinkerLanguages();
  491. bool CheckTargetsForMissingSources() const;
  492. bool CheckTargetsForType() const;
  493. bool CheckTargetsForPchCompilePdb() const;
  494. void CreateLocalGenerators();
  495. void CheckCompilerIdCompatibility(cmMakefile* mf,
  496. std::string const& lang) const;
  497. void ComputeBuildFileGenerators();
  498. std::unique_ptr<cmExternalMakefileProjectGenerator> ExtraGenerator;
  499. // track files replaced during a Generate
  500. std::vector<std::string> FilesReplacedDuringGenerate;
  501. // Store computed inter-target dependencies.
  502. using TargetDependMap = std::map<cmGeneratorTarget const*, TargetDependSet>;
  503. TargetDependMap TargetDependencies;
  504. friend class cmake;
  505. void CreateGeneratorTargets(
  506. TargetTypes targetTypes, cmMakefile* mf, cmLocalGenerator* lg,
  507. std::map<cmTarget*, cmGeneratorTarget*> const& importedMap);
  508. void CreateGeneratorTargets(TargetTypes targetTypes);
  509. void ClearGeneratorMembers();
  510. bool CheckCMP0037(std::string const& targetName,
  511. std::string const& reason) const;
  512. void IndexMakefile(cmMakefile* mf);
  513. void IndexLocalGenerator(cmLocalGenerator* lg);
  514. virtual const char* GetBuildIgnoreErrorsFlag() const { return nullptr; }
  515. // Cache directory content and target files to be built.
  516. struct DirectoryContent
  517. {
  518. long LastDiskTime = -1;
  519. std::set<std::string> All;
  520. std::set<std::string> Generated;
  521. };
  522. std::map<std::string, DirectoryContent> DirectoryContentMap;
  523. // Set of binary directories on disk.
  524. std::set<std::string> BinaryDirectories;
  525. // track targets to issue CMP0042 warning for.
  526. std::set<std::string> CMP0042WarnTargets;
  527. // track targets to issue CMP0068 warning for.
  528. std::set<std::string> CMP0068WarnTargets;
  529. mutable std::map<cmSourceFile*, std::set<cmGeneratorTarget const*>>
  530. FilenameTargetDepends;
  531. #if !defined(CMAKE_BOOTSTRAP)
  532. // Pool of file locks
  533. cmFileLockPool FileLockPool;
  534. #endif
  535. protected:
  536. float FirstTimeProgress;
  537. bool NeedSymbolicMark;
  538. bool UseLinkScript;
  539. bool ForceUnixPaths;
  540. bool ToolSupportsColor;
  541. bool InstallTargetEnabled;
  542. bool ConfigureDoneCMP0026AndCMP0024;
  543. };
  544. #endif