cmLocalGenerator.h 28 KB

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