| 13 | #include "cmSystemTools.h" |
| 14 | |
| 15 | bool 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; |
nothing calls this directly
no test coverage detected
searching dependent graphs…