cmLocalGenerator.h 28 KB

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