cmake.h 27 KB

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