cmLocalGenerator.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <iosfwd>
  6. #include <map>
  7. #include <memory>
  8. #include <set>
  9. #include <string>
  10. #include <unordered_map>
  11. #include <vector>
  12. #include <cm3p/kwiml/int.h>
  13. #include "cmCustomCommandTypes.h"
  14. #include "cmListFileCache.h"
  15. #include "cmMessageType.h"
  16. #include "cmOutputConverter.h"
  17. #include "cmPolicies.h"
  18. #include "cmProperty.h"
  19. #include "cmStateSnapshot.h"
  20. class cmCompiledGeneratorExpression;
  21. class cmComputeLinkInformation;
  22. class cmCustomCommand;
  23. class cmCustomCommandGenerator;
  24. class cmCustomCommandLines;
  25. class cmGeneratorTarget;
  26. class cmGlobalGenerator;
  27. class cmImplicitDependsList;
  28. class cmLinkLineComputer;
  29. class cmMakefile;
  30. class cmRulePlaceholderExpander;
  31. class cmSourceFile;
  32. class cmState;
  33. class cmTarget;
  34. class cmake;
  35. /** Flag if byproducts shall also be considered. */
  36. enum class cmSourceOutputKind
  37. {
  38. OutputOnly,
  39. OutputOrByproduct
  40. };
  41. /** What scanner to use for dependencies lookup. */
  42. enum class cmDependencyScannerKind
  43. {
  44. CMake,
  45. Compiler
  46. };
  47. /** Target and source file which have a specific output. */
  48. struct cmSourcesWithOutput
  49. {
  50. /** Target with byproduct. */
  51. cmTarget* Target = nullptr;
  52. /** Source file with output or byproduct. */
  53. cmSourceFile* Source = nullptr;
  54. bool SourceIsByproduct = false;
  55. };
  56. /** \class cmLocalGenerator
  57. * \brief Create required build files for a directory.
  58. *
  59. * Subclasses of this abstract class generate makefiles, DSP, etc for various
  60. * platforms. This class should never be constructed directly. A
  61. * GlobalGenerator will create it and invoke the appropriate commands on it.
  62. */
  63. class cmLocalGenerator : public cmOutputConverter
  64. {
  65. public:
  66. cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile);
  67. virtual ~cmLocalGenerator();
  68. /**
  69. * Generate the makefile for this directory.
  70. */
  71. virtual void Generate() {}
  72. virtual void ComputeHomeRelativeOutputPath() {}
  73. /**
  74. * Calls TraceVSDependencies() on all targets of this generator.
  75. */
  76. void TraceDependencies() const;
  77. virtual void AddHelperCommands() {}
  78. /**
  79. * Generate the install rules files in this directory.
  80. */
  81. void GenerateInstallRules();
  82. /**
  83. * Generate the test files for tests.
  84. */
  85. void GenerateTestFiles();
  86. /**
  87. * Generate a manifest of target files that will be built.
  88. */
  89. void ComputeTargetManifest();
  90. bool ComputeTargetCompileFeatures();
  91. bool IsRootMakefile() const;
  92. //! Get the makefile for this generator
  93. cmMakefile* GetMakefile() { return this->Makefile; }
  94. //! Get the makefile for this generator, const version
  95. const cmMakefile* GetMakefile() const { return this->Makefile; }
  96. //! Get the GlobalGenerator this is associated with
  97. cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; }
  98. const cmGlobalGenerator* GetGlobalGenerator() const
  99. {
  100. return this->GlobalGenerator;
  101. }
  102. virtual cmRulePlaceholderExpander* CreateRulePlaceholderExpander() const;
  103. std::string GetLinkLibsCMP0065(std::string const& linkLanguage,
  104. cmGeneratorTarget& tgt) const;
  105. cmState* GetState() const;
  106. cmStateSnapshot GetStateSnapshot() const;
  107. void AddArchitectureFlags(std::string& flags,
  108. cmGeneratorTarget const* target,
  109. const std::string& lang, const std::string& config,
  110. const std::string& filterArch = std::string());
  111. void AddLanguageFlags(std::string& flags, cmGeneratorTarget const* target,
  112. const std::string& lang, const std::string& config);
  113. void AddLanguageFlagsForLinking(std::string& flags,
  114. cmGeneratorTarget const* target,
  115. const std::string& lang,
  116. const std::string& config);
  117. void AddCMP0018Flags(std::string& flags, cmGeneratorTarget const* target,
  118. std::string const& lang, const std::string& config);
  119. void AddVisibilityPresetFlags(std::string& flags,
  120. cmGeneratorTarget const* target,
  121. const std::string& lang);
  122. void AddConfigVariableFlags(std::string& flags, const std::string& var,
  123. const std::string& config);
  124. void AddCompilerRequirementFlag(std::string& flags,
  125. cmGeneratorTarget const* target,
  126. const std::string& lang,
  127. const std::string& config);
  128. //! Append flags to a string.
  129. virtual void AppendFlags(std::string& flags,
  130. const std::string& newFlags) const;
  131. virtual void AppendFlags(std::string& flags,
  132. const std::vector<BT<std::string>>& newFlags) const;
  133. virtual void AppendFlagEscape(std::string& flags,
  134. const std::string& rawFlag) const;
  135. void AddISPCDependencies(cmGeneratorTarget* target);
  136. void AddPchDependencies(cmGeneratorTarget* target);
  137. void AddUnityBuild(cmGeneratorTarget* target);
  138. void AppendIPOLinkerFlags(std::string& flags, cmGeneratorTarget* target,
  139. const std::string& config,
  140. const std::string& lang);
  141. void AppendPositionIndependentLinkerFlags(std::string& flags,
  142. cmGeneratorTarget* target,
  143. const std::string& config,
  144. const std::string& lang);
  145. //! Get the include flags for the current makefile and language
  146. std::string GetIncludeFlags(const std::vector<std::string>& includes,
  147. cmGeneratorTarget* target,
  148. const std::string& lang,
  149. bool forceFullPaths = false,
  150. bool forResponseFile = false,
  151. const std::string& config = "");
  152. using GeneratorTargetVector =
  153. std::vector<std::unique_ptr<cmGeneratorTarget>>;
  154. const GeneratorTargetVector& GetGeneratorTargets() const
  155. {
  156. return this->GeneratorTargets;
  157. }
  158. void AddGeneratorTarget(std::unique_ptr<cmGeneratorTarget> gt);
  159. void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
  160. void AddOwnedImportedGeneratorTarget(std::unique_ptr<cmGeneratorTarget> gt);
  161. cmGeneratorTarget* FindLocalNonAliasGeneratorTarget(
  162. const std::string& name) const;
  163. cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
  164. /**
  165. * Process a list of include directories
  166. */
  167. void AppendIncludeDirectories(std::vector<std::string>& includes,
  168. std::string const& includes_list,
  169. const cmSourceFile& sourceFile) const;
  170. void AppendIncludeDirectories(std::vector<std::string>& includes,
  171. const std::vector<std::string>& includes_vec,
  172. const cmSourceFile& sourceFile) const;
  173. /**
  174. * Encode a list of preprocessor definitions for the compiler
  175. * command line.
  176. */
  177. void AppendDefines(std::set<std::string>& defines,
  178. std::string const& defines_list) const;
  179. void AppendDefines(std::set<BT<std::string>>& defines,
  180. std::string const& defines_list) const;
  181. void AppendDefines(std::set<BT<std::string>>& defines,
  182. const std::vector<BT<std::string>>& defines_vec) const;
  183. /**
  184. * Encode a list of compile options for the compiler
  185. * command line.
  186. */
  187. void AppendCompileOptions(std::string& options,
  188. std::string const& options_list,
  189. const char* regex = nullptr) const;
  190. void AppendCompileOptions(std::string& options,
  191. const std::vector<std::string>& options_vec,
  192. const char* regex = nullptr) const;
  193. void AppendCompileOptions(std::vector<BT<std::string>>& options,
  194. const std::vector<BT<std::string>>& options_vec,
  195. const char* regex = nullptr) const;
  196. /**
  197. * Join a set of defines into a definesString with a space separator.
  198. */
  199. void JoinDefines(const std::set<std::string>& defines,
  200. std::string& definesString, const std::string& lang);
  201. /** Lookup and append options associated with a particular feature. */
  202. void AppendFeatureOptions(std::string& flags, const std::string& lang,
  203. const char* feature);
  204. cmProp GetFeature(const std::string& feature, const std::string& config);
  205. /** \brief Get absolute path to dependency \a name
  206. *
  207. * Translate a dependency as given in CMake code to the name to
  208. * appear in a generated build file.
  209. * - If \a name is a utility target, returns false.
  210. * - If \a name is a CMake target, it will be transformed to the real output
  211. * location of that target for the given configuration.
  212. * - If \a name is the full path to a file, it will be returned.
  213. * - Otherwise \a name is treated as a relative path with respect to
  214. * the source directory of this generator. This should only be
  215. * used for dependencies of custom commands.
  216. */
  217. bool GetRealDependency(const std::string& name, const std::string& config,
  218. std::string& dep);
  219. virtual std::string ConvertToIncludeReference(
  220. std::string const& path,
  221. cmOutputConverter::OutputFormat format = cmOutputConverter::SHELL,
  222. bool forceFullPaths = false);
  223. /** Called from command-line hook to clear dependencies. */
  224. virtual void ClearDependencies(cmMakefile* /* mf */, bool /* verbose */) {}
  225. /** Called from command-line hook to update dependencies. */
  226. virtual bool UpdateDependencies(const std::string& /* tgtInfo */,
  227. bool /*verbose*/, bool /*color*/)
  228. {
  229. return true;
  230. }
  231. /** @brief Get the include directories for the current makefile and language
  232. * and optional the compiler implicit include directories.
  233. *
  234. * @arg stripImplicitDirs Strip all directories found in
  235. * CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES from the result.
  236. * @arg appendAllImplicitDirs Append all directories found in
  237. * CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES to the result.
  238. */
  239. std::vector<BT<std::string>> GetIncludeDirectoriesImplicit(
  240. cmGeneratorTarget const* target, std::string const& lang = "C",
  241. std::string const& config = "", bool stripImplicitDirs = true,
  242. bool appendAllImplicitDirs = false) const;
  243. /** @brief Get the include directories for the current makefile and language
  244. * and optional the compiler implicit include directories.
  245. *
  246. * @arg dirs Directories are appended to this list
  247. */
  248. void GetIncludeDirectoriesImplicit(std::vector<std::string>& dirs,
  249. cmGeneratorTarget const* target,
  250. const std::string& lang = "C",
  251. const std::string& config = "",
  252. bool stripImplicitDirs = true,
  253. bool appendAllImplicitDirs = false) const;
  254. /** @brief Get the include directories for the current makefile and language.
  255. * @arg dirs Include directories are appended to this list
  256. */
  257. void GetIncludeDirectories(std::vector<std::string>& dirs,
  258. cmGeneratorTarget const* target,
  259. const std::string& lang = "C",
  260. const std::string& config = "") const;
  261. /** @brief Get the include directories for the current makefile and language.
  262. * @return The include directory list
  263. */
  264. std::vector<BT<std::string>> GetIncludeDirectories(
  265. cmGeneratorTarget const* target, std::string const& lang = "C",
  266. std::string const& config = "") const;
  267. void AddCompileOptions(std::string& flags, cmGeneratorTarget* target,
  268. const std::string& lang, const std::string& config);
  269. void AddCompileOptions(std::vector<BT<std::string>>& flags,
  270. cmGeneratorTarget* target, const std::string& lang,
  271. const std::string& config);
  272. /**
  273. * Add a custom PRE_BUILD, PRE_LINK, or POST_BUILD command to a target.
  274. */
  275. cmTarget* AddCustomCommandToTarget(
  276. const std::string& target, const std::vector<std::string>& byproducts,
  277. const std::vector<std::string>& depends,
  278. const cmCustomCommandLines& commandLines, cmCustomCommandType type,
  279. const char* comment, const char* workingDir, bool escapeOldStyle = true,
  280. bool uses_terminal = false, const std::string& depfile = "",
  281. const std::string& job_pool = "", bool command_expand_lists = false,
  282. cmObjectLibraryCommands objLibCommands = cmObjectLibraryCommands::Reject,
  283. bool stdPipesUTF8 = false);
  284. /**
  285. * Add a custom command to a source file.
  286. */
  287. cmSourceFile* AddCustomCommandToOutput(
  288. const std::string& output, const std::vector<std::string>& depends,
  289. const std::string& main_dependency,
  290. const cmCustomCommandLines& commandLines, const char* comment,
  291. const char* workingDir, bool replace = false, bool escapeOldStyle = true,
  292. bool uses_terminal = false, bool command_expand_lists = false,
  293. const std::string& depfile = "", const std::string& job_pool = "",
  294. bool stdPipesUTF8 = false);
  295. cmSourceFile* AddCustomCommandToOutput(
  296. const std::vector<std::string>& outputs,
  297. const std::vector<std::string>& byproducts,
  298. const std::vector<std::string>& depends,
  299. const std::string& main_dependency,
  300. const cmImplicitDependsList& implicit_depends,
  301. const cmCustomCommandLines& commandLines, const char* comment,
  302. const char* workingDir, bool replace = false, bool escapeOldStyle = true,
  303. bool uses_terminal = false, bool command_expand_lists = false,
  304. const std::string& depfile = "", const std::string& job_pool = "",
  305. bool stdPipesUTF8 = false);
  306. /**
  307. * Add a utility to the build. A utility target is a command that is run
  308. * every time the target is built.
  309. */
  310. cmTarget* AddUtilityCommand(
  311. const std::string& utilityName, bool excludeFromAll,
  312. const char* workingDir, const std::vector<std::string>& byproducts,
  313. const std::vector<std::string>& depends,
  314. const cmCustomCommandLines& commandLines, bool escapeOldStyle = true,
  315. const char* comment = nullptr, bool uses_terminal = false,
  316. bool command_expand_lists = false, const std::string& job_pool = "",
  317. bool stdPipesUTF8 = false);
  318. virtual std::string CreateUtilityOutput(
  319. std::string const& targetName, std::vector<std::string> const& byproducts,
  320. cmListFileBacktrace const& bt);
  321. virtual std::vector<cmCustomCommandGenerator> MakeCustomCommandGenerators(
  322. cmCustomCommand const& cc, std::string const& config);
  323. std::vector<std::string> ExpandCustomCommandOutputPaths(
  324. cmCompiledGeneratorExpression const& cge, std::string const& config);
  325. std::vector<std::string> ExpandCustomCommandOutputGenex(
  326. std::string const& o, cmListFileBacktrace const& bt);
  327. /**
  328. * Add target byproducts.
  329. */
  330. void AddTargetByproducts(cmTarget* target,
  331. const std::vector<std::string>& byproducts,
  332. cmListFileBacktrace const& bt,
  333. cmCommandOrigin origin);
  334. enum class OutputRole
  335. {
  336. Primary,
  337. Byproduct,
  338. };
  339. /**
  340. * Add source file outputs.
  341. */
  342. void AddSourceOutputs(cmSourceFile* source,
  343. std::vector<std::string> const& outputs,
  344. OutputRole role, cmListFileBacktrace const& bt,
  345. cmCommandOrigin origin);
  346. /**
  347. * Return the target if the provided source name is a byproduct of a utility
  348. * target or a PRE_BUILD, PRE_LINK, or POST_BUILD command.
  349. * Return the source file which has the provided source name as output.
  350. */
  351. cmSourcesWithOutput GetSourcesWithOutput(const std::string& name) const;
  352. /**
  353. * Is there a source file that has the provided source name as an output?
  354. * If so then return it.
  355. */
  356. cmSourceFile* GetSourceFileWithOutput(
  357. const std::string& name,
  358. cmSourceOutputKind kind = cmSourceOutputKind::OutputOnly) const;
  359. std::string GetProjectName() const;
  360. /** Compute the language used to compile the given source file. */
  361. std::string GetSourceFileLanguage(const cmSourceFile& source);
  362. // Fill the vector with the target names for the object files,
  363. // preprocessed files and assembly files.
  364. void GetIndividualFileTargets(std::vector<std::string>&) {}
  365. /**
  366. * Get the relative path from the generator output directory to a
  367. * per-target support directory.
  368. */
  369. virtual std::string GetTargetDirectory(
  370. cmGeneratorTarget const* target) const;
  371. /**
  372. * Get the level of backwards compatibility requested by the project
  373. * in this directory. This is the value of the CMake variable
  374. * CMAKE_BACKWARDS_COMPATIBILITY whose format is
  375. * "major.minor[.patch]". The returned integer is encoded as
  376. *
  377. * CMake_VERSION_ENCODE(major, minor, patch)
  378. *
  379. * and is monotonically increasing with the CMake version.
  380. */
  381. KWIML_INT_uint64_t GetBackwardsCompatibility();
  382. /**
  383. * Test whether compatibility is set to a given version or lower.
  384. */
  385. bool NeedBackwardsCompatibility_2_4();
  386. cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id) const;
  387. cmake* GetCMakeInstance() const;
  388. std::string const& GetSourceDirectory() const;
  389. std::string const& GetBinaryDirectory() const;
  390. std::string const& GetCurrentBinaryDirectory() const;
  391. std::string const& GetCurrentSourceDirectory() const;
  392. /**
  393. * Convert the given remote path to a relative path with respect to
  394. * the given local path. Both paths must use forward slashes and not
  395. * already be escaped or quoted.
  396. * The conversion is skipped if the paths are not both in the source
  397. * or both in the binary tree.
  398. */
  399. std::string MaybeConvertToRelativePath(std::string const& local_path,
  400. std::string const& remote_path) const;
  401. /**
  402. * Generate a macOS application bundle Info.plist file.
  403. */
  404. void GenerateAppleInfoPList(cmGeneratorTarget* target,
  405. const std::string& targetName,
  406. const std::string& fname);
  407. /**
  408. * Generate a macOS framework Info.plist file.
  409. */
  410. void GenerateFrameworkInfoPList(cmGeneratorTarget* target,
  411. const std::string& targetName,
  412. const std::string& fname);
  413. /** Construct a comment for a custom command. */
  414. std::string ConstructComment(cmCustomCommandGenerator const& ccg,
  415. const char* default_comment = "") const;
  416. // Compute object file names.
  417. std::string GetObjectFileNameWithoutTarget(
  418. const cmSourceFile& source, std::string const& dir_max,
  419. bool* hasSourceExtension = nullptr,
  420. char const* customOutputExtension = nullptr);
  421. /** Fill out the static linker flags for the given target. */
  422. void GetStaticLibraryFlags(std::string& flags, std::string const& config,
  423. std::string const& linkLanguage,
  424. cmGeneratorTarget* target);
  425. std::vector<BT<std::string>> GetStaticLibraryFlags(
  426. std::string const& config, std::string const& linkLanguage,
  427. cmGeneratorTarget* target);
  428. /** Fill out these strings for the given target. Libraries to link,
  429. * flags, and linkflags. */
  430. void GetDeviceLinkFlags(cmLinkLineComputer* linkLineComputer,
  431. const std::string& config, std::string& linkLibs,
  432. std::string& linkFlags, std::string& frameworkPath,
  433. std::string& linkPath, cmGeneratorTarget* target);
  434. void GetTargetFlags(cmLinkLineComputer* linkLineComputer,
  435. const std::string& config, std::string& linkLibs,
  436. std::string& flags, std::string& linkFlags,
  437. std::string& frameworkPath, std::string& linkPath,
  438. cmGeneratorTarget* target);
  439. void GetTargetFlags(
  440. cmLinkLineComputer* linkLineComputer, const std::string& config,
  441. std::vector<BT<std::string>>& linkLibs, std::string& flags,
  442. std::vector<BT<std::string>>& linkFlags, std::string& frameworkPath,
  443. std::vector<BT<std::string>>& linkPath, cmGeneratorTarget* target);
  444. void GetTargetDefines(cmGeneratorTarget const* target,
  445. std::string const& config, std::string const& lang,
  446. std::set<std::string>& defines) const;
  447. std::set<BT<std::string>> GetTargetDefines(cmGeneratorTarget const* target,
  448. std::string const& config,
  449. std::string const& lang) const;
  450. void GetTargetCompileFlags(cmGeneratorTarget* target,
  451. std::string const& config,
  452. std::string const& lang, std::string& flags,
  453. std::string const& arch);
  454. std::vector<BT<std::string>> GetTargetCompileFlags(
  455. cmGeneratorTarget* target, std::string const& config,
  456. std::string const& lang, std::string const& arch = std::string());
  457. std::string GetFrameworkFlags(std::string const& l,
  458. std::string const& config,
  459. cmGeneratorTarget* target);
  460. virtual std::string GetTargetFortranFlags(cmGeneratorTarget const* target,
  461. std::string const& config);
  462. virtual void ComputeObjectFilenames(
  463. std::map<cmSourceFile const*, std::string>& mapping,
  464. cmGeneratorTarget const* gt = nullptr);
  465. bool IsWindowsShell() const;
  466. bool IsWatcomWMake() const;
  467. bool IsMinGWMake() const;
  468. bool IsNMake() const;
  469. bool IsNinjaMulti() const;
  470. void IssueMessage(MessageType t, std::string const& text) const;
  471. void CreateEvaluationFileOutputs();
  472. void CreateEvaluationFileOutputs(const std::string& config);
  473. void ProcessEvaluationFiles(std::vector<std::string>& generatedFiles);
  474. cmProp GetRuleLauncher(cmGeneratorTarget* target, const std::string& prop);
  475. protected:
  476. //! put all the libraries for a target on into the given stream
  477. void OutputLinkLibraries(cmComputeLinkInformation* pcli,
  478. cmLinkLineComputer* linkLineComputer,
  479. std::string& linkLibraries,
  480. std::string& frameworkPath, std::string& linkPath);
  481. void OutputLinkLibraries(cmComputeLinkInformation* pcli,
  482. cmLinkLineComputer* linkLineComputer,
  483. std::vector<BT<std::string>>& linkLibraries,
  484. std::string& frameworkPath,
  485. std::vector<BT<std::string>>& linkPath);
  486. // Handle old-style install rules stored in the targets.
  487. void GenerateTargetInstallRules(
  488. std::ostream& os, const std::string& config,
  489. std::vector<std::string> const& configurationTypes);
  490. std::string& CreateSafeUniqueObjectFileName(const std::string& sin,
  491. std::string const& dir_max);
  492. /** Check whether the native build system supports the given
  493. definition. Issues a warning. */
  494. virtual bool CheckDefinition(std::string const& define) const;
  495. cmMakefile* Makefile;
  496. cmStateSnapshot StateSnapshot;
  497. cmListFileBacktrace DirectoryBacktrace;
  498. cmGlobalGenerator* GlobalGenerator;
  499. std::map<std::string, std::string> UniqueObjectNamesMap;
  500. std::string::size_type ObjectPathMax;
  501. std::set<std::string> ObjectMaxPathViolations;
  502. std::set<std::string> EnvCPATH;
  503. using GeneratorTargetMap =
  504. std::unordered_map<std::string, cmGeneratorTarget*>;
  505. GeneratorTargetMap GeneratorTargetSearchIndex;
  506. GeneratorTargetVector GeneratorTargets;
  507. std::set<cmGeneratorTarget const*> WarnCMP0063;
  508. GeneratorTargetMap ImportedGeneratorTargets;
  509. GeneratorTargetVector OwnedImportedGeneratorTargets;
  510. std::map<std::string, std::string> AliasTargets;
  511. std::map<std::string, std::string> Compilers;
  512. std::map<std::string, std::string> VariableMappings;
  513. std::string CompilerSysroot;
  514. std::string LinkerSysroot;
  515. std::unordered_map<std::string, std::string> AppleArchSysroots;
  516. bool EmitUniversalBinaryFlags;
  517. KWIML_INT_uint64_t BackwardsCompatibility;
  518. bool BackwardsCompatibilityFinal;
  519. private:
  520. /**
  521. * See LinearGetSourceFileWithOutput for background information
  522. */
  523. cmTarget* LinearGetTargetWithOutput(const std::string& name) const;
  524. /**
  525. * Generalized old version of GetSourceFileWithOutput kept for
  526. * backward-compatibility. It implements a linear search and supports
  527. * relative file paths. It is used as a fall back by GetSourceFileWithOutput
  528. * and GetSourcesWithOutput.
  529. */
  530. cmSourceFile* LinearGetSourceFileWithOutput(const std::string& name,
  531. cmSourceOutputKind kind,
  532. bool& byproduct) const;
  533. struct SourceEntry
  534. {
  535. cmSourcesWithOutput Sources;
  536. };
  537. // A map for fast output to input look up.
  538. using OutputToSourceMap = std::unordered_map<std::string, SourceEntry>;
  539. OutputToSourceMap OutputToSource;
  540. void UpdateOutputToSourceMap(std::string const& byproduct, cmTarget* target,
  541. cmListFileBacktrace const& bt,
  542. cmCommandOrigin origin);
  543. void UpdateOutputToSourceMap(std::string const& output, cmSourceFile* source,
  544. OutputRole role, cmListFileBacktrace const& bt,
  545. cmCommandOrigin origin);
  546. void AddSharedFlags(std::string& flags, const std::string& lang,
  547. bool shared);
  548. bool GetShouldUseOldFlags(bool shared, const std::string& lang) const;
  549. void AddPositionIndependentFlags(std::string& flags, std::string const& l,
  550. int targetType);
  551. void ComputeObjectMaxPath();
  552. bool AllAppleArchSysrootsAreTheSame(const std::vector<std::string>& archs,
  553. const char* sysroot);
  554. void CopyPchCompilePdb(const std::string& config, cmGeneratorTarget* target,
  555. const std::string& ReuseFrom,
  556. cmGeneratorTarget* reuseTarget,
  557. std::vector<std::string> const& extensions);
  558. };
  559. #if !defined(CMAKE_BOOTSTRAP)
  560. bool cmLocalGeneratorCheckObjectName(std::string& objName,
  561. std::string::size_type dir_len,
  562. std::string::size_type max_total_len);
  563. #endif
  564. namespace detail {
  565. void AddCustomCommandToTarget(cmLocalGenerator& lg,
  566. const cmListFileBacktrace& lfbt,
  567. cmCommandOrigin origin, cmTarget* target,
  568. const std::vector<std::string>& byproducts,
  569. const std::vector<std::string>& depends,
  570. const cmCustomCommandLines& commandLines,
  571. cmCustomCommandType type, const char* comment,
  572. const char* workingDir, bool escapeOldStyle,
  573. bool uses_terminal, const std::string& depfile,
  574. const std::string& job_pool,
  575. bool command_expand_lists, bool stdPipesUTF8);
  576. cmSourceFile* AddCustomCommandToOutput(
  577. cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
  578. cmCommandOrigin origin, const std::vector<std::string>& outputs,
  579. const std::vector<std::string>& byproducts,
  580. const std::vector<std::string>& depends, const std::string& main_dependency,
  581. const cmImplicitDependsList& implicit_depends,
  582. const cmCustomCommandLines& commandLines, const char* comment,
  583. const char* workingDir, bool replace, bool escapeOldStyle,
  584. bool uses_terminal, bool command_expand_lists, const std::string& depfile,
  585. const std::string& job_pool, bool stdPipesUTF8);
  586. void AppendCustomCommandToOutput(cmLocalGenerator& lg,
  587. const cmListFileBacktrace& lfbt,
  588. const std::string& output,
  589. const std::vector<std::string>& depends,
  590. const cmImplicitDependsList& implicit_depends,
  591. const cmCustomCommandLines& commandLines);
  592. void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
  593. cmCommandOrigin origin, cmTarget* target,
  594. const char* workingDir,
  595. const std::vector<std::string>& byproducts,
  596. const std::vector<std::string>& depends,
  597. const cmCustomCommandLines& commandLines,
  598. bool escapeOldStyle, const char* comment,
  599. bool uses_terminal, bool command_expand_lists,
  600. const std::string& job_pool, bool stdPipesUTF8);
  601. std::vector<std::string> ComputeISPCObjectSuffixes(cmGeneratorTarget* target);
  602. std::vector<std::string> ComputeISPCExtraObjects(
  603. std::string const& objectName, std::string const& buildDirectory,
  604. std::vector<std::string> const& ispcSuffixes);
  605. }