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. */
|
2013-03-16 19:13:01 +02:00
|
|
|
#include "cmTargetIncludeDirectoriesCommand.h"
|
|
|
|
|
2017-04-14 19:02:05 +02:00
|
|
|
#include <set>
|
|
|
|
|
2014-08-03 19:52:23 +02:00
|
|
|
#include "cmGeneratorExpression.h"
|
2017-04-14 19:02:05 +02:00
|
|
|
#include "cmListFileCache.h"
|
|
|
|
#include "cmMakefile.h"
|
2019-11-11 23:01:05 +01:00
|
|
|
#include "cmMessageType.h"
|
2020-02-01 23:06:01 +01:00
|
|
|
#include "cmStringAlgorithms.h"
|
2017-04-14 19:02:05 +02:00
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmTarget.h"
|
2020-02-01 23:06:01 +01:00
|
|
|
#include "cmTargetPropCommandBase.h"
|
2017-04-14 19:02:05 +02:00
|
|
|
|
2020-02-01 23:06:01 +01:00
|
|
|
namespace {
|
2014-08-03 19:52:23 +02:00
|
|
|
|
2020-02-01 23:06:01 +01:00
|
|
|
class TargetIncludeDirectoriesImpl : public cmTargetPropCommandBase
|
2013-03-16 19:13:01 +02:00
|
|
|
{
|
2020-02-01 23:06:01 +01:00
|
|
|
public:
|
|
|
|
using cmTargetPropCommandBase::cmTargetPropCommandBase;
|
2013-03-16 19:13:01 +02:00
|
|
|
|
2020-02-01 23:06:01 +01:00
|
|
|
private:
|
|
|
|
void HandleMissingTarget(const std::string& name) override
|
|
|
|
{
|
|
|
|
this->Makefile->IssueMessage(
|
|
|
|
MessageType::FATAL_ERROR,
|
|
|
|
cmStrCat("Cannot specify include directories for target \"", name,
|
|
|
|
"\" which is not built by this project."));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool HandleDirectContent(cmTarget* tgt,
|
|
|
|
const std::vector<std::string>& content,
|
|
|
|
bool prepend, bool system) override;
|
|
|
|
|
|
|
|
void HandleInterfaceContent(cmTarget* tgt,
|
|
|
|
const std::vector<std::string>& content,
|
|
|
|
bool prepend, bool system) override;
|
2013-03-16 19:13:01 +02:00
|
|
|
|
2020-02-01 23:06:01 +01:00
|
|
|
std::string Join(const std::vector<std::string>& content) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::string TargetIncludeDirectoriesImpl::Join(
|
2016-07-09 11:21:54 +02:00
|
|
|
const std::vector<std::string>& content)
|
2013-03-16 19:13:01 +02:00
|
|
|
{
|
|
|
|
std::string dirs;
|
|
|
|
std::string sep;
|
2018-10-28 12:09:07 +01:00
|
|
|
std::string prefix = this->Makefile->GetCurrentSourceDirectory() + "/";
|
2018-01-26 17:06:56 +01:00
|
|
|
for (std::string const& it : content) {
|
2018-04-23 21:13:27 +02:00
|
|
|
if (cmSystemTools::FileIsFullPath(it) ||
|
2018-01-26 17:06:56 +01:00
|
|
|
cmGeneratorExpression::Find(it) == 0) {
|
2020-02-01 23:06:01 +01:00
|
|
|
dirs += cmStrCat(sep, it);
|
2016-07-09 11:21:54 +02:00
|
|
|
} else {
|
2020-02-01 23:06:01 +01:00
|
|
|
dirs += cmStrCat(sep, prefix, it);
|
2013-03-16 19:13:01 +02:00
|
|
|
}
|
2016-07-09 11:21:54 +02:00
|
|
|
sep = ";";
|
|
|
|
}
|
2013-03-16 19:13:01 +02:00
|
|
|
return dirs;
|
|
|
|
}
|
|
|
|
|
2020-02-01 23:06:01 +01:00
|
|
|
bool TargetIncludeDirectoriesImpl::HandleDirectContent(
|
2016-07-09 11:21:54 +02:00
|
|
|
cmTarget* tgt, const std::vector<std::string>& content, 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();
|
2021-11-20 13:41:27 +01:00
|
|
|
tgt->InsertInclude(BT<std::string>(this->Join(content), lfbt), prepend);
|
2016-07-09 11:21:54 +02:00
|
|
|
if (system) {
|
2018-10-28 12:09:07 +01:00
|
|
|
std::string prefix = this->Makefile->GetCurrentSourceDirectory() + "/";
|
2015-11-17 17:22:37 +01:00
|
|
|
std::set<std::string> sdirs;
|
2018-01-26 17:06:56 +01:00
|
|
|
for (std::string const& it : content) {
|
2018-04-23 21:13:27 +02:00
|
|
|
if (cmSystemTools::FileIsFullPath(it) ||
|
2018-01-26 17:06:56 +01:00
|
|
|
cmGeneratorExpression::Find(it) == 0) {
|
|
|
|
sdirs.insert(it);
|
2016-07-09 11:21:54 +02:00
|
|
|
} else {
|
2018-01-26 17:06:56 +01:00
|
|
|
sdirs.insert(prefix + it);
|
2015-11-17 17:22:37 +01:00
|
|
|
}
|
2013-11-03 12:27:13 +02:00
|
|
|
}
|
2016-07-09 11:21:54 +02:00
|
|
|
tgt->AddSystemIncludeDirectories(sdirs);
|
|
|
|
}
|
2018-04-23 21:13:27 +02:00
|
|
|
return true; // Successfully handled.
|
2013-11-03 12:27:13 +02:00
|
|
|
}
|
|
|
|
|
2020-02-01 23:06:01 +01:00
|
|
|
void TargetIncludeDirectoriesImpl::HandleInterfaceContent(
|
2016-07-09 11:21:54 +02:00
|
|
|
cmTarget* tgt, const std::vector<std::string>& content, bool prepend,
|
|
|
|
bool system)
|
2013-11-03 12:27:13 +02:00
|
|
|
{
|
2021-09-14 00:13:48 +02:00
|
|
|
this->cmTargetPropCommandBase::HandleInterfaceContent(tgt, content, prepend,
|
|
|
|
system);
|
2016-07-09 11:21:54 +02:00
|
|
|
if (system) {
|
2015-11-17 17:22:37 +01:00
|
|
|
std::string joined = this->Join(content);
|
2022-11-16 20:14:03 +01:00
|
|
|
tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", joined,
|
|
|
|
this->Makefile->GetBacktrace());
|
2016-07-09 11:21:54 +02:00
|
|
|
}
|
2013-03-16 19:13:01 +02:00
|
|
|
}
|
2020-02-01 23:06:01 +01:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
bool cmTargetIncludeDirectoriesCommand(std::vector<std::string> const& args,
|
|
|
|
cmExecutionStatus& status)
|
|
|
|
{
|
|
|
|
return TargetIncludeDirectoriesImpl(status).HandleArguments(
|
|
|
|
args, "INCLUDE_DIRECTORIES",
|
2023-05-23 16:38:00 +02:00
|
|
|
TargetIncludeDirectoriesImpl::PROCESS_BEFORE |
|
2021-09-14 00:13:48 +02:00
|
|
|
TargetIncludeDirectoriesImpl::PROCESS_AFTER |
|
2023-05-23 16:38:00 +02:00
|
|
|
TargetIncludeDirectoriesImpl::PROCESS_SYSTEM);
|
2020-02-01 23:06:01 +01:00
|
|
|
}
|