summaryrefslogtreecommitdiffstats
path: root/Source/cmIncludeDirectoryCommand.cxx
diff options
context:
space:
mode:
authorRegina Pfeifer <regina@mailbox.org>2019-09-18 15:31:38 (GMT)
committerRegina Pfeifer <regina@mailbox.org>2019-09-21 03:11:44 (GMT)
commitd038beec21fde74977e6ce6604f7fc913066dad6 (patch)
treed5b279f84625e116ac82d730fa1707ec3139672c /Source/cmIncludeDirectoryCommand.cxx
parentfdc3ba45832456fc17cff58850b16a02cee30e7c (diff)
downloadCMake-d038beec21fde74977e6ce6604f7fc913066dad6.zip
CMake-d038beec21fde74977e6ce6604f7fc913066dad6.tar.gz
CMake-d038beec21fde74977e6ce6604f7fc913066dad6.tar.bz2
cmIncludeDirectoryCommand: Port away from cmCommand
Diffstat (limited to 'Source/cmIncludeDirectoryCommand.cxx')
-rw-r--r--Source/cmIncludeDirectoryCommand.cxx44
1 files changed, 22 insertions, 22 deletions
diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx
index a4d0a0d..170aea1 100644
--- a/Source/cmIncludeDirectoryCommand.cxx
+++ b/Source/cmIncludeDirectoryCommand.cxx
@@ -7,24 +7,28 @@
#include <utility>
#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
+static void GetIncludes(cmMakefile& mf, const std::string& arg,
+ std::vector<std::string>& incs);
+static void NormalizeInclude(cmMakefile& mf, std::string& inc);
-// cmIncludeDirectoryCommand
-bool cmIncludeDirectoryCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmIncludeDirectoryCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
return true;
}
+ cmMakefile& mf = status.GetMakefile();
+
auto i = args.begin();
- bool before = this->Makefile->IsOn("CMAKE_INCLUDE_DIRECTORIES_BEFORE");
+ bool before = mf.IsOn("CMAKE_INCLUDE_DIRECTORIES_BEFORE");
bool system = false;
if ((*i) == "BEFORE") {
@@ -45,13 +49,13 @@ bool cmIncludeDirectoryCommand::InitialPass(
continue;
}
if (i->empty()) {
- this->SetError("given empty-string as include directory.");
+ status.SetError("given empty-string as include directory.");
return false;
}
std::vector<std::string> includes;
- this->GetIncludes(*i, includes);
+ GetIncludes(mf, *i, includes);
if (before) {
cmAppend(beforeIncludes, includes);
@@ -64,9 +68,9 @@ bool cmIncludeDirectoryCommand::InitialPass(
}
std::reverse(beforeIncludes.begin(), beforeIncludes.end());
- this->Makefile->AddIncludeDirectories(afterIncludes);
- this->Makefile->AddIncludeDirectories(beforeIncludes, before);
- this->Makefile->AddSystemIncludeDirectories(systemIncludes);
+ mf.AddIncludeDirectories(afterIncludes);
+ mf.AddIncludeDirectories(beforeIncludes, before);
+ mf.AddSystemIncludeDirectories(systemIncludes);
return true;
}
@@ -83,8 +87,8 @@ bool cmIncludeDirectoryCommand::InitialPass(
// output from a program and passing it into a command the cleanup doesn't
// always happen
//
-void cmIncludeDirectoryCommand::GetIncludes(const std::string& arg,
- std::vector<std::string>& incs)
+static void GetIncludes(cmMakefile& mf, const std::string& arg,
+ std::vector<std::string>& incs)
{
// break apart any line feed arguments
std::string::size_type pos = 0;
@@ -92,7 +96,7 @@ void cmIncludeDirectoryCommand::GetIncludes(const std::string& arg,
while ((pos = arg.find('\n', lastPos)) != std::string::npos) {
if (pos) {
std::string inc = arg.substr(lastPos, pos);
- this->NormalizeInclude(inc);
+ NormalizeInclude(mf, inc);
if (!inc.empty()) {
incs.push_back(std::move(inc));
}
@@ -100,13 +104,13 @@ void cmIncludeDirectoryCommand::GetIncludes(const std::string& arg,
lastPos = pos + 1;
}
std::string inc = arg.substr(lastPos);
- this->NormalizeInclude(inc);
+ NormalizeInclude(mf, inc);
if (!inc.empty()) {
incs.push_back(std::move(inc));
}
}
-void cmIncludeDirectoryCommand::NormalizeInclude(std::string& inc)
+static void NormalizeInclude(cmMakefile& mf, std::string& inc)
{
std::string::size_type b = inc.find_first_not_of(" \r");
std::string::size_type e = inc.find_last_not_of(" \r");
@@ -119,13 +123,9 @@ void cmIncludeDirectoryCommand::NormalizeInclude(std::string& inc)
if (!cmIsOff(inc)) {
cmSystemTools::ConvertToUnixSlashes(inc);
-
- if (!cmSystemTools::FileIsFullPath(inc)) {
- if (!cmGeneratorExpression::StartsWithGeneratorExpression(inc)) {
- std::string tmp =
- cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', inc);
- inc = tmp;
- }
+ if (!cmSystemTools::FileIsFullPath(inc) &&
+ !cmGeneratorExpression::StartsWithGeneratorExpression(inc)) {
+ inc = cmStrCat(mf.GetCurrentSourceDirectory(), '/', inc);
}
}
}