/src/CMake/Source/cmSubdirCommand.cxx
Line | Count | Source |
1 | | /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying |
2 | | file LICENSE.rst or https://cmake.org/licensing for details. */ |
3 | | #include "cmSubdirCommand.h" |
4 | | |
5 | | #include "cmExecutionStatus.h" |
6 | | #include "cmMakefile.h" |
7 | | #include "cmStringAlgorithms.h" |
8 | | #include "cmSystemTools.h" |
9 | | |
10 | | bool cmSubdirCommand(std::vector<std::string> const& args, |
11 | | cmExecutionStatus& status) |
12 | 0 | { |
13 | 0 | if (args.empty()) { |
14 | 0 | status.SetError("called with incorrect number of arguments"); |
15 | 0 | return false; |
16 | 0 | } |
17 | 0 | bool res = true; |
18 | 0 | bool excludeFromAll = false; |
19 | 0 | cmMakefile& mf = status.GetMakefile(); |
20 | |
|
21 | 0 | for (std::string const& i : args) { |
22 | 0 | if (i == "EXCLUDE_FROM_ALL") { |
23 | 0 | excludeFromAll = true; |
24 | 0 | continue; |
25 | 0 | } |
26 | 0 | if (i == "PREORDER") { |
27 | | // Ignored |
28 | 0 | continue; |
29 | 0 | } |
30 | | |
31 | | // if they specified a relative path then compute the full |
32 | 0 | std::string srcPath = mf.GetCurrentSourceDirectory() + "/" + i; |
33 | 0 | if (cmSystemTools::FileIsDirectory(srcPath)) { |
34 | 0 | std::string binPath = mf.GetCurrentBinaryDirectory() + "/" + i; |
35 | 0 | mf.AddSubDirectory(srcPath, binPath, excludeFromAll, false, false); |
36 | 0 | } |
37 | | // otherwise it is a full path |
38 | 0 | else if (cmSystemTools::FileIsDirectory(i)) { |
39 | | // we must compute the binPath from the srcPath, we just take the last |
40 | | // element from the source path and use that |
41 | 0 | std::string binPath = mf.GetCurrentBinaryDirectory() + "/" + |
42 | 0 | cmSystemTools::GetFilenameName(i); |
43 | 0 | mf.AddSubDirectory(i, binPath, excludeFromAll, false, false); |
44 | 0 | } else { |
45 | 0 | status.SetError(cmStrCat("Incorrect SUBDIRS command. Directory: ", i, |
46 | 0 | " does not exist.")); |
47 | 0 | res = false; |
48 | 0 | } |
49 | 0 | } |
50 | 0 | return res; |
51 | 0 | } |