cmake/Source/cmTargetIncludeDirectoriesCommand.cxx

100 lines
3.4 KiB
C++
Raw Normal View History

2013-03-16 19:13:01 +02:00
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2013 Stephen Kelly <steveire@gmail.com>
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#include "cmTargetIncludeDirectoriesCommand.h"
2014-08-03 19:52:23 +02:00
#include "cmGeneratorExpression.h"
2013-03-16 19:13:01 +02:00
//----------------------------------------------------------------------------
bool cmTargetIncludeDirectoriesCommand
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
{
2013-11-03 12:27:13 +02:00
return this->HandleArguments(args, "INCLUDE_DIRECTORIES",
ArgumentFlags(PROCESS_BEFORE | PROCESS_SYSTEM));
2013-03-16 19:13:01 +02:00
}
//----------------------------------------------------------------------------
void cmTargetIncludeDirectoriesCommand
::HandleImportedTarget(const std::string &tgt)
{
2015-04-27 22:25:09 +02:00
std::ostringstream e;
2013-03-16 19:13:01 +02:00
e << "Cannot specify include directories for imported target \""
<< tgt << "\".";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
}
//----------------------------------------------------------------------------
void cmTargetIncludeDirectoriesCommand
::HandleMissingTarget(const std::string &name)
{
2015-04-27 22:25:09 +02:00
std::ostringstream e;
2013-03-16 19:13:01 +02:00
e << "Cannot specify include directories for target \"" << name << "\" "
"which is not built by this project.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
}
//----------------------------------------------------------------------------
std::string cmTargetIncludeDirectoriesCommand
::Join(const std::vector<std::string> &content)
{
std::string dirs;
std::string sep;
2015-08-17 11:37:30 +02:00
std::string prefix =
this->Makefile->GetCurrentSourceDirectory() + std::string("/");
2013-03-16 19:13:01 +02:00
for(std::vector<std::string>::const_iterator it = content.begin();
it != content.end(); ++it)
{
if (cmSystemTools::FileIsFullPath(it->c_str())
2014-08-03 19:52:23 +02:00
|| cmGeneratorExpression::Find(*it) == 0)
2013-03-16 19:13:01 +02:00
{
dirs += sep + *it;
}
else
{
dirs += sep + prefix + *it;
}
sep = ";";
}
return dirs;
}
//----------------------------------------------------------------------------
2015-04-27 22:25:09 +02:00
bool cmTargetIncludeDirectoriesCommand
2013-03-16 19:13:01 +02:00
::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
2013-11-03 12:27:13 +02:00
bool prepend, bool system)
2013-03-16 19:13:01 +02:00
{
2015-04-27 22:25:09 +02:00
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
2013-03-16 19:13:01 +02:00
cmValueWithOrigin entry(this->Join(content), lfbt);
tgt->InsertInclude(entry, prepend);
2013-11-03 12:27:13 +02:00
if (system)
{
tgt->AddSystemIncludeDirectories(content);
}
2015-04-27 22:25:09 +02:00
return true;
2013-11-03 12:27:13 +02:00
}
//----------------------------------------------------------------------------
void cmTargetIncludeDirectoriesCommand
::HandleInterfaceContent(cmTarget *tgt,
const std::vector<std::string> &content,
bool prepend, bool system)
{
cmTargetPropCommandBase::HandleInterfaceContent(tgt, content,
prepend, system);
if (system)
{
2015-04-27 22:25:09 +02:00
std::string joined = cmJoin(content, ";");
2013-11-03 12:27:13 +02:00
tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
joined.c_str());
}
2013-03-16 19:13:01 +02:00
}