cmake.h 29 KB

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