cmake/Source/cmTargetLinkOptionsCommand.cxx

51 lines
1.5 KiB
C++
Raw Normal View History

2018-10-28 12:09:07 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetLinkOptionsCommand.h"
#include "cmListFileCache.h"
#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"
2018-10-28 12:09:07 +01:00
#include "cmTarget.h"
2020-02-01 23:06:01 +01:00
#include "cmTargetPropCommandBase.h"
2018-10-28 12:09:07 +01:00
2020-02-01 23:06:01 +01:00
namespace {
2018-10-28 12:09:07 +01:00
2020-02-01 23:06:01 +01:00
class TargetLinkOptionsImpl : public cmTargetPropCommandBase
2018-10-28 12:09:07 +01:00
{
2020-02-01 23:06:01 +01:00
public:
using cmTargetPropCommandBase::cmTargetPropCommandBase;
2018-10-28 12:09:07 +01: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 link options for target \"", name,
"\" which is not built by this project."));
}
2018-10-28 12:09:07 +01:00
2020-02-01 23:06:01 +01:00
bool HandleDirectContent(cmTarget* tgt,
const std::vector<std::string>& content,
bool prepend, bool /*system*/) override
{
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
2021-11-20 13:41:27 +01:00
tgt->InsertLinkOption(BT<std::string>(this->Join(content), lfbt), prepend);
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, ";");
}
};
} // namespace
2018-10-28 12:09:07 +01:00
2020-02-01 23:06:01 +01:00
bool cmTargetLinkOptionsCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
2018-10-28 12:09:07 +01:00
{
2020-02-01 23:06:01 +01:00
return TargetLinkOptionsImpl(status).HandleArguments(
args, "LINK_OPTIONS", TargetLinkOptionsImpl::PROCESS_BEFORE);
2018-10-28 12:09:07 +01:00
}