cmTargetCompileFeaturesCommand.cxx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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 "cmTargetCompileFeaturesCommand.h"
  11. bool cmTargetCompileFeaturesCommand::InitialPass(
  12. std::vector<std::string> const& args,
  13. cmExecutionStatus &)
  14. {
  15. return this->HandleArguments(args, "COMPILE_FEATURES", NO_FLAGS);
  16. }
  17. void cmTargetCompileFeaturesCommand
  18. ::HandleImportedTarget(const std::string &tgt)
  19. {
  20. cmOStringStream e;
  21. e << "Cannot specify compile features for imported target \""
  22. << tgt << "\".";
  23. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  24. }
  25. void cmTargetCompileFeaturesCommand
  26. ::HandleMissingTarget(const std::string &name)
  27. {
  28. cmOStringStream e;
  29. e << "Cannot specify compile features for target \"" << name << "\" "
  30. "which is not built by this project.";
  31. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  32. }
  33. //----------------------------------------------------------------------------
  34. std::string cmTargetCompileFeaturesCommand
  35. ::Join(const std::vector<std::string> &content)
  36. {
  37. std::string defs;
  38. std::string sep;
  39. for(std::vector<std::string>::const_iterator it = content.begin();
  40. it != content.end(); ++it)
  41. {
  42. defs += sep + *it;
  43. sep = ";";
  44. }
  45. return defs;
  46. }
  47. //----------------------------------------------------------------------------
  48. bool cmTargetCompileFeaturesCommand
  49. ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
  50. bool, bool)
  51. {
  52. for(std::vector<std::string>::const_iterator it = content.begin();
  53. it != content.end(); ++it)
  54. {
  55. std::string error;
  56. if(!this->Makefile->AddRequiredTargetFeature(tgt, *it, &error))
  57. {
  58. this->SetError(error);
  59. return false;
  60. }
  61. }
  62. return true;
  63. }