cmTargetCompileOptionsCommand.cxx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 "cmTargetCompileOptionsCommand.h"
  4. #include <algorithm>
  5. #include <sstream>
  6. #include "cmAlgorithms.h"
  7. #include "cmListFileCache.h"
  8. #include "cmMakefile.h"
  9. #include "cmTarget.h"
  10. #include "cmake.h"
  11. class cmExecutionStatus;
  12. bool cmTargetCompileOptionsCommand::InitialPass(
  13. std::vector<std::string> const& args, cmExecutionStatus&)
  14. {
  15. return this->HandleArguments(args, "COMPILE_OPTIONS", PROCESS_BEFORE);
  16. }
  17. void cmTargetCompileOptionsCommand::HandleImportedTarget(
  18. const std::string& tgt)
  19. {
  20. std::ostringstream e;
  21. e << "Cannot specify compile options for imported target \"" << tgt << "\".";
  22. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  23. }
  24. void cmTargetCompileOptionsCommand::HandleMissingTarget(
  25. const std::string& name)
  26. {
  27. std::ostringstream e;
  28. e << "Cannot specify compile options for target \"" << name
  29. << "\" "
  30. "which is not built by this project.";
  31. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  32. }
  33. std::string cmTargetCompileOptionsCommand::Join(
  34. const std::vector<std::string>& content)
  35. {
  36. return cmJoin(content, ";");
  37. }
  38. bool cmTargetCompileOptionsCommand::HandleDirectContent(
  39. cmTarget* tgt, const std::vector<std::string>& content, bool, bool)
  40. {
  41. cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
  42. tgt->InsertCompileOption(this->Join(content), lfbt);
  43. return true;
  44. }