cmake.h 29 KB

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