cmGlobalGenerator.h 24 KB

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