cmTargetCompileOptionsCommand.cxx 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2013 Stephen Kelly <[email protected]>
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmTargetCompileOptionsCommand.h"
  11. bool cmTargetCompileOptionsCommand
  12. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  13. {
  14. return this->HandleArguments(args, "COMPILE_OPTIONS", PROCESS_BEFORE);
  15. }
  16. void cmTargetCompileOptionsCommand
  17. ::HandleImportedTarget(const std::string &tgt)
  18. {
  19. cmOStringStream e;
  20. e << "Cannot specify compile options for imported target \""
  21. << tgt << "\".";
  22. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  23. }
  24. void cmTargetCompileOptionsCommand
  25. ::HandleMissingTarget(const std::string &name)
  26. {
  27. cmOStringStream e;
  28. e << "Cannot specify compile options for target \"" << name << "\" "
  29. "which is not built by this project.";
  30. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  31. }
  32. //----------------------------------------------------------------------------
  33. std::string cmTargetCompileOptionsCommand
  34. ::Join(const std::vector<std::string> &content)
  35. {
  36. std::string defs;
  37. std::string sep;
  38. for(std::vector<std::string>::const_iterator it = content.begin();
  39. it != content.end(); ++it)
  40. {
  41. defs += sep + *it;
  42. sep = ";";
  43. }
  44. return defs;
  45. }
  46. //----------------------------------------------------------------------------
  47. void cmTargetCompileOptionsCommand
  48. ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
  49. bool, bool)
  50. {
  51. cmListFileBacktrace lfbt;
  52. this->Makefile->GetBacktrace(lfbt);
  53. cmValueWithOrigin entry(this->Join(content), lfbt);
  54. tgt->InsertCompileOption(entry);
  55. }