cmake.h 29 KB

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