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

Function cmIncludeCommand

Source/cmIncludeCommand.cxx:19–196  ·  view source on GitHub ↗

cmIncludeCommand

Source from the content-addressed store, hash-verified

17
18// cmIncludeCommand
19bool cmIncludeCommand(std::vector<std::string> const& args,
20 cmExecutionStatus& status)
21{
22 static std::map<std::string, cmPolicies::PolicyID> DeprecatedModules;
23 if (DeprecatedModules.empty()) {
24 DeprecatedModules["CMakeDetermineVSServicePack"] = cmPolicies::CMP0196;
25 DeprecatedModules["CMakeFindFrameworks"] = cmPolicies::CMP0173;
26 DeprecatedModules["Dart"] = cmPolicies::CMP0145;
27 DeprecatedModules["Documentation"] = cmPolicies::CMP0106;
28 DeprecatedModules["FindBoost"] = cmPolicies::CMP0167;
29 DeprecatedModules["FindCABLE"] = cmPolicies::CMP0191;
30 DeprecatedModules["FindCUDA"] = cmPolicies::CMP0146;
31 DeprecatedModules["FindDart"] = cmPolicies::CMP0145;
32 DeprecatedModules["FindGCCXML"] = cmPolicies::CMP0188;
33 DeprecatedModules["FindPythonInterp"] = cmPolicies::CMP0148;
34 DeprecatedModules["FindPythonLibs"] = cmPolicies::CMP0148;
35 DeprecatedModules["WriteCompilerDetectionHeader"] = cmPolicies::CMP0120;
36 }
37
38 if (args.empty() || args.size() > 4) {
39 status.SetError("called with wrong number of arguments. "
40 "include() only takes one file.");
41 return false;
42 }
43
44 if (status.GetMakefile().GetStateSnapshot().GetUnwindState() ==
45 cmStateEnums::UNWINDING) {
46 status.SetError("called while already in an UNWIND state");
47 return false;
48 }
49
50 bool optional = false;
51 bool noPolicyScope = false;
52 std::string fname = args[0];
53 std::string resultVarName;
54
55 for (unsigned int i = 1; i < args.size(); i++) {
56 if (args[i] == "OPTIONAL") {
57 if (optional) {
58 status.SetError("called with invalid arguments: OPTIONAL used twice");
59 return false;
60 }
61 optional = true;
62 } else if (args[i] == "RESULT_VARIABLE") {
63 if (!resultVarName.empty()) {
64 status.SetError("called with invalid arguments: "
65 "only one result variable allowed");
66 return false;
67 }
68 if (++i < args.size()) {
69 resultVarName = args[i];
70 } else {
71 status.SetError("called with no value for RESULT_VARIABLE.");
72 return false;
73 }
74 } else if (args[i] == "NO_POLICY_SCOPE") {
75 noPolicyScope = true;
76 } else if (i > 1) // compat.: in previous cmake versions the second

Callers

nothing calls this directly

Calls 15

GetUnwindStateMethod · 0.80
IsExportedTargetsFileMethod · 0.80
ReadDependentFileMethod · 0.80
c_strMethod · 0.80
GetUnwindTypeMethod · 0.80
SetReturnInvokedMethod · 0.80
cmStrCatFunction · 0.70
FileExistsFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
SetErrorMethod · 0.45
GetStateSnapshotMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…