/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 "cmDiagnostics.h" |
6 | | #include "cmExecutionStatus.h" |
7 | | #include "cmMakefile.h" |
8 | | #include "cmStringAlgorithms.h" |
9 | | #include "cmSystemTools.h" |
10 | | |
11 | | bool cmSubdirCommand(std::vector<std::string> const& args, |
12 | | cmExecutionStatus& status) |
13 | 0 | { |
14 | 0 | cmMakefile& mf = status.GetMakefile(); |
15 | |
|
16 | 0 | mf.IssueDiagnostic(cmDiagnostics::CMD_DEPRECATED, |
17 | 0 | "The 'subdirs' command has been superseded. " |
18 | 0 | "Use the 'add_subdirectory' command instead."); |
19 | |
|
20 | 0 | if (args.empty()) { |
21 | 0 | status.SetError("called with incorrect number of arguments"); |
22 | 0 | return false; |
23 | 0 | } |
24 | 0 | bool res = true; |
25 | 0 | bool excludeFromAll = false; |
26 | |
|
27 | 0 | for (std::string const& i : args) { |
28 | 0 | if (i == "EXCLUDE_FROM_ALL") { |
29 | 0 | excludeFromAll = true; |
30 | 0 | continue; |
31 | 0 | } |
32 | 0 | if (i == "PREORDER") { |
33 | | // Ignored |
34 | 0 | continue; |
35 | 0 | } |
36 | | |
37 | | // if they specified a relative path then compute the full |
38 | 0 | std::string srcPath = mf.GetCurrentSourceDirectory() + "/" + i; |
39 | 0 | if (cmSystemTools::FileIsDirectory(srcPath)) { |
40 | 0 | std::string binPath = mf.GetCurrentBinaryDirectory() + "/" + i; |
41 | 0 | mf.AddSubDirectory(srcPath, binPath, excludeFromAll, false, false); |
42 | 0 | } |
43 | | // otherwise it is a full path |
44 | 0 | else if (cmSystemTools::FileIsDirectory(i)) { |
45 | | // we must compute the binPath from the srcPath, we just take the last |
46 | | // element from the source path and use that |
47 | 0 | std::string binPath = mf.GetCurrentBinaryDirectory() + "/" + |
48 | 0 | cmSystemTools::GetFilenameName(i); |
49 | 0 | mf.AddSubDirectory(i, binPath, excludeFromAll, false, false); |
50 | 0 | } else { |
51 | 0 | status.SetError(cmStrCat("Incorrect SUBDIRS command. Directory: ", i, |
52 | 0 | " does not exist.")); |
53 | 0 | res = false; |
54 | 0 | } |
55 | 0 | } |
56 | 0 | return res; |
57 | 0 | } |