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

Function cmAddSubDirectoryCommand

Source/cmAddSubDirectoryCommand.cxx:15–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13#include "cmSystemTools.h"
14
15bool cmAddSubDirectoryCommand(std::vector<std::string> const& args,
16 cmExecutionStatus& status)
17{
18 if (args.empty()) {
19 status.SetError("called with incorrect number of arguments");
20 return false;
21 }
22
23 cmMakefile& mf = status.GetMakefile();
24 // store the binpath
25 std::string const& srcArg = args.front();
26 std::string binArg;
27
28 bool excludeFromAll = false;
29 bool system = false;
30
31 // process the rest of the arguments looking for optional args
32 for (std::string const& arg : cmMakeRange(args).advance(1)) {
33 if (arg == "EXCLUDE_FROM_ALL") {
34 excludeFromAll = true;
35 continue;
36 }
37 if (arg == "SYSTEM") {
38 system = true;
39 continue;
40 }
41 if (binArg.empty()) {
42 binArg = arg;
43 } else {
44 status.SetError("called with incorrect number of arguments");
45 return false;
46 }
47 }
48 // "SYSTEM" directory property should also affects targets in nested
49 // subdirectories.
50 if (mf.GetPropertyAsBool("SYSTEM")) {
51 system = true;
52 }
53
54 // Compute the full path to the specified source directory.
55 // Interpret a relative path with respect to the current source directory.
56 std::string srcPath;
57 if (cmSystemTools::FileIsFullPath(srcArg)) {
58 srcPath = srcArg;
59 } else {
60 srcPath = cmStrCat(mf.GetCurrentSourceDirectory(), '/', srcArg);
61 }
62 if (!cmSystemTools::FileIsDirectory(srcPath)) {
63 std::string error = cmStrCat("given source \"", srcArg,
64 "\" which is not an existing directory.");
65 status.SetError(error);
66 return false;
67 }
68 srcPath =
69 cmSystemTools::CollapseFullPath(srcPath, mf.GetHomeOutputDirectory());
70
71 // Compute the full path to the binary directory.
72 std::string binPath;

Callers

nothing calls this directly

Calls 12

cmMakeRangeFunction · 0.85
lengthMethod · 0.80
AddSubDirectoryMethod · 0.80
cmStrCatFunction · 0.70
emptyMethod · 0.45
SetErrorMethod · 0.45
GetMakefileMethod · 0.45
frontMethod · 0.45
advanceMethod · 0.45
GetPropertyAsBoolMethod · 0.45
backMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…