cmake.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  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 "cmState.h"
  22. #include "cmStateSnapshot.h"
  23. #include "cmStateTypes.h"
  24. #if !defined(CMAKE_BOOTSTRAP)
  25. # include "cm_jsoncpp_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. const std::vector<std::string>& GetSourceExtensions() const
  231. {
  232. return this->SourceFileExtensions.ordered;
  233. }
  234. bool IsSourceExtension(cm::string_view ext) const
  235. {
  236. return this->SourceFileExtensions.Test(ext);
  237. }
  238. const std::vector<std::string>& GetHeaderExtensions() const
  239. {
  240. return this->HeaderFileExtensions.ordered;
  241. }
  242. bool IsHeaderExtension(cm::string_view ext) const
  243. {
  244. return this->HeaderFileExtensions.Test(ext);
  245. }
  246. const std::vector<std::string>& GetCudaExtensions() const
  247. {
  248. return this->CudaFileExtensions.ordered;
  249. }
  250. bool IsCudaExtension(cm::string_view ext) const
  251. {
  252. return this->CudaFileExtensions.Test(ext);
  253. }
  254. const std::vector<std::string>& GetFortranExtensions() const
  255. {
  256. return this->FortranFileExtensions.ordered;
  257. }
  258. bool IsFortranExtension(cm::string_view ext) const
  259. {
  260. return this->FortranFileExtensions.Test(ext);
  261. }
  262. // Strips the extension (if present and known) from a filename
  263. std::string StripExtension(const std::string& file) const;
  264. /**
  265. * Given a variable name, return its value (as a string).
  266. */
  267. const char* GetCacheDefinition(const std::string&) const;
  268. //! Add an entry into the cache
  269. void AddCacheEntry(const std::string& key, const char* value,
  270. const char* helpString, int type);
  271. bool DoWriteGlobVerifyTarget() const;
  272. std::string const& GetGlobVerifyScript() const;
  273. std::string const& GetGlobVerifyStamp() const;
  274. void AddGlobCacheEntry(bool recurse, bool listDirectories,
  275. bool followSymlinks, const std::string& relative,
  276. const std::string& expression,
  277. const std::vector<std::string>& files,
  278. const std::string& variable,
  279. cmListFileBacktrace const& bt);
  280. /**
  281. * Get the system information and write it to the file specified
  282. */
  283. int GetSystemInformation(std::vector<std::string>&);
  284. //! Parse environment variables
  285. void LoadEnvironmentPresets();
  286. //! Parse command line arguments
  287. void SetArgs(const std::vector<std::string>& args);
  288. //! Is this cmake running as a result of a TRY_COMPILE command
  289. bool GetIsInTryCompile() const;
  290. void SetIsInTryCompile(bool b);
  291. //! Parse command line arguments that might set cache values
  292. bool SetCacheArgs(const std::vector<std::string>&);
  293. using ProgressCallbackType = std::function<void(const std::string&, float)>;
  294. /**
  295. * Set the function used by GUIs to receive progress updates
  296. * Function gets passed: message as a const char*, a progress
  297. * amount ranging from 0 to 1.0 and client data. The progress
  298. * number provided may be negative in cases where a message is
  299. * to be displayed without any progress percentage.
  300. */
  301. void SetProgressCallback(ProgressCallbackType f);
  302. //! this is called by generators to update the progress
  303. void UpdateProgress(const std::string& msg, float prog);
  304. #if !defined(CMAKE_BOOTSTRAP)
  305. //! Get the variable watch object
  306. cmVariableWatch* GetVariableWatch() { return this->VariableWatch.get(); }
  307. #endif
  308. std::vector<cmDocumentationEntry> GetGeneratorsDocumentation();
  309. //! Set/Get a property of this target file
  310. void SetProperty(const std::string& prop, const char* value);
  311. void AppendProperty(const std::string& prop, const std::string& value,
  312. bool asString = false);
  313. const char* GetProperty(const std::string& prop);
  314. bool GetPropertyAsBool(const std::string& prop);
  315. //! Get or create an cmInstalledFile instance and return a pointer to it
  316. cmInstalledFile* GetOrCreateInstalledFile(cmMakefile* mf,
  317. const std::string& name);
  318. cmInstalledFile const* GetInstalledFile(const std::string& name) const;
  319. InstalledFilesMap const& GetInstalledFiles() const
  320. {
  321. return this->InstalledFiles;
  322. }
  323. //! Do all the checks before running configure
  324. int DoPreConfigureChecks();
  325. void SetWorkingMode(WorkingMode mode) { this->CurrentWorkingMode = mode; }
  326. WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; }
  327. //! Debug the try compile stuff by not deleting the files
  328. bool GetDebugTryCompile() { return this->DebugTryCompile; }
  329. void DebugTryCompileOn() { this->DebugTryCompile = true; }
  330. /**
  331. * Generate CMAKE_ROOT and CMAKE_COMMAND cache entries
  332. */
  333. int AddCMakePaths();
  334. /**
  335. * Get the file comparison class
  336. */
  337. cmFileTimeCache* GetFileTimeCache() { return this->FileTimeCache.get(); }
  338. bool WasLogLevelSetViaCLI() const { return this->LogLevelWasSetViaCLI; }
  339. //! Get the selected log level for `message()` commands during the cmake run.
  340. LogLevel GetLogLevel() const { return this->MessageLogLevel; }
  341. void SetLogLevel(LogLevel level) { this->MessageLogLevel = level; }
  342. static LogLevel StringToLogLevel(const std::string& levelStr);
  343. static TraceFormat StringToTraceFormat(const std::string& levelStr);
  344. bool HasCheckInProgress() const
  345. {
  346. return !this->CheckInProgressMessages.empty();
  347. }
  348. std::size_t GetCheckInProgressSize() const
  349. {
  350. return this->CheckInProgressMessages.size();
  351. }
  352. std::string GetTopCheckInProgressMessage()
  353. {
  354. auto message = this->CheckInProgressMessages.top();
  355. this->CheckInProgressMessages.pop();
  356. return message;
  357. }
  358. void PushCheckInProgressMessage(std::string message)
  359. {
  360. this->CheckInProgressMessages.emplace(std::move(message));
  361. }
  362. //! Should `message` command display context.
  363. bool GetShowLogContext() const { return this->LogContext; }
  364. void SetShowLogContext(bool b) { this->LogContext = b; }
  365. //! Do we want debug output during the cmake run.
  366. bool GetDebugOutput() { return this->DebugOutput; }
  367. void SetDebugOutputOn(bool b) { this->DebugOutput = b; }
  368. //! Do we want debug output from the find commands during the cmake run.
  369. bool GetDebugFindOutput() { return this->DebugFindOutput; }
  370. void SetDebugFindOutputOn(bool b) { this->DebugFindOutput = b; }
  371. //! Do we want trace output during the cmake run.
  372. bool GetTrace() const { return this->Trace; }
  373. void SetTrace(bool b) { this->Trace = b; }
  374. bool GetTraceExpand() const { return this->TraceExpand; }
  375. void SetTraceExpand(bool b) { this->TraceExpand = b; }
  376. TraceFormat GetTraceFormat() const { return this->TraceFormatVar; }
  377. void SetTraceFormat(TraceFormat f) { this->TraceFormatVar = f; }
  378. void AddTraceSource(std::string const& file)
  379. {
  380. this->TraceOnlyThisSources.push_back(file);
  381. }
  382. std::vector<std::string> const& GetTraceSources() const
  383. {
  384. return this->TraceOnlyThisSources;
  385. }
  386. cmGeneratedFileStream& GetTraceFile() { return this->TraceFile; }
  387. void SetTraceFile(std::string const& file);
  388. void PrintTraceFormatVersion();
  389. bool GetWarnUninitialized() { return this->WarnUninitialized; }
  390. void SetWarnUninitialized(bool b) { this->WarnUninitialized = b; }
  391. bool GetWarnUnused() { return this->WarnUnused; }
  392. void SetWarnUnused(bool b) { this->WarnUnused = b; }
  393. bool GetWarnUnusedCli() { return this->WarnUnusedCli; }
  394. void SetWarnUnusedCli(bool b) { this->WarnUnusedCli = b; }
  395. bool GetCheckSystemVars() { return this->CheckSystemVars; }
  396. void SetCheckSystemVars(bool b) { this->CheckSystemVars = b; }
  397. void MarkCliAsUsed(const std::string& variable);
  398. /** Get the list of configurations (in upper case) considered to be
  399. debugging configurations.*/
  400. std::vector<std::string> GetDebugConfigs();
  401. void SetCMakeEditCommand(std::string const& s)
  402. {
  403. this->CMakeEditCommand = s;
  404. }
  405. std::string const& GetCMakeEditCommand() const
  406. {
  407. return this->CMakeEditCommand;
  408. }
  409. cmMessenger* GetMessenger() const { return this->Messenger.get(); }
  410. /**
  411. * Get the state of the suppression of developer (author) warnings.
  412. * Returns false, by default, if developer warnings should be shown, true
  413. * otherwise.
  414. */
  415. bool GetSuppressDevWarnings() const;
  416. /**
  417. * Set the state of the suppression of developer (author) warnings.
  418. */
  419. void SetSuppressDevWarnings(bool v);
  420. /**
  421. * Get the state of the suppression of deprecated warnings.
  422. * Returns false, by default, if deprecated warnings should be shown, true
  423. * otherwise.
  424. */
  425. bool GetSuppressDeprecatedWarnings() const;
  426. /**
  427. * Set the state of the suppression of deprecated warnings.
  428. */
  429. void SetSuppressDeprecatedWarnings(bool v);
  430. /**
  431. * Get the state of treating developer (author) warnings as errors.
  432. * Returns false, by default, if warnings should not be treated as errors,
  433. * true otherwise.
  434. */
  435. bool GetDevWarningsAsErrors() const;
  436. /**
  437. * Set the state of treating developer (author) warnings as errors.
  438. */
  439. void SetDevWarningsAsErrors(bool v);
  440. /**
  441. * Get the state of treating deprecated warnings as errors.
  442. * Returns false, by default, if warnings should not be treated as errors,
  443. * true otherwise.
  444. */
  445. bool GetDeprecatedWarningsAsErrors() const;
  446. /**
  447. * Set the state of treating developer (author) warnings as errors.
  448. */
  449. void SetDeprecatedWarningsAsErrors(bool v);
  450. /** Display a message to the user. */
  451. void IssueMessage(
  452. MessageType t, std::string const& text,
  453. cmListFileBacktrace const& backtrace = cmListFileBacktrace()) const;
  454. //! run the --build option
  455. int Build(int jobs, const std::string& dir,
  456. const std::vector<std::string>& targets, const std::string& config,
  457. const std::vector<std::string>& nativeOptions, bool clean,
  458. bool verbose);
  459. //! run the --open option
  460. bool Open(const std::string& dir, bool dryRun);
  461. void UnwatchUnusedCli(const std::string& var);
  462. void WatchUnusedCli(const std::string& var);
  463. cmState* GetState() const { return this->State.get(); }
  464. void SetCurrentSnapshot(cmStateSnapshot const& snapshot)
  465. {
  466. this->CurrentSnapshot = snapshot;
  467. }
  468. cmStateSnapshot GetCurrentSnapshot() const { return this->CurrentSnapshot; }
  469. bool GetRegenerateDuringBuild() const { return this->RegenerateDuringBuild; }
  470. #if !defined(CMAKE_BOOTSTRAP)
  471. cmMakefileProfilingData& GetProfilingOutput();
  472. bool IsProfilingEnabled() const;
  473. #endif
  474. protected:
  475. void RunCheckForUnusedVariables();
  476. int HandleDeleteCacheVariables(const std::string& var);
  477. using RegisteredGeneratorsVector =
  478. std::vector<std::unique_ptr<cmGlobalGeneratorFactory>>;
  479. RegisteredGeneratorsVector Generators;
  480. using RegisteredExtraGeneratorsVector =
  481. std::vector<cmExternalMakefileProjectGeneratorFactory*>;
  482. RegisteredExtraGeneratorsVector ExtraGenerators;
  483. void AddScriptingCommands();
  484. void AddProjectCommands();
  485. void AddDefaultGenerators();
  486. void AddDefaultExtraGenerators();
  487. std::map<std::string, DiagLevel> DiagLevels;
  488. std::string GeneratorInstance;
  489. std::string GeneratorPlatform;
  490. std::string GeneratorToolset;
  491. bool GeneratorInstanceSet = false;
  492. bool GeneratorPlatformSet = false;
  493. bool GeneratorToolsetSet = false;
  494. //! read in a cmake list file to initialize the cache
  495. void ReadListFile(const std::vector<std::string>& args,
  496. const std::string& path);
  497. bool FindPackage(const std::vector<std::string>& args);
  498. //! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file.
  499. /// If it is set, truncate it to 50kb
  500. void TruncateOutputLog(const char* fname);
  501. /**
  502. * Method called to check build system integrity at build time.
  503. * Returns 1 if CMake should rerun and 0 otherwise.
  504. */
  505. int CheckBuildSystem();
  506. void SetDirectoriesFromFile(const std::string& arg);
  507. //! Make sure all commands are what they say they are and there is no
  508. /// macros.
  509. void CleanupCommandsAndMacros();
  510. void GenerateGraphViz(const std::string& fileName) const;
  511. private:
  512. ProgressCallbackType ProgressCallback;
  513. WorkingMode CurrentWorkingMode = NORMAL_MODE;
  514. bool DebugOutput = false;
  515. bool DebugFindOutput = false;
  516. bool Trace = false;
  517. bool TraceExpand = false;
  518. TraceFormat TraceFormatVar = TRACE_HUMAN;
  519. cmGeneratedFileStream TraceFile;
  520. bool WarnUninitialized = false;
  521. bool WarnUnused = false;
  522. bool WarnUnusedCli = true;
  523. bool CheckSystemVars = false;
  524. std::map<std::string, bool> UsedCliVariables;
  525. std::string CMakeEditCommand;
  526. std::string CXXEnvironment;
  527. std::string CCEnvironment;
  528. std::string CheckBuildSystemArgument;
  529. std::string CheckStampFile;
  530. std::string CheckStampList;
  531. std::string VSSolutionFile;
  532. std::string EnvironmentGenerator;
  533. FileExtensions SourceFileExtensions;
  534. FileExtensions HeaderFileExtensions;
  535. FileExtensions CudaFileExtensions;
  536. FileExtensions FortranFileExtensions;
  537. bool ClearBuildSystem = false;
  538. bool DebugTryCompile = false;
  539. bool RegenerateDuringBuild = false;
  540. std::unique_ptr<cmFileTimeCache> FileTimeCache;
  541. std::string GraphVizFile;
  542. InstalledFilesMap InstalledFiles;
  543. #if !defined(CMAKE_BOOTSTRAP)
  544. std::unique_ptr<cmVariableWatch> VariableWatch;
  545. std::unique_ptr<cmFileAPI> FileAPI;
  546. #endif
  547. std::unique_ptr<cmState> State;
  548. cmStateSnapshot CurrentSnapshot;
  549. std::unique_ptr<cmMessenger> Messenger;
  550. std::vector<std::string> TraceOnlyThisSources;
  551. LogLevel MessageLogLevel = LogLevel::LOG_STATUS;
  552. bool LogLevelWasSetViaCLI = false;
  553. bool LogContext = false;
  554. std::stack<std::string> CheckInProgressMessages;
  555. std::unique_ptr<cmGlobalGenerator> GlobalGenerator;
  556. void UpdateConversionPathTable();
  557. //! Print a list of valid generators to stderr.
  558. void PrintGeneratorList();
  559. std::unique_ptr<cmGlobalGenerator> EvaluateDefaultGlobalGenerator();
  560. void CreateDefaultGlobalGenerator();
  561. void AppendGlobalGeneratorsDocumentation(std::vector<cmDocumentationEntry>&);
  562. void AppendExtraGeneratorsDocumentation(std::vector<cmDocumentationEntry>&);
  563. #if !defined(CMAKE_BOOTSTRAP)
  564. std::unique_ptr<cmMakefileProfilingData> ProfilingOutput;
  565. #endif
  566. };
  567. #define CMAKE_STANDARD_OPTIONS_TABLE \
  568. { "-S <path-to-source>", "Explicitly specify a source directory." }, \
  569. { "-B <path-to-build>", "Explicitly specify a build directory." }, \
  570. { "-C <initial-cache>", "Pre-load a script to populate the cache." }, \
  571. { "-D <var>[:<type>]=<value>", "Create or update a cmake cache entry." }, \
  572. { "-U <globbing_expr>", "Remove matching entries from CMake cache." }, \
  573. { "-G <generator-name>", "Specify a build system generator." }, \
  574. { "-T <toolset-name>", \
  575. "Specify toolset name if supported by generator." }, \
  576. { "-A <platform-name>", \
  577. "Specify platform name if supported by generator." }, \
  578. { "-Wdev", "Enable developer warnings." }, \
  579. { "-Wno-dev", "Suppress developer warnings." }, \
  580. { "-Werror=dev", "Make developer warnings errors." }, \
  581. { "-Wno-error=dev", "Make developer warnings not errors." }, \
  582. { "-Wdeprecated", "Enable deprecation warnings." }, \
  583. { "-Wno-deprecated", "Suppress deprecation warnings." }, \
  584. { "-Werror=deprecated", \
  585. "Make deprecated macro and function warnings " \
  586. "errors." }, \
  587. { \
  588. "-Wno-error=deprecated", \
  589. "Make deprecated macro and function warnings " \
  590. "not errors." \
  591. }
  592. #define FOR_EACH_C90_FEATURE(F) F(c_function_prototypes)
  593. #define FOR_EACH_C99_FEATURE(F) \
  594. F(c_restrict) \
  595. F(c_variadic_macros)
  596. #define FOR_EACH_C11_FEATURE(F) F(c_static_assert)
  597. #define FOR_EACH_C_FEATURE(F) \
  598. F(c_std_90) \
  599. F(c_std_99) \
  600. F(c_std_11) \
  601. FOR_EACH_C90_FEATURE(F) \
  602. FOR_EACH_C99_FEATURE(F) \
  603. FOR_EACH_C11_FEATURE(F)
  604. #define FOR_EACH_CXX98_FEATURE(F) F(cxx_template_template_parameters)
  605. #define FOR_EACH_CXX11_FEATURE(F) \
  606. F(cxx_alias_templates) \
  607. F(cxx_alignas) \
  608. F(cxx_alignof) \
  609. F(cxx_attributes) \
  610. F(cxx_auto_type) \
  611. F(cxx_constexpr) \
  612. F(cxx_decltype) \
  613. F(cxx_decltype_incomplete_return_types) \
  614. F(cxx_default_function_template_args) \
  615. F(cxx_defaulted_functions) \
  616. F(cxx_defaulted_move_initializers) \
  617. F(cxx_delegating_constructors) \
  618. F(cxx_deleted_functions) \
  619. F(cxx_enum_forward_declarations) \
  620. F(cxx_explicit_conversions) \
  621. F(cxx_extended_friend_declarations) \
  622. F(cxx_extern_templates) \
  623. F(cxx_final) \
  624. F(cxx_func_identifier) \
  625. F(cxx_generalized_initializers) \
  626. F(cxx_inheriting_constructors) \
  627. F(cxx_inline_namespaces) \
  628. F(cxx_lambdas) \
  629. F(cxx_local_type_template_args) \
  630. F(cxx_long_long_type) \
  631. F(cxx_noexcept) \
  632. F(cxx_nonstatic_member_init) \
  633. F(cxx_nullptr) \
  634. F(cxx_override) \
  635. F(cxx_range_for) \
  636. F(cxx_raw_string_literals) \
  637. F(cxx_reference_qualified_functions) \
  638. F(cxx_right_angle_brackets) \
  639. F(cxx_rvalue_references) \
  640. F(cxx_sizeof_member) \
  641. F(cxx_static_assert) \
  642. F(cxx_strong_enums) \
  643. F(cxx_thread_local) \
  644. F(cxx_trailing_return_types) \
  645. F(cxx_unicode_literals) \
  646. F(cxx_uniform_initialization) \
  647. F(cxx_unrestricted_unions) \
  648. F(cxx_user_literals) \
  649. F(cxx_variadic_macros) \
  650. F(cxx_variadic_templates)
  651. #define FOR_EACH_CXX14_FEATURE(F) \
  652. F(cxx_aggregate_default_initializers) \
  653. F(cxx_attribute_deprecated) \
  654. F(cxx_binary_literals) \
  655. F(cxx_contextual_conversions) \
  656. F(cxx_decltype_auto) \
  657. F(cxx_digit_separators) \
  658. F(cxx_generic_lambdas) \
  659. F(cxx_lambda_init_captures) \
  660. F(cxx_relaxed_constexpr) \
  661. F(cxx_return_type_deduction) \
  662. F(cxx_variable_templates)
  663. #define FOR_EACH_CXX_FEATURE(F) \
  664. F(cxx_std_98) \
  665. F(cxx_std_11) \
  666. F(cxx_std_14) \
  667. F(cxx_std_17) \
  668. F(cxx_std_20) \
  669. FOR_EACH_CXX98_FEATURE(F) \
  670. FOR_EACH_CXX11_FEATURE(F) \
  671. FOR_EACH_CXX14_FEATURE(F)
  672. #define FOR_EACH_CUDA_FEATURE(F) \
  673. F(cuda_std_03) \
  674. F(cuda_std_11) \
  675. F(cuda_std_14) \
  676. F(cuda_std_17) \
  677. F(cuda_std_20)
  678. #endif