cmLocalGenerator.h 28 KB

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