cmStandardLevelResolver.cxx 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmStandardLevelResolver.h"
  4. #include <algorithm>
  5. #include <cassert>
  6. #include <cstddef>
  7. #include <sstream>
  8. #include <stdexcept>
  9. #include <unordered_map>
  10. #include <utility>
  11. #include <vector>
  12. #include <cm/iterator>
  13. #include <cmext/algorithm>
  14. #include "cmGeneratorExpression.h"
  15. #include "cmGeneratorTarget.h"
  16. #include "cmGlobalGenerator.h"
  17. #include "cmMakefile.h"
  18. #include "cmMessageType.h"
  19. #include "cmPolicies.h"
  20. #include "cmStringAlgorithms.h"
  21. #include "cmTarget.h"
  22. #include "cmValue.h"
  23. #include "cmake.h"
  24. namespace {
  25. #define FEATURE_STRING(F) , #F
  26. const char* const C_FEATURES[] = { nullptr FOR_EACH_C_FEATURE(
  27. FEATURE_STRING) };
  28. const char* const CXX_FEATURES[] = { nullptr FOR_EACH_CXX_FEATURE(
  29. FEATURE_STRING) };
  30. const char* const CUDA_FEATURES[] = { nullptr FOR_EACH_CUDA_FEATURE(
  31. FEATURE_STRING) };
  32. const char* const HIP_FEATURES[] = { nullptr FOR_EACH_HIP_FEATURE(
  33. FEATURE_STRING) };
  34. #undef FEATURE_STRING
  35. struct StandardNeeded
  36. {
  37. int index;
  38. int value;
  39. };
  40. int ParseStd(std::string const& level)
  41. {
  42. try {
  43. return std::stoi(level);
  44. } catch (std::invalid_argument&) {
  45. // Fall through to use an invalid value.
  46. }
  47. return -1;
  48. }
  49. struct StandardLevelComputer
  50. {
  51. explicit StandardLevelComputer(std::string lang, std::vector<int> levels,
  52. std::vector<std::string> levelsStr)
  53. : Language(std::move(lang))
  54. , Levels(std::move(levels))
  55. , LevelsAsStrings(std::move(levelsStr))
  56. {
  57. assert(this->Levels.size() == this->LevelsAsStrings.size());
  58. }
  59. std::string GetCompileOptionDef(cmMakefile* makefile,
  60. cmGeneratorTarget const* target,
  61. std::string const& config) const
  62. {
  63. const auto& stds = this->Levels;
  64. const auto& stdsStrings = this->LevelsAsStrings;
  65. cmValue defaultStd = makefile->GetDefinition(
  66. cmStrCat("CMAKE_", this->Language, "_STANDARD_DEFAULT"));
  67. if (!cmNonempty(defaultStd)) {
  68. // this compiler has no notion of language standard levels
  69. return std::string{};
  70. }
  71. cmPolicies::PolicyStatus const cmp0128{ makefile->GetPolicyStatus(
  72. cmPolicies::CMP0128) };
  73. bool const defaultExt{ cmIsOn(*makefile->GetDefinition(
  74. cmStrCat("CMAKE_", this->Language, "_EXTENSIONS_DEFAULT"))) };
  75. bool ext = true;
  76. if (cmp0128 == cmPolicies::NEW) {
  77. ext = defaultExt;
  78. }
  79. if (cmValue extPropValue = target->GetLanguageExtensions(this->Language)) {
  80. ext = cmIsOn(*extPropValue);
  81. }
  82. std::string const type{ ext ? "EXTENSION" : "STANDARD" };
  83. cmValue standardProp = target->GetLanguageStandard(this->Language, config);
  84. if (!standardProp) {
  85. if (cmp0128 == cmPolicies::NEW) {
  86. // Add extension flag if compiler's default doesn't match.
  87. if (ext != defaultExt) {
  88. return cmStrCat("CMAKE_", this->Language, *defaultStd, "_", type,
  89. "_COMPILE_OPTION");
  90. }
  91. } else {
  92. if (cmp0128 == cmPolicies::WARN &&
  93. makefile->PolicyOptionalWarningEnabled(
  94. "CMAKE_POLICY_WARNING_CMP0128") &&
  95. ext != defaultExt) {
  96. const char* state{};
  97. if (ext) {
  98. if (!makefile->GetDefinition(cmStrCat(
  99. "CMAKE_", this->Language, "_EXTENSION_COMPILE_OPTION"))) {
  100. state = "enabled";
  101. }
  102. } else {
  103. state = "disabled";
  104. }
  105. if (state) {
  106. makefile->IssueMessage(
  107. MessageType::AUTHOR_WARNING,
  108. cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0128),
  109. "\nFor compatibility with older versions of CMake, "
  110. "compiler extensions won't be ",
  111. state, "."));
  112. }
  113. }
  114. if (ext) {
  115. return cmStrCat("CMAKE_", this->Language,
  116. "_EXTENSION_COMPILE_OPTION");
  117. }
  118. }
  119. return std::string{};
  120. }
  121. if (target->GetLanguageStandardRequired(this->Language)) {
  122. std::string option_flag = cmStrCat(
  123. "CMAKE_", this->Language, *standardProp, "_", type, "_COMPILE_OPTION");
  124. cmValue opt = target->Target->GetMakefile()->GetDefinition(option_flag);
  125. if (!opt) {
  126. std::ostringstream e;
  127. e << "Target \"" << target->GetName()
  128. << "\" requires the language "
  129. "dialect \""
  130. << this->Language << *standardProp << "\" "
  131. << (ext ? "(with compiler extensions)" : "")
  132. << ", but CMake "
  133. "does not know the compile flags to use to enable it.";
  134. makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
  135. }
  136. return option_flag;
  137. }
  138. // If the request matches the compiler's defaults we don't need to add
  139. // anything.
  140. if (*standardProp == *defaultStd && ext == defaultExt) {
  141. if (cmp0128 == cmPolicies::NEW) {
  142. return std::string{};
  143. }
  144. if (cmp0128 == cmPolicies::WARN &&
  145. makefile->PolicyOptionalWarningEnabled(
  146. "CMAKE_POLICY_WARNING_CMP0128")) {
  147. makefile->IssueMessage(
  148. MessageType::AUTHOR_WARNING,
  149. cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0128),
  150. "\nFor compatibility with older versions of CMake, "
  151. "unnecessary flags for language standard or compiler "
  152. "extensions may be added."));
  153. }
  154. }
  155. std::string standardStr(*standardProp);
  156. if (this->Language == "CUDA" && standardStr == "98") {
  157. standardStr = "03";
  158. }
  159. auto stdIt =
  160. std::find(cm::cbegin(stds), cm::cend(stds), ParseStd(standardStr));
  161. if (stdIt == cm::cend(stds)) {
  162. std::string e =
  163. cmStrCat(this->Language, "_STANDARD is set to invalid value '",
  164. standardStr, "'");
  165. makefile->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e,
  166. target->GetBacktrace());
  167. return std::string{};
  168. }
  169. auto defaultStdIt =
  170. std::find(cm::cbegin(stds), cm::cend(stds), ParseStd(*defaultStd));
  171. if (defaultStdIt == cm::cend(stds)) {
  172. std::string e = cmStrCat("CMAKE_", this->Language,
  173. "_STANDARD_DEFAULT is set to invalid value '",
  174. *defaultStd, "'");
  175. makefile->IssueMessage(MessageType::INTERNAL_ERROR, e);
  176. return std::string{};
  177. }
  178. // If the standard requested is older than the compiler's default or the
  179. // extension mode doesn't match then we need to use a flag.
  180. if (stdIt < defaultStdIt ||
  181. (cmp0128 == cmPolicies::NEW && ext != defaultExt)) {
  182. auto offset = std::distance(cm::cbegin(stds), stdIt);
  183. return cmStrCat("CMAKE_", this->Language, stdsStrings[offset], "_", type,
  184. "_COMPILE_OPTION");
  185. }
  186. // The compiler's default is at least as new as the requested standard,
  187. // and the requested standard is not required. Decay to the newest
  188. // standard for which a flag is defined.
  189. for (; defaultStdIt < stdIt; --stdIt) {
  190. auto offset = std::distance(cm::cbegin(stds), stdIt);
  191. std::string option_flag =
  192. cmStrCat("CMAKE_", this->Language, stdsStrings[offset], "_", type,
  193. "_COMPILE_OPTION");
  194. if (target->Target->GetMakefile()->GetDefinition(option_flag)) {
  195. return option_flag;
  196. }
  197. }
  198. return std::string{};
  199. }
  200. bool GetNewRequiredStandard(cmMakefile* makefile,
  201. std::string const& targetName,
  202. const std::string& feature,
  203. cmValue currentLangStandardValue,
  204. std::string& newRequiredStandard,
  205. std::string* error) const
  206. {
  207. if (currentLangStandardValue) {
  208. newRequiredStandard = *currentLangStandardValue;
  209. } else {
  210. newRequiredStandard.clear();
  211. }
  212. auto needed = this->HighestStandardNeeded(makefile, feature);
  213. cmValue existingStandard = currentLangStandardValue;
  214. if (!existingStandard) {
  215. cmValue defaultStandard = makefile->GetDefinition(
  216. cmStrCat("CMAKE_", this->Language, "_STANDARD_DEFAULT"));
  217. if (cmNonempty(defaultStandard)) {
  218. existingStandard = defaultStandard;
  219. }
  220. }
  221. auto existingLevelIter = cm::cend(this->Levels);
  222. if (existingStandard) {
  223. existingLevelIter =
  224. std::find(cm::cbegin(this->Levels), cm::cend(this->Levels),
  225. ParseStd(*existingStandard));
  226. if (existingLevelIter == cm::cend(this->Levels)) {
  227. const std::string e =
  228. cmStrCat("The ", this->Language, "_STANDARD property on target \"",
  229. targetName, "\" contained an invalid value: \"",
  230. *existingStandard, "\".");
  231. if (error) {
  232. *error = e;
  233. } else {
  234. makefile->IssueMessage(MessageType::FATAL_ERROR, e);
  235. }
  236. return false;
  237. }
  238. }
  239. if (needed.index != -1) {
  240. // Ensure the C++ language level is high enough to support
  241. // the needed C++ features.
  242. if (existingLevelIter == cm::cend(this->Levels) ||
  243. existingLevelIter < this->Levels.begin() + needed.index) {
  244. newRequiredStandard = this->LevelsAsStrings[needed.index];
  245. }
  246. }
  247. return true;
  248. }
  249. bool HaveStandardAvailable(cmMakefile* makefile,
  250. cmGeneratorTarget const* target,
  251. std::string const& config,
  252. std::string const& feature) const
  253. {
  254. cmValue defaultStandard = makefile->GetDefinition(
  255. cmStrCat("CMAKE_", this->Language, "_STANDARD_DEFAULT"));
  256. if (!defaultStandard) {
  257. makefile->IssueMessage(
  258. MessageType::INTERNAL_ERROR,
  259. cmStrCat("CMAKE_", this->Language,
  260. "_STANDARD_DEFAULT is not set. COMPILE_FEATURES support "
  261. "not fully configured for this compiler."));
  262. // Return true so the caller does not try to lookup the default standard.
  263. return true;
  264. }
  265. // convert defaultStandard to an integer
  266. if (std::find(cm::cbegin(this->Levels), cm::cend(this->Levels),
  267. ParseStd(*defaultStandard)) == cm::cend(this->Levels)) {
  268. const std::string e = cmStrCat("The CMAKE_", this->Language,
  269. "_STANDARD_DEFAULT variable contains an "
  270. "invalid value: \"",
  271. *defaultStandard, "\".");
  272. makefile->IssueMessage(MessageType::INTERNAL_ERROR, e);
  273. return false;
  274. }
  275. cmValue existingStandard =
  276. target->GetLanguageStandard(this->Language, config);
  277. if (!existingStandard) {
  278. existingStandard = defaultStandard;
  279. }
  280. auto existingLevelIter =
  281. std::find(cm::cbegin(this->Levels), cm::cend(this->Levels),
  282. ParseStd(*existingStandard));
  283. if (existingLevelIter == cm::cend(this->Levels)) {
  284. const std::string e =
  285. cmStrCat("The ", this->Language, "_STANDARD property on target \"",
  286. target->GetName(), "\" contained an invalid value: \"",
  287. *existingStandard, "\".");
  288. makefile->IssueMessage(MessageType::FATAL_ERROR, e);
  289. return false;
  290. }
  291. auto needed = this->HighestStandardNeeded(makefile, feature);
  292. return (needed.index == -1) ||
  293. (this->Levels.begin() + needed.index) <= existingLevelIter;
  294. }
  295. StandardNeeded HighestStandardNeeded(cmMakefile* makefile,
  296. std::string const& feature) const
  297. {
  298. std::string prefix = cmStrCat("CMAKE_", this->Language);
  299. StandardNeeded maxLevel = { -1, -1 };
  300. for (size_t i = 0; i < this->Levels.size(); ++i) {
  301. if (cmValue prop = makefile->GetDefinition(
  302. cmStrCat(prefix, this->LevelsAsStrings[i], "_COMPILE_FEATURES"))) {
  303. std::vector<std::string> props = cmExpandedList(*prop);
  304. if (cm::contains(props, feature)) {
  305. maxLevel = { static_cast<int>(i), this->Levels[i] };
  306. }
  307. }
  308. }
  309. return maxLevel;
  310. }
  311. bool IsLaterStandard(int lhs, int rhs) const
  312. {
  313. auto rhsIt =
  314. std::find(cm::cbegin(this->Levels), cm::cend(this->Levels), rhs);
  315. return std::find(rhsIt, cm::cend(this->Levels), lhs) !=
  316. cm::cend(this->Levels);
  317. }
  318. std::string Language;
  319. std::vector<int> Levels;
  320. std::vector<std::string> LevelsAsStrings;
  321. };
  322. std::unordered_map<std::string, StandardLevelComputer>
  323. StandardComputerMapping = {
  324. { "C",
  325. StandardLevelComputer{
  326. "C", std::vector<int>{ 90, 99, 11, 17, 23 },
  327. std::vector<std::string>{ "90", "99", "11", "17", "23" } } },
  328. { "CXX",
  329. StandardLevelComputer{
  330. "CXX", std::vector<int>{ 98, 11, 14, 17, 20, 23 },
  331. std::vector<std::string>{ "98", "11", "14", "17", "20", "23" } } },
  332. { "CUDA",
  333. StandardLevelComputer{
  334. "CUDA", std::vector<int>{ 03, 11, 14, 17, 20, 23 },
  335. std::vector<std::string>{ "03", "11", "14", "17", "20", "23" } } },
  336. { "OBJC",
  337. StandardLevelComputer{
  338. "OBJC", std::vector<int>{ 90, 99, 11, 17, 23 },
  339. std::vector<std::string>{ "90", "99", "11", "17", "23" } } },
  340. { "OBJCXX",
  341. StandardLevelComputer{
  342. "OBJCXX", std::vector<int>{ 98, 11, 14, 17, 20, 23 },
  343. std::vector<std::string>{ "98", "11", "14", "17", "20", "23" } } },
  344. { "HIP",
  345. StandardLevelComputer{
  346. "HIP", std::vector<int>{ 98, 11, 14, 17, 20, 23 },
  347. std::vector<std::string>{ "98", "11", "14", "17", "20", "23" } } }
  348. };
  349. }
  350. std::string cmStandardLevelResolver::GetCompileOptionDef(
  351. cmGeneratorTarget const* target, std::string const& lang,
  352. std::string const& config) const
  353. {
  354. const auto& mapping = StandardComputerMapping.find(lang);
  355. if (mapping == cm::cend(StandardComputerMapping)) {
  356. return std::string{};
  357. }
  358. return mapping->second.GetCompileOptionDef(this->Makefile, target, config);
  359. }
  360. bool cmStandardLevelResolver::AddRequiredTargetFeature(
  361. cmTarget* target, const std::string& feature, std::string* error) const
  362. {
  363. if (cmGeneratorExpression::Find(feature) != std::string::npos) {
  364. target->AppendProperty("COMPILE_FEATURES", feature);
  365. return true;
  366. }
  367. std::string lang;
  368. if (!this->CheckCompileFeaturesAvailable(target->GetName(), feature, lang,
  369. error)) {
  370. return false;
  371. }
  372. target->AppendProperty("COMPILE_FEATURES", feature);
  373. // FIXME: Add a policy to avoid updating the <LANG>_STANDARD target
  374. // property due to COMPILE_FEATURES. The language standard selection
  375. // should be done purely at generate time based on whatever the project
  376. // code put in these properties explicitly. That is mostly true now,
  377. // but for compatibility we need to continue updating the property here.
  378. std::string newRequiredStandard;
  379. bool newRequired = this->GetNewRequiredStandard(
  380. target->GetName(), feature,
  381. target->GetProperty(cmStrCat(lang, "_STANDARD")), newRequiredStandard,
  382. error);
  383. if (!newRequiredStandard.empty()) {
  384. target->SetProperty(cmStrCat(lang, "_STANDARD"), newRequiredStandard);
  385. }
  386. return newRequired;
  387. }
  388. bool cmStandardLevelResolver::CheckCompileFeaturesAvailable(
  389. const std::string& targetName, const std::string& feature, std::string& lang,
  390. std::string* error) const
  391. {
  392. if (!this->CompileFeatureKnown(targetName, feature, lang, error)) {
  393. return false;
  394. }
  395. if (!this->Makefile->GetGlobalGenerator()->GetLanguageEnabled(lang)) {
  396. return true;
  397. }
  398. cmValue features = this->CompileFeaturesAvailable(lang, error);
  399. if (!features) {
  400. return false;
  401. }
  402. std::vector<std::string> availableFeatures = cmExpandedList(features);
  403. if (!cm::contains(availableFeatures, feature)) {
  404. std::ostringstream e;
  405. e << "The compiler feature \"" << feature << "\" is not known to " << lang
  406. << " compiler\n\""
  407. << this->Makefile->GetSafeDefinition("CMAKE_" + lang + "_COMPILER_ID")
  408. << "\"\nversion "
  409. << this->Makefile->GetSafeDefinition("CMAKE_" + lang +
  410. "_COMPILER_VERSION")
  411. << ".";
  412. if (error) {
  413. *error = e.str();
  414. } else {
  415. this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
  416. }
  417. return false;
  418. }
  419. return true;
  420. }
  421. bool cmStandardLevelResolver::CompileFeatureKnown(
  422. const std::string& targetName, const std::string& feature, std::string& lang,
  423. std::string* error) const
  424. {
  425. assert(cmGeneratorExpression::Find(feature) == std::string::npos);
  426. bool isCFeature =
  427. std::find_if(cm::cbegin(C_FEATURES) + 1, cm::cend(C_FEATURES),
  428. cmStrCmp(feature)) != cm::cend(C_FEATURES);
  429. if (isCFeature) {
  430. lang = "C";
  431. return true;
  432. }
  433. bool isCxxFeature =
  434. std::find_if(cm::cbegin(CXX_FEATURES) + 1, cm::cend(CXX_FEATURES),
  435. cmStrCmp(feature)) != cm::cend(CXX_FEATURES);
  436. if (isCxxFeature) {
  437. lang = "CXX";
  438. return true;
  439. }
  440. bool isCudaFeature =
  441. std::find_if(cm::cbegin(CUDA_FEATURES) + 1, cm::cend(CUDA_FEATURES),
  442. cmStrCmp(feature)) != cm::cend(CUDA_FEATURES);
  443. if (isCudaFeature) {
  444. lang = "CUDA";
  445. return true;
  446. }
  447. bool isHIPFeature =
  448. std::find_if(cm::cbegin(HIP_FEATURES) + 1, cm::cend(HIP_FEATURES),
  449. cmStrCmp(feature)) != cm::cend(HIP_FEATURES);
  450. if (isHIPFeature) {
  451. lang = "HIP";
  452. return true;
  453. }
  454. std::ostringstream e;
  455. if (error) {
  456. e << "specified";
  457. } else {
  458. e << "Specified";
  459. }
  460. e << " unknown feature \"" << feature
  461. << "\" for "
  462. "target \""
  463. << targetName << "\".";
  464. if (error) {
  465. *error = e.str();
  466. } else {
  467. this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
  468. }
  469. return false;
  470. }
  471. cmValue cmStandardLevelResolver::CompileFeaturesAvailable(
  472. const std::string& lang, std::string* error) const
  473. {
  474. if (!this->Makefile->GetGlobalGenerator()->GetLanguageEnabled(lang)) {
  475. std::ostringstream e;
  476. if (error) {
  477. e << "cannot";
  478. } else {
  479. e << "Cannot";
  480. }
  481. e << " use features from non-enabled language " << lang;
  482. if (error) {
  483. *error = e.str();
  484. } else {
  485. this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
  486. }
  487. return nullptr;
  488. }
  489. cmValue featuresKnown =
  490. this->Makefile->GetDefinition("CMAKE_" + lang + "_COMPILE_FEATURES");
  491. if (!cmNonempty(featuresKnown)) {
  492. std::ostringstream e;
  493. if (error) {
  494. e << "no";
  495. } else {
  496. e << "No";
  497. }
  498. e << " known features for " << lang << " compiler\n\""
  499. << this->Makefile->GetSafeDefinition("CMAKE_" + lang + "_COMPILER_ID")
  500. << "\"\nversion "
  501. << this->Makefile->GetSafeDefinition("CMAKE_" + lang +
  502. "_COMPILER_VERSION")
  503. << ".";
  504. if (error) {
  505. *error = e.str();
  506. } else {
  507. this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
  508. }
  509. return nullptr;
  510. }
  511. return featuresKnown;
  512. }
  513. bool cmStandardLevelResolver::GetNewRequiredStandard(
  514. const std::string& targetName, const std::string& feature,
  515. cmValue currentLangStandardValue, std::string& newRequiredStandard,
  516. std::string* error) const
  517. {
  518. std::string lang;
  519. if (!this->CheckCompileFeaturesAvailable(targetName, feature, lang, error)) {
  520. return false;
  521. }
  522. auto mapping = StandardComputerMapping.find(lang);
  523. if (mapping != cm::cend(StandardComputerMapping)) {
  524. return mapping->second.GetNewRequiredStandard(
  525. this->Makefile, targetName, feature, currentLangStandardValue,
  526. newRequiredStandard, error);
  527. }
  528. return false;
  529. }
  530. bool cmStandardLevelResolver::HaveStandardAvailable(
  531. cmGeneratorTarget const* target, std::string const& lang,
  532. std::string const& config, const std::string& feature) const
  533. {
  534. auto mapping = StandardComputerMapping.find(lang);
  535. if (mapping != cm::cend(StandardComputerMapping)) {
  536. return mapping->second.HaveStandardAvailable(this->Makefile, target,
  537. config, feature);
  538. }
  539. return false;
  540. }
  541. bool cmStandardLevelResolver::IsLaterStandard(std::string const& lang,
  542. std::string const& lhs,
  543. std::string const& rhs) const
  544. {
  545. auto mapping = StandardComputerMapping.find(lang);
  546. if (mapping != cm::cend(StandardComputerMapping)) {
  547. return mapping->second.IsLaterStandard(std::stoi(lhs), std::stoi(rhs));
  548. }
  549. return false;
  550. }