cmake/Source/cmSubdirCommand.cxx

57 lines
1.8 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSubdirCommand.h"
2017-04-14 19:02:05 +02:00
#include "cmMakefile.h"
#include "cmSystemTools.h"
class cmExecutionStatus;
// cmSubdirCommand
2016-07-09 11:21:54 +02:00
bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus&)
{
2016-10-30 18:24:19 +01:00
if (args.empty()) {
this->SetError("called with incorrect number of arguments");
return false;
2016-07-09 11:21:54 +02:00
}
bool res = true;
bool excludeFromAll = false;
2016-07-09 11:21:54 +02:00
for (std::vector<std::string>::const_iterator i = args.begin();
i != args.end(); ++i) {
if (*i == "EXCLUDE_FROM_ALL") {
excludeFromAll = true;
continue;
2016-07-09 11:21:54 +02:00
}
if (*i == "PREORDER") {
2015-08-17 11:37:30 +02:00
// Ignored
continue;
2016-07-09 11:21:54 +02:00
}
// if they specified a relative path then compute the full
2013-03-16 19:13:01 +02:00
std::string srcPath =
2017-04-14 19:02:05 +02:00
std::string(this->Makefile->GetCurrentSourceDirectory()) + "/" + *i;
2016-07-09 11:21:54 +02:00
if (cmSystemTools::FileIsDirectory(srcPath)) {
2013-03-16 19:13:01 +02:00
std::string binPath =
2017-04-14 19:02:05 +02:00
std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" + *i;
2016-07-09 11:21:54 +02:00
this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, false);
}
// otherwise it is a full path
2016-07-09 11:21:54 +02:00
else if (cmSystemTools::FileIsDirectory(*i)) {
// we must compute the binPath from the srcPath, we just take the last
// element from the source path and use that
2013-03-16 19:13:01 +02:00
std::string binPath =
2016-07-09 11:21:54 +02:00
std::string(this->Makefile->GetCurrentBinaryDirectory()) + "/" +
cmSystemTools::GetFilenameName(*i);
this->Makefile->AddSubDirectory(*i, binPath, excludeFromAll, false);
} else {
std::string error = "Incorrect SUBDIRS command. Directory: ";
2013-11-03 12:27:13 +02:00
error += *i + " does not exist.";
2015-04-27 22:25:09 +02:00
this->SetError(error);
res = false;
}
2016-07-09 11:21:54 +02:00
}
return res;
}