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 "cmTargetCompileDefinitionsCommand.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 "cmTarget.h"
|
|
|
|
#include "cmake.h"
|
|
|
|
|
|
|
|
class cmExecutionStatus;
|
2015-08-17 11:37:30 +02:00
|
|
|
|
2016-07-09 11:21:54 +02:00
|
|
|
bool cmTargetCompileDefinitionsCommand::InitialPass(
|
|
|
|
std::vector<std::string> const& args, cmExecutionStatus&)
|
2013-03-16 19:13:01 +02:00
|
|
|
{
|
|
|
|
return this->HandleArguments(args, "COMPILE_DEFINITIONS");
|
|
|
|
}
|
|
|
|
|
2016-07-09 11:21:54 +02:00
|
|
|
void cmTargetCompileDefinitionsCommand::HandleMissingTarget(
|
|
|
|
const std::string& name)
|
2013-03-16 19:13:01 +02:00
|
|
|
{
|
2015-04-27 22:25:09 +02:00
|
|
|
std::ostringstream e;
|
2016-07-09 11:21:54 +02:00
|
|
|
e << "Cannot specify compile definitions for target \"" << name
|
|
|
|
<< "\" "
|
2013-03-16 19:13:01 +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 cmTargetCompileDefinitionsCommand::Join(
|
|
|
|
const std::vector<std::string>& content)
|
2013-03-16 19:13:01 +02:00
|
|
|
{
|
|
|
|
std::string defs;
|
|
|
|
std::string sep;
|
2018-01-26 17:06:56 +01:00
|
|
|
for (std::string const& it : content) {
|
2018-04-23 21:13:27 +02:00
|
|
|
if (cmHasLiteralPrefix(it, "-D")) {
|
2018-01-26 17:06:56 +01:00
|
|
|
defs += sep + it.substr(2);
|
2016-07-09 11:21:54 +02:00
|
|
|
} else {
|
2018-01-26 17:06:56 +01:00
|
|
|
defs += sep + 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 defs;
|
|
|
|
}
|
|
|
|
|
2016-07-09 11:21:54 +02:00
|
|
|
bool cmTargetCompileDefinitionsCommand::HandleDirectContent(
|
|
|
|
cmTarget* tgt, const std::vector<std::string>& content, bool, bool)
|
2013-03-16 19:13:01 +02:00
|
|
|
{
|
|
|
|
tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str());
|
2018-04-23 21:13:27 +02:00
|
|
|
return true; // Successfully handled.
|
2013-03-16 19:13:01 +02:00
|
|
|
}
|