cmake/Source/cmSubdirCommand.cxx

55 lines
1.7 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;
2018-01-26 17:06:56 +01:00
for (std::string const& i : args) {
if (i == "EXCLUDE_FROM_ALL") {
excludeFromAll = true;
continue;
2016-07-09 11:21:54 +02:00
}
2018-01-26 17:06:56 +01: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 =
2018-10-28 12:09:07 +01:00
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 =
2018-10-28 12:09:07 +01:00
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
2018-01-26 17:06:56 +01: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
2018-10-28 12:09:07 +01:00
std::string binPath = this->Makefile->GetCurrentBinaryDirectory() + "/" +
2018-01-26 17:06:56 +01:00
cmSystemTools::GetFilenameName(i);
this->Makefile->AddSubDirectory(i, binPath, excludeFromAll, false);
2016-07-09 11:21:54 +02:00
} else {
std::string error = "Incorrect SUBDIRS command. Directory: ";
2018-01-26 17:06:56 +01: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;
}