cmake.h 29 KB

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