1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmTargetLinkOptionsCommand.h"
5 #include "cmListFileCache.h"
6 #include "cmMakefile.h"
7 #include "cmMessageType.h"
8 #include "cmStringAlgorithms.h"
10 #include "cmTargetPropCommandBase.h"
14 class TargetLinkOptionsImpl : public cmTargetPropCommandBase
17 using cmTargetPropCommandBase::cmTargetPropCommandBase;
20 void HandleMissingTarget(const std::string& name) override
22 this->Makefile->IssueMessage(
23 MessageType::FATAL_ERROR,
24 cmStrCat("Cannot specify link options for target \"", name,
25 "\" which is not built by this project."));
28 bool HandleDirectContent(cmTarget* tgt,
29 const std::vector<std::string>& content,
30 bool prepend, bool /*system*/) override
32 cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
33 tgt->InsertLinkOption(BT<std::string>(this->Join(content), lfbt), prepend);
34 return true; // Successfully handled.
37 std::string Join(const std::vector<std::string>& content) override
39 return cmJoin(content, ";");
45 bool cmTargetLinkOptionsCommand(std::vector<std::string> const& args,
46 cmExecutionStatus& status)
48 return TargetLinkOptionsImpl(status).HandleArguments(
49 args, "LINK_OPTIONS", TargetLinkOptionsImpl::PROCESS_BEFORE);