cmake.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  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 <functional>
  7. #include <map>
  8. #include <memory>
  9. #include <set>
  10. #include <stack>
  11. #include <string>
  12. #include <unordered_set>
  13. #include <utility>
  14. #include <vector>
  15. #include <cm/string_view>
  16. #include "cmGeneratedFileStream.h"
  17. #include "cmInstalledFile.h"
  18. #include "cmListFileCache.h"
  19. #include "cmMessageType.h"
  20. #include "cmProperty.h"
  21. #include "cmState.h"
  22. #include "cmStateSnapshot.h"
  23. #include "cmStateTypes.h"
  24. #if !defined(CMAKE_BOOTSTRAP)
  25. # include <cm3p/json/value.h>
  26. #endif
  27. class cmExternalMakefileProjectGeneratorFactory;
  28. class cmFileAPI;
  29. class cmFileTimeCache;
  30. class cmGlobalGenerator;
  31. class cmGlobalGeneratorFactory;
  32. class cmMakefile;
  33. #if !defined(CMAKE_BOOTSTRAP)
  34. class cmMakefileProfilingData;
  35. #endif
  36. class cmMessenger;
  37. class cmVariableWatch;
  38. struct cmDocumentationEntry;
  39. /** \brief Represents a cmake invocation.
  40. *
  41. * This class represents a cmake invocation. It is the top level class when
  42. * running cmake. Most cmake based GUIs should primarily create an instance
  43. * of this class and communicate with it.
  44. *
  45. * The basic process for a GUI is as follows:
  46. *
  47. * -# Create a cmake instance
  48. * -# Set the Home directories, generator, and cmake command. this
  49. * can be done using the Set methods or by using SetArgs and passing in
  50. * command line arguments.
  51. * -# Load the cache by calling LoadCache (duh)
  52. * -# if you are using command line arguments with -D or -C flags then
  53. * call SetCacheArgs (or if for some other reason you want to modify the
  54. * cache), do it now.
  55. * -# Finally call Configure
  56. * -# Let the user change values and go back to step 5
  57. * -# call Generate
  58. * If your GUI allows the user to change the home directories then
  59. * you must at a minimum redo steps 2 through 7.
  60. */
  61. class cmake
  62. {
  63. public:
  64. enum Role
  65. {
  66. RoleInternal, // no commands
  67. RoleScript, // script commands
  68. RoleProject // all commands
  69. };
  70. enum DiagLevel
  71. {
  72. DIAG_IGNORE,
  73. DIAG_WARN,
  74. DIAG_ERROR
  75. };
  76. /** \brief Describes the working modes of cmake */
  77. enum WorkingMode
  78. {
  79. NORMAL_MODE, ///< Cmake runs to create project files
  80. /** \brief Script mode (started by using -P).
  81. *
  82. * In script mode there is no generator and no cache. Also,
  83. * languages are not enabled, so add_executable and things do
  84. * nothing.
  85. */
  86. SCRIPT_MODE,
  87. /** \brief A pkg-config like mode
  88. *
  89. * In this mode cmake just searches for a package and prints the results to
  90. * stdout. This is similar to SCRIPT_MODE, but commands like add_library()
  91. * work too, since they may be used e.g. in exported target files. Started
  92. * via --find-package.
  93. */
  94. FIND_PACKAGE_MODE
  95. };
  96. /** \brief Define log level constants. */
  97. enum LogLevel
  98. {
  99. LOG_UNDEFINED,
  100. LOG_ERROR,
  101. LOG_WARNING,
  102. LOG_NOTICE,
  103. LOG_STATUS,
  104. LOG_VERBOSE,
  105. LOG_DEBUG,
  106. LOG_TRACE
  107. };
  108. /** \brief Define supported trace formats **/
  109. enum TraceFormat
  110. {
  111. TRACE_UNDEFINED,
  112. TRACE_HUMAN,
  113. TRACE_JSON_V1,
  114. };
  115. struct GeneratorInfo
  116. {
  117. std::string name;
  118. std::string baseName;
  119. std::string extraName;
  120. bool supportsToolset;
  121. bool supportsPlatform;
  122. std::vector<std::string> supportedPlatforms;
  123. std::string defaultPlatform;
  124. bool isAlias;
  125. };
  126. struct FileExtensions
  127. {
  128. bool Test(cm::string_view ext) const
  129. {
  130. return (this->unordered.find(ext) != this->unordered.end());
  131. }
  132. std::vector<std::string> ordered;
  133. std::unordered_set<cm::string_view> unordered;
  134. };
  135. using InstalledFilesMap = std::map<std::string, cmInstalledFile>;
  136. static const int NO_BUILD_PARALLEL_LEVEL = -1;
  137. static const int DEFAULT_BUILD_PARALLEL_LEVEL = 0;
  138. /// Default constructor
  139. cmake(Role role, cmState::Mode mode);
  140. /// Destructor
  141. ~cmake();
  142. cmake(cmake const&) = delete;
  143. cmake& operator=(cmake const&) = delete;
  144. #if !defined(CMAKE_BOOTSTRAP)
  145. Json::Value ReportVersionJson() const;
  146. Json::Value ReportCapabilitiesJson() const;
  147. #endif
  148. std::string ReportCapabilities() const;
  149. //@{
  150. /**
  151. * Set/Get the home directory (or output directory) in the project. The
  152. * home directory is the top directory of the project. It is the
  153. * path-to-source cmake was run with.
  154. */
  155. void SetHomeDirectory(const std::string& dir);
  156. std::string const& GetHomeDirectory() const;
  157. void SetHomeOutputDirectory(const std::string& dir);
  158. std::string const& GetHomeOutputDirectory() const;
  159. //@}
  160. /**
  161. * Handle a command line invocation of cmake.
  162. */
  163. int Run(const std::vector<std::string>& args)
  164. {
  165. return this->Run(args, false);
  166. }
  167. int Run(const std::vector<std::string>& args, bool noconfigure);
  168. /**
  169. * Run the global generator Generate step.
  170. */
  171. int Generate();
  172. /**
  173. * Configure the cmMakefiles. This routine will create a GlobalGenerator if
  174. * one has not already been set. It will then Call Configure on the
  175. * GlobalGenerator. This in turn will read in an process all the CMakeList
  176. * files for the tree. It will not produce any actual Makefiles, or
  177. * workspaces. Generate does that. */
  178. int Configure();
  179. int ActualConfigure();
  180. //! Break up a line like VAR:type="value" into var, type and value
  181. static bool ParseCacheEntry(const std::string& entry, std::string& var,
  182. std::string& value,
  183. cmStateEnums::CacheEntryType& type);
  184. int LoadCache();
  185. bool LoadCache(const std::string& path);
  186. bool LoadCache(const std::string& path, bool internal,
  187. std::set<std::string>& excludes,
  188. std::set<std::string>& includes);
  189. bool SaveCache(const std::string& path);
  190. bool DeleteCache(const std::string& path);
  191. void PreLoadCMakeFiles();
  192. //! Create a GlobalGenerator
  193. std::unique_ptr<cmGlobalGenerator> CreateGlobalGenerator(
  194. const std::string& name);
  195. //! Return the global generator assigned to this instance of cmake
  196. cmGlobalGenerator* GetGlobalGenerator()
  197. {
  198. return this->GlobalGenerator.get();
  199. }
  200. //! Return the global generator assigned to this instance of cmake, const
  201. const cmGlobalGenerator* GetGlobalGenerator() const
  202. {
  203. return this->GlobalGenerator.get();
  204. }
  205. //! Return the full path to where the CMakeCache.txt file should be.
  206. static std::string FindCacheFile(const std::string& binaryDir);
  207. //! Return the global generator assigned to this instance of cmake
  208. void SetGlobalGenerator(std::unique_ptr<cmGlobalGenerator>);
  209. //! Get the names of the current registered generators
  210. void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators,
  211. bool includeNamesWithPlatform = true) const;
  212. //! Set the name of the selected generator-specific instance.
  213. void SetGeneratorInstance(std::string const& instance)
  214. {
  215. this->GeneratorInstance = instance;
  216. this->GeneratorInstanceSet = true;
  217. }
  218. //! Set the name of the selected generator-specific platform.
  219. void SetGeneratorPlatform(std::string const& ts)
  220. {
  221. this->GeneratorPlatform = ts;
  222. this->GeneratorPlatformSet = true;
  223. }
  224. //! Set the name of the selected generator-specific toolset.
  225. void SetGeneratorToolset(std::string const& ts)
  226. {
  227. this->GeneratorToolset = ts;
  228. this->GeneratorToolsetSet = true;
  229. }
  230. bool IsAKnownSourceExtension(cm::string_view ext) const
  231. {
  232. return this->CLikeSourceFileExtensions.Test(ext) ||
  233. this->CudaFileExtensions.Test(ext) ||
  234. this->FortranFileExtensions.Test(ext) ||
  235. this->ISPCFileExtensions.Test(ext);
  236. }
  237. bool IsACLikeSourceExtension(cm::string_view ext) const
  238. {
  239. return this->CLikeSourceFileExtensions.Test(ext);
  240. }
  241. bool IsAKnownExtension(cm::string_view ext) const
  242. {
  243. return this->IsAKnownSourceExtension(ext) || this->IsAHeaderExtension(ext);
  244. }
  245. std::vector<std::string> GetAllExtensions() const;
  246. const std::vector<std::string>& GetHeaderExtensions() const
  247. {
  248. return this->HeaderFileExtensions.ordered;
  249. }
  250. bool IsAHeaderExtension(cm::string_view ext) const
  251. {
  252. return this->HeaderFileExtensions.Test(ext);
  253. }
  254. // Strips the extension (if present and known) from a filename
  255. std::string StripExtension(const std::string& file) const;
  256. /**
  257. * Given a variable name, return its value (as a string).
  258. */
  259. cmProp GetCacheDefinition(const std::string&) const;
  260. //! Add an entry into the cache
  261. void AddCacheEntry(const std::string& key, const char* value,
  262. const char* helpString, int type);
  263. bool DoWriteGlobVerifyTarget() const;
  264. std::string const& GetGlobVerifyScript() const;
  265. std::string const& GetGlobVerifyStamp() const;
  266. void AddGlobCacheEntry(bool recurse, bool listDirectories,
  267. bool followSymlinks, const std::string& relative,
  268. const std::string& expression,
  269. const std::vector<std::string>& files,
  270. const std::string& variable,
  271. cmListFileBacktrace const& bt);
  272. /**
  273. * Get the system information and write it to the file specified
  274. */
  275. int GetSystemInformation(std::vector<std::string>&);
  276. //! Parse environment variables
  277. void LoadEnvironmentPresets();
  278. //! Parse command line arguments
  279. void SetArgs(const std::vector<std::string>& args);
  280. //! Is this cmake running as a result of a TRY_COMPILE command
  281. bool GetIsInTryCompile() const;
  282. void SetIsInTryCompile(bool b);
  283. //! Parse command line arguments that might set cache values
  284. bool SetCacheArgs(const std::vector<std::string>&);
  285. using ProgressCallbackType = std::function<void(const std::string&, float)>;
  286. /**
  287. * Set the function used by GUIs to receive progress updates
  288. * Function gets passed: message as a const char*, a progress
  289. * amount ranging from 0 to 1.0 and client data. The progress
  290. * number provided may be negative in cases where a message is
  291. * to be displayed without any progress percentage.
  292. */
  293. void SetProgressCallback(ProgressCallbackType f);
  294. //! this is called by generators to update the progress
  295. void UpdateProgress(const std::string& msg, float prog);
  296. #if !defined(CMAKE_BOOTSTRAP)
  297. //! Get the variable watch object
  298. cmVariableWatch* GetVariableWatch() { return this->VariableWatch.get(); }
  299. #endif
  300. std::vector<cmDocumentationEntry> GetGeneratorsDocumentation();
  301. //! Set/Get a property of this target file
  302. void SetProperty(const std::string& prop, const char* value);
  303. void AppendProperty(const std::string& prop, const std::string& value,
  304. bool asString = false);
  305. cmProp GetProperty(const std::string& prop);
  306. bool GetPropertyAsBool(const std::string& prop);
  307. //! Get or create an cmInstalledFile instance and return a pointer to it
  308. cmInstalledFile* GetOrCreateInstalledFile(cmMakefile* mf,
  309. const std::string& name);
  310. cmInstalledFile const* GetInstalledFile(const std::string& name) const;
  311. InstalledFilesMap const& GetInstalledFiles() const
  312. {
  313. return this->InstalledFiles;
  314. }
  315. //! Do all the checks before running configure
  316. int DoPreConfigureChecks();
  317. void SetWorkingMode(WorkingMode mode) { this->CurrentWorkingMode = mode; }
  318. WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; }
  319. //! Debug the try compile stuff by not deleting the files
  320. bool GetDebugTryCompile() { return this->DebugTryCompile; }
  321. void DebugTryCompileOn() { this->DebugTryCompile = true; }
  322. /**
  323. * Generate CMAKE_ROOT and CMAKE_COMMAND cache entries
  324. */
  325. int AddCMakePaths();
  326. /**
  327. * Get the file comparison class
  328. */
  329. cmFileTimeCache* GetFileTimeCache() { return this->FileTimeCache.get(); }
  330. bool WasLogLevelSetViaCLI() const { return this->LogLevelWasSetViaCLI; }
  331. //! Get the selected log level for `message()` commands during the cmake run.
  332. LogLevel GetLogLevel() const { return this->MessageLogLevel; }
  333. void SetLogLevel(LogLevel level) { this->MessageLogLevel = level; }
  334. static LogLevel StringToLogLevel(const std::string& levelStr);
  335. static TraceFormat StringToTraceFormat(const std::string& levelStr);
  336. bool HasCheckInProgress() const
  337. {
  338. return !this->CheckInProgressMessages.empty();
  339. }
  340. std::size_t GetCheckInProgressSize() const
  341. {
  342. return this->CheckInProgressMessages.size();
  343. }
  344. std::string GetTopCheckInProgressMessage()
  345. {
  346. auto message = this->CheckInProgressMessages.top();
  347. this->CheckInProgressMessages.pop();
  348. return message;
  349. }
  350. void PushCheckInProgressMessage(std::string message)
  351. {
  352. this->CheckInProgressMessages.emplace(std::move(message));
  353. }
  354. //! Should `message` command display context.
  355. bool GetShowLogContext() const { return this->LogContext; }
  356. void SetShowLogContext(bool b) { this->LogContext = b; }
  357. //! Do we want debug output during the cmake run.
  358. bool GetDebugOutput() { return this->DebugOutput; }
  359. void SetDebugOutputOn(bool b) { this->DebugOutput = b; }
  360. //! Do we want debug output from the find commands during the cmake run.
  361. bool GetDebugFindOutput() { return this->DebugFindOutput; }
  362. void SetDebugFindOutputOn(bool b) { this->DebugFindOutput = b; }
  363. //! Do we want trace output during the cmake run.
  364. bool GetTrace() const { return this->Trace; }
  365. void SetTrace(bool b) { this->Trace = b; }
  366. bool GetTraceExpand() const { return this->TraceExpand; }
  367. void SetTraceExpand(bool b) { this->TraceExpand = b; }
  368. TraceFormat GetTraceFormat() const { return this->TraceFormatVar; }
  369. void SetTraceFormat(TraceFormat f) { this->TraceFormatVar = f; }
  370. void AddTraceSource(std::string const& file)
  371. {
  372. this->TraceOnlyThisSources.push_back(file);
  373. }
  374. std::vector<std::string> const& GetTraceSources() const
  375. {
  376. return this->TraceOnlyThisSources;
  377. }
  378. cmGeneratedFileStream& GetTraceFile() { return this->TraceFile; }
  379. void SetTraceFile(std::string const& file);
  380. void PrintTraceFormatVersion();
  381. bool GetWarnUninitialized() { return this->WarnUninitialized; }
  382. void SetWarnUninitialized(bool b) { this->WarnUninitialized = b; }
  383. bool GetWarnUnusedCli() { return this->WarnUnusedCli; }
  384. void SetWarnUnusedCli(bool b) { this->WarnUnusedCli = b; }
  385. bool GetCheckSystemVars() { return this->CheckSystemVars; }
  386. void SetCheckSystemVars(bool b) { this->CheckSystemVars = b; }
  387. void MarkCliAsUsed(const std::string& variable);
  388. /** Get the list of configurations (in upper case) considered to be
  389. debugging configurations.*/
  390. std::vector<std::string> GetDebugConfigs();
  391. void SetCMakeEditCommand(std::string const& s)
  392. {
  393. this->CMakeEditCommand = s;
  394. }
  395. std::string const& GetCMakeEditCommand() const
  396. {
  397. return this->CMakeEditCommand;
  398. }
  399. cmMessenger* GetMessenger() const { return this->Messenger.get(); }
  400. /**
  401. * Get the state of the suppression of developer (author) warnings.
  402. * Returns false, by default, if developer warnings should be shown, true
  403. * otherwise.
  404. */
  405. bool GetSuppressDevWarnings() const;
  406. /**
  407. * Set the state of the suppression of developer (author) warnings.
  408. */
  409. void SetSuppressDevWarnings(bool v);
  410. /**
  411. * Get the state of the suppression of deprecated warnings.
  412. * Returns false, by default, if deprecated warnings should be shown, true
  413. * otherwise.
  414. */
  415. bool GetSuppressDeprecatedWarnings() const;
  416. /**
  417. * Set the state of the suppression of deprecated warnings.
  418. */
  419. void SetSuppressDeprecatedWarnings(bool v);
  420. /**
  421. * Get the state of treating developer (author) warnings as errors.
  422. * Returns false, by default, if warnings should not be treated as errors,
  423. * true otherwise.
  424. */
  425. bool GetDevWarningsAsErrors() const;
  426. /**
  427. * Set the state of treating developer (author) warnings as errors.
  428. */
  429. void SetDevWarningsAsErrors(bool v);
  430. /**
  431. * Get the state of treating deprecated warnings as errors.
  432. * Returns false, by default, if warnings should not be treated as errors,
  433. * true otherwise.
  434. */
  435. bool GetDeprecatedWarningsAsErrors() const;
  436. /**
  437. * Set the state of treating developer (author) warnings as errors.
  438. */
  439. void SetDeprecatedWarningsAsErrors(bool v);
  440. /** Display a message to the user. */
  441. void IssueMessage(
  442. MessageType t, std::string const& text,
  443. cmListFileBacktrace const& backtrace = cmListFileBacktrace()) const;
  444. //! run the --build option
  445. int Build(int jobs, const std::string& dir,
  446. const std::vector<std::string>& targets, const std::string& config,
  447. const std::vector<std::string>& nativeOptions, bool clean,
  448. bool verbose);
  449. //! run the --open option
  450. bool Open(const std::string& dir, bool dryRun);
  451. void UnwatchUnusedCli(const std::string& var);
  452. void WatchUnusedCli(const std::string& var);
  453. cmState* GetState() const { return this->State.get(); }
  454. void SetCurrentSnapshot(cmStateSnapshot const& snapshot)
  455. {
  456. this->CurrentSnapshot = snapshot;
  457. }
  458. cmStateSnapshot GetCurrentSnapshot() const { return this->CurrentSnapshot; }
  459. bool GetRegenerateDuringBuild() const { return this->RegenerateDuringBuild; }
  460. #if !defined(CMAKE_BOOTSTRAP)
  461. cmMakefileProfilingData& GetProfilingOutput();
  462. bool IsProfilingEnabled() const;
  463. #endif
  464. protected:
  465. void RunCheckForUnusedVariables();
  466. int HandleDeleteCacheVariables(const std::string& var);
  467. using RegisteredGeneratorsVector =
  468. std::vector<std::unique_ptr<cmGlobalGeneratorFactory>>;
  469. RegisteredGeneratorsVector Generators;
  470. using RegisteredExtraGeneratorsVector =
  471. std::vector<cmExternalMakefileProjectGeneratorFactory*>;
  472. RegisteredExtraGeneratorsVector ExtraGenerators;
  473. void AddScriptingCommands();
  474. void AddProjectCommands();
  475. void AddDefaultGenerators();
  476. void AddDefaultExtraGenerators();
  477. std::map<std::string, DiagLevel> DiagLevels;
  478. std::string GeneratorInstance;
  479. std::string GeneratorPlatform;
  480. std::string GeneratorToolset;
  481. bool GeneratorInstanceSet = false;
  482. bool GeneratorPlatformSet = false;
  483. bool GeneratorToolsetSet = false;
  484. //! read in a cmake list file to initialize the cache
  485. void ReadListFile(const std::vector<std::string>& args,
  486. const std::string& path);
  487. bool FindPackage(const std::vector<std::string>& args);
  488. //! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file.
  489. /// If it is set, truncate it to 50kb
  490. void TruncateOutputLog(const char* fname);
  491. /**
  492. * Method called to check build system integrity at build time.
  493. * Returns 1 if CMake should rerun and 0 otherwise.
  494. */
  495. int CheckBuildSystem();
  496. void SetDirectoriesFromFile(const std::string& arg);
  497. //! Make sure all commands are what they say they are and there is no
  498. /// macros.
  499. void CleanupCommandsAndMacros();
  500. void GenerateGraphViz(const std::string& fileName) const;
  501. private:
  502. ProgressCallbackType ProgressCallback;
  503. WorkingMode CurrentWorkingMode = NORMAL_MODE;
  504. bool DebugOutput = false;
  505. bool DebugFindOutput = false;
  506. bool Trace = false;
  507. bool TraceExpand = false;
  508. TraceFormat TraceFormatVar = TRACE_HUMAN;
  509. cmGeneratedFileStream TraceFile;
  510. bool WarnUninitialized = false;
  511. bool WarnUnusedCli = true;
  512. bool CheckSystemVars = false;
  513. std::map<std::string, bool> UsedCliVariables;
  514. std::string CMakeEditCommand;
  515. std::string CXXEnvironment;
  516. std::string CCEnvironment;
  517. std::string CheckBuildSystemArgument;
  518. std::string CheckStampFile;
  519. std::string CheckStampList;
  520. std::string VSSolutionFile;
  521. std::string EnvironmentGenerator;
  522. FileExtensions CLikeSourceFileExtensions;
  523. FileExtensions HeaderFileExtensions;
  524. FileExtensions CudaFileExtensions;
  525. FileExtensions ISPCFileExtensions;
  526. FileExtensions FortranFileExtensions;
  527. bool ClearBuildSystem = false;
  528. bool DebugTryCompile = false;
  529. bool RegenerateDuringBuild = false;
  530. std::unique_ptr<cmFileTimeCache> FileTimeCache;
  531. std::string GraphVizFile;
  532. InstalledFilesMap InstalledFiles;
  533. #if !defined(CMAKE_BOOTSTRAP)
  534. std::unique_ptr<cmVariableWatch> VariableWatch;
  535. std::unique_ptr<cmFileAPI> FileAPI;
  536. #endif
  537. std::unique_ptr<cmState> State;
  538. cmStateSnapshot CurrentSnapshot;
  539. std::unique_ptr<cmMessenger> Messenger;
  540. std::vector<std::string> TraceOnlyThisSources;
  541. LogLevel MessageLogLevel = LogLevel::LOG_STATUS;
  542. bool LogLevelWasSetViaCLI = false;
  543. bool LogContext = false;
  544. std::stack<std::string> CheckInProgressMessages;
  545. std::unique_ptr<cmGlobalGenerator> GlobalGenerator;
  546. void UpdateConversionPathTable();
  547. //! Print a list of valid generators to stderr.
  548. void PrintGeneratorList();
  549. std::unique_ptr<cmGlobalGenerator> EvaluateDefaultGlobalGenerator();
  550. void CreateDefaultGlobalGenerator();
  551. void AppendGlobalGeneratorsDocumentation(std::vector<cmDocumentationEntry>&);
  552. void AppendExtraGeneratorsDocumentation(std::vector<cmDocumentationEntry>&);
  553. #if !defined(CMAKE_BOOTSTRAP)
  554. std::unique_ptr<cmMakefileProfilingData> ProfilingOutput;
  555. #endif
  556. };
  557. #define CMAKE_STANDARD_OPTIONS_TABLE \
  558. { "-S <path-to-source>", "Explicitly specify a source directory." }, \
  559. { "-B <path-to-build>", "Explicitly specify a build directory." }, \
  560. { "-C <initial-cache>", "Pre-load a script to populate the cache." }, \
  561. { "-D <var>[:<type>]=<value>", "Create or update a cmake cache entry." }, \
  562. { "-U <globbing_expr>", "Remove matching entries from CMake cache." }, \
  563. { "-G <generator-name>", "Specify a build system generator." }, \
  564. { "-T <toolset-name>", \
  565. "Specify toolset name if supported by generator." }, \
  566. { "-A <platform-name>", \
  567. "Specify platform name if supported by generator." }, \
  568. { "-Wdev", "Enable developer warnings." }, \
  569. { "-Wno-dev", "Suppress developer warnings." }, \
  570. { "-Werror=dev", "Make developer warnings errors." }, \
  571. { "-Wno-error=dev", "Make developer warnings not errors." }, \
  572. { "-Wdeprecated", "Enable deprecation warnings." }, \
  573. { "-Wno-deprecated", "Suppress deprecation warnings." }, \
  574. { "-Werror=deprecated", \
  575. "Make deprecated macro and function warnings " \
  576. "errors." }, \
  577. { \
  578. "-Wno-error=deprecated", \
  579. "Make deprecated macro and function warnings " \
  580. "not errors." \
  581. }
  582. #define FOR_EACH_C90_FEATURE(F) F(c_function_prototypes)
  583. #define FOR_EACH_C99_FEATURE(F) \
  584. F(c_restrict) \
  585. F(c_variadic_macros)
  586. #define FOR_EACH_C11_FEATURE(F) F(c_static_assert)
  587. #define FOR_EACH_C_FEATURE(F) \
  588. F(c_std_90) \
  589. F(c_std_99) \
  590. F(c_std_11) \
  591. FOR_EACH_C90_FEATURE(F) \
  592. FOR_EACH_C99_FEATURE(F) \
  593. FOR_EACH_C11_FEATURE(F)
  594. #define FOR_EACH_CXX98_FEATURE(F) F(cxx_template_template_parameters)
  595. #define FOR_EACH_CXX11_FEATURE(F) \
  596. F(cxx_alias_templates) \
  597. F(cxx_alignas) \
  598. F(cxx_alignof) \
  599. F(cxx_attributes) \
  600. F(cxx_auto_type) \
  601. F(cxx_constexpr) \
  602. F(cxx_decltype) \
  603. F(cxx_decltype_incomplete_return_types) \
  604. F(cxx_default_function_template_args) \
  605. F(cxx_defaulted_functions) \
  606. F(cxx_defaulted_move_initializers) \
  607. F(cxx_delegating_constructors) \
  608. F(cxx_deleted_functions) \
  609. F(cxx_enum_forward_declarations) \
  610. F(cxx_explicit_conversions) \
  611. F(cxx_extended_friend_declarations) \
  612. F(cxx_extern_templates) \
  613. F(cxx_final) \
  614. F(cxx_func_identifier) \
  615. F(cxx_generalized_initializers) \
  616. F(cxx_inheriting_constructors) \
  617. F(cxx_inline_namespaces) \
  618. F(cxx_lambdas) \
  619. F(cxx_local_type_template_args) \
  620. F(cxx_long_long_type) \
  621. F(cxx_noexcept) \
  622. F(cxx_nonstatic_member_init) \
  623. F(cxx_nullptr) \
  624. F(cxx_override) \
  625. F(cxx_range_for) \
  626. F(cxx_raw_string_literals) \
  627. F(cxx_reference_qualified_functions) \
  628. F(cxx_right_angle_brackets) \
  629. F(cxx_rvalue_references) \
  630. F(cxx_sizeof_member) \
  631. F(cxx_static_assert) \
  632. F(cxx_strong_enums) \
  633. F(cxx_thread_local) \
  634. F(cxx_trailing_return_types) \
  635. F(cxx_unicode_literals) \
  636. F(cxx_uniform_initialization) \
  637. F(cxx_unrestricted_unions) \
  638. F(cxx_user_literals) \
  639. F(cxx_variadic_macros) \
  640. F(cxx_variadic_templates)
  641. #define FOR_EACH_CXX14_FEATURE(F) \
  642. F(cxx_aggregate_default_initializers) \
  643. F(cxx_attribute_deprecated) \
  644. F(cxx_binary_literals) \
  645. F(cxx_contextual_conversions) \
  646. F(cxx_decltype_auto) \
  647. F(cxx_digit_separators) \
  648. F(cxx_generic_lambdas) \
  649. F(cxx_lambda_init_captures) \
  650. F(cxx_relaxed_constexpr) \
  651. F(cxx_return_type_deduction) \
  652. F(cxx_variable_templates)
  653. #define FOR_EACH_CXX_FEATURE(F) \
  654. F(cxx_std_98) \
  655. F(cxx_std_11) \
  656. F(cxx_std_14) \
  657. F(cxx_std_17) \
  658. F(cxx_std_20) \
  659. FOR_EACH_CXX98_FEATURE(F) \
  660. FOR_EACH_CXX11_FEATURE(F) \
  661. FOR_EACH_CXX14_FEATURE(F)
  662. #define FOR_EACH_CUDA_FEATURE(F) \
  663. F(cuda_std_03) \
  664. F(cuda_std_11) \
  665. F(cuda_std_14) \
  666. F(cuda_std_17) \
  667. F(cuda_std_20)