2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2013-01-08 03:34:41 +04:00
|
|
|
#include "cmTargetCompileDefinitionsCommand.h"
|
|
|
|
|
2015-03-08 15:51:20 +03:00
|
|
|
#include "cmAlgorithms.h"
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmTargetCompileDefinitionsCommand::InitialPass(
|
|
|
|
std::vector<std::string> const& args, cmExecutionStatus&)
|
2013-01-08 03:34:41 +04:00
|
|
|
{
|
|
|
|
return this->HandleArguments(args, "COMPILE_DEFINITIONS");
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmTargetCompileDefinitionsCommand::HandleImportedTarget(
|
|
|
|
const std::string& tgt)
|
2013-01-08 03:34:41 +04:00
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Cannot specify compile definitions for imported target \"" << tgt
|
|
|
|
<< "\".";
|
2013-01-08 03:34:41 +04:00
|
|
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmTargetCompileDefinitionsCommand::HandleMissingTarget(
|
|
|
|
const std::string& name)
|
2013-01-08 03:34:41 +04:00
|
|
|
{
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2016-05-16 17:34:04 +03:00
|
|
|
e << "Cannot specify compile definitions for target \"" << name
|
|
|
|
<< "\" "
|
2013-01-08 03:34:41 +04:00
|
|
|
"which is not built by this project.";
|
|
|
|
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmTargetCompileDefinitionsCommand::Join(
|
|
|
|
const std::vector<std::string>& content)
|
2013-01-29 20:23:31 +04:00
|
|
|
{
|
|
|
|
std::string defs;
|
|
|
|
std::string sep;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<std::string>::const_iterator it = content.begin();
|
|
|
|
it != content.end(); ++it) {
|
|
|
|
if (cmHasLiteralPrefix(it->c_str(), "-D")) {
|
2013-01-29 20:23:31 +04:00
|
|
|
defs += sep + it->substr(2);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2013-01-29 20:23:31 +04:00
|
|
|
defs += sep + *it;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
sep = ";";
|
|
|
|
}
|
2013-01-29 20:23:31 +04:00
|
|
|
return defs;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmTargetCompileDefinitionsCommand::HandleDirectContent(
|
|
|
|
cmTarget* tgt, const std::vector<std::string>& content, bool, bool)
|
2013-01-08 03:34:41 +04:00
|
|
|
{
|
2013-01-29 20:23:31 +04:00
|
|
|
tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str());
|
2013-11-09 03:18:35 +04:00
|
|
|
return true;
|
2013-01-08 03:34:41 +04:00
|
|
|
}
|