cmake.h 26 KB

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