1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmSubdirCommand.h"
5 #include "cmExecutionStatus.h"
6 #include "cmMakefile.h"
7 #include "cmStringAlgorithms.h"
8 #include "cmSystemTools.h"
10 bool cmSubdirCommand(std::vector
<std::string
> const& args
,
11 cmExecutionStatus
& status
)
14 status
.SetError("called with incorrect number of arguments");
18 bool excludeFromAll
= false;
19 cmMakefile
& mf
= status
.GetMakefile();
21 for (std::string
const& i
: args
) {
22 if (i
== "EXCLUDE_FROM_ALL") {
23 excludeFromAll
= true;
26 if (i
== "PREORDER") {
31 // if they specified a relative path then compute the full
32 std::string srcPath
= mf
.GetCurrentSourceDirectory() + "/" + i
;
33 if (cmSystemTools::FileIsDirectory(srcPath
)) {
34 std::string binPath
= mf
.GetCurrentBinaryDirectory() + "/" + i
;
35 mf
.AddSubDirectory(srcPath
, binPath
, excludeFromAll
, false, false);
37 // otherwise it is a full path
38 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 std::string binPath
= mf
.GetCurrentBinaryDirectory() + "/" +
42 cmSystemTools::GetFilenameName(i
);
43 mf
.AddSubDirectory(i
, binPath
, excludeFromAll
, false, false);
45 status
.SetError(cmStrCat("Incorrect SUBDIRS command. Directory: ", i
,