cmake/Source/cmTargetCompileFeaturesCommand.cxx

57 lines
1.5 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 <sstream>
2015-08-17 11:37:30 +02:00
#include "cmAlgorithms.h"
2017-04-14 19:02:05 +02:00
#include "cmMakefile.h"
#include "cmake.h"
class cmExecutionStatus;
class cmTarget;
2015-08-17 11:37:30 +02:00
2015-04-27 22:25:09 +02:00
bool cmTargetCompileFeaturesCommand::InitialPass(
2016-07-09 11:21:54 +02:00
std::vector<std::string> const& args, cmExecutionStatus&)
2015-04-27 22:25:09 +02:00
{
return this->HandleArguments(args, "COMPILE_FEATURES", NO_FLAGS);
}
2016-07-09 11:21:54 +02:00
void cmTargetCompileFeaturesCommand::HandleImportedTarget(
const std::string& tgt)
2015-04-27 22:25:09 +02:00
{
std::ostringstream e;
2016-07-09 11:21:54 +02:00
e << "Cannot specify compile features for imported target \"" << tgt
<< "\".";
2015-04-27 22:25:09 +02:00
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
}
2016-07-09 11:21:54 +02:00
void cmTargetCompileFeaturesCommand::HandleMissingTarget(
const std::string& name)
2015-04-27 22:25:09 +02:00
{
std::ostringstream e;
2016-07-09 11:21:54 +02:00
e << "Cannot specify compile features for target \"" << name
<< "\" "
2015-04-27 22:25:09 +02:00
"which is not built by this project.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
}
2016-07-09 11:21:54 +02:00
std::string cmTargetCompileFeaturesCommand::Join(
const std::vector<std::string>& content)
2015-04-27 22:25:09 +02:00
{
return cmJoin(content, ";");
}
2016-07-09 11:21:54 +02:00
bool cmTargetCompileFeaturesCommand::HandleDirectContent(
cmTarget* tgt, const std::vector<std::string>& content, bool, bool)
2015-04-27 22:25:09 +02:00
{
2018-01-26 17:06:56 +01:00
for (std::string const& it : content) {
2015-04-27 22:25:09 +02:00
std::string error;
2018-01-26 17:06:56 +01:00
if (!this->Makefile->AddRequiredTargetFeature(tgt, it, &error)) {
2015-04-27 22:25:09 +02:00
this->SetError(error);
return false;
}
2016-07-09 11:21:54 +02:00
}
2015-04-27 22:25:09 +02:00
return true;
}