MCPcopy Create free account
hub / github.com/Kitware/CMake / cmCMakeMinimumRequired

Function cmCMakeMinimumRequired

Source/cmCMakeMinimumRequired.cxx:21–125  ·  view source on GitHub ↗

cmCMakeMinimumRequired

Source from the content-addressed store, hash-verified

19
20// cmCMakeMinimumRequired
21bool cmCMakeMinimumRequired(std::vector<std::string> const& args,
22 cmExecutionStatus& status)
23{
24 // Process arguments.
25 std::string version_string;
26 bool doing_version = false;
27 std::vector<std::string> unknown_arguments;
28 for (std::string const& arg : args) {
29 if (arg == "VERSION") {
30 doing_version = true;
31 } else if (arg == "FATAL_ERROR") {
32 if (doing_version) {
33 status.SetError("called with no value for VERSION.");
34 return false;
35 }
36 doing_version = false;
37 } else if (doing_version) {
38 doing_version = false;
39 version_string = arg;
40 } else {
41 unknown_arguments.push_back(arg);
42 }
43 }
44 if (doing_version) {
45 status.SetError("called with no value for VERSION.");
46 return false;
47 }
48
49 // Make sure there was a version to check.
50 if (version_string.empty()) {
51 return EnforceUnknownArguments(std::string(), unknown_arguments, status);
52 }
53
54 // Separate the <min> version and any trailing ...<max> component.
55 std::string::size_type const dd = version_string.find("...");
56 std::string const version_min = version_string.substr(0, dd);
57 std::string const version_max = dd != std::string::npos
58 ? version_string.substr(dd + 3, std::string::npos)
59 : std::string();
60 if (dd != std::string::npos &&
61 (version_min.empty() || version_max.empty())) {
62 std::ostringstream e;
63 e << "VERSION \"" << version_string
64 << R"(" does not have a version on both sides of "...".)";
65 status.SetError(e.str());
66 return false;
67 }
68
69 // Save the required version string.
70 status.GetMakefile().AddDefinition("CMAKE_MINIMUM_REQUIRED_VERSION",
71 version_min);
72
73 // Get the current version number.
74 unsigned int current_major = cmVersion::GetMajorVersion();
75 unsigned int current_minor = cmVersion::GetMinorVersion();
76 unsigned int current_patch = cmVersion::GetPatchVersion();
77 unsigned int current_tweak = cmVersion::GetTweakVersion();
78

Callers

nothing calls this directly

Calls 12

EnforceUnknownArgumentsFunction · 0.85
push_backMethod · 0.80
strMethod · 0.80
c_strMethod · 0.80
SetPolicyVersionMethod · 0.80
SetErrorMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45
substrMethod · 0.45
AddDefinitionMethod · 0.45
GetMakefileMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…