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