cmTargetLinkOptionsCommand.cxx 1.5 KB

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