cmTargetLinkOptionsCommand.cxx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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"
  4. #include "cmList.h"
  5. #include "cmListFileCache.h"
  6. #include "cmMakefile.h"
  7. #include "cmMessageType.h"
  8. #include "cmStringAlgorithms.h"
  9. #include "cmTarget.h"
  10. #include "cmTargetPropCommandBase.h"
  11. namespace {
  12. class TargetLinkOptionsImpl : public cmTargetPropCommandBase
  13. {
  14. public:
  15. using cmTargetPropCommandBase::cmTargetPropCommandBase;
  16. private:
  17. void HandleMissingTarget(const std::string& name) override
  18. {
  19. this->Makefile->IssueMessage(
  20. MessageType::FATAL_ERROR,
  21. cmStrCat("Cannot specify link options for target \"", name,
  22. "\" which is not built by this project."));
  23. }
  24. bool HandleDirectContent(cmTarget* tgt,
  25. const std::vector<std::string>& content,
  26. bool prepend, bool /*system*/) override
  27. {
  28. cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
  29. tgt->InsertLinkOption(BT<std::string>(this->Join(content), lfbt), prepend);
  30. return true; // Successfully handled.
  31. }
  32. std::string Join(const std::vector<std::string>& content) override
  33. {
  34. return cmList::to_string(content);
  35. }
  36. };
  37. } // namespace
  38. bool cmTargetLinkOptionsCommand(std::vector<std::string> const& args,
  39. cmExecutionStatus& status)
  40. {
  41. return TargetLinkOptionsImpl(status).HandleArguments(
  42. args, "LINK_OPTIONS", TargetLinkOptionsImpl::PROCESS_BEFORE);
  43. }