cmake/Source/cmTargetCompileFeaturesCommand.cxx

56 lines
1.6 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. */
2015-04-27 22:25:09 +02:00
#include "cmTargetCompileFeaturesCommand.h"
2017-04-14 19:02:05 +02:00
#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"
#include "cmTargetPropCommandBase.h"
2017-04-14 19:02:05 +02:00
class cmTarget;
2015-08-17 11:37:30 +02:00
2020-02-01 23:06:01 +01:00
namespace {
2015-04-27 22:25:09 +02:00
2020-02-01 23:06:01 +01:00
class TargetCompileFeaturesImpl : public cmTargetPropCommandBase
2015-04-27 22:25:09 +02:00
{
2020-02-01 23:06:01 +01:00
public:
using cmTargetPropCommandBase::cmTargetPropCommandBase;
2015-04-27 22:25:09 +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 compile features for target \"", name,
"\" which is not built by this project."));
}
2015-04-27 22:25:09 +02:00
2020-02-01 23:06:01 +01:00
bool HandleDirectContent(cmTarget* tgt,
const std::vector<std::string>& content,
bool /*prepend*/, bool /*system*/) override
{
for (std::string const& it : content) {
std::string error;
if (!this->Makefile->AddRequiredTargetFeature(tgt, it, &error)) {
this->SetError(error);
return false; // Not (successfully) handled.
}
2015-04-27 22:25:09 +02:00
}
2020-02-01 23:06:01 +01:00
return true; // Successfully handled.
}
std::string Join(const std::vector<std::string>& content) override
{
return cmJoin(content, ";");
2016-07-09 11:21:54 +02:00
}
2020-02-01 23:06:01 +01:00
};
} // namespace
bool cmTargetCompileFeaturesCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
return TargetCompileFeaturesImpl(status).HandleArguments(args,
"COMPILE_FEATURES");
2015-04-27 22:25:09 +02:00
}