cmInstallTargetsCommand.cxx 1.6 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 "cmInstallTargetsCommand.h"
  4. #include "cmGlobalGenerator.h"
  5. // cmExecutableCommand
  6. bool cmInstallTargetsCommand::InitialPass(std::vector<std::string> const& args,
  7. cmExecutionStatus&)
  8. {
  9. if (args.size() < 2) {
  10. this->SetError("called with incorrect number of arguments");
  11. return false;
  12. }
  13. // Enable the install target.
  14. this->Makefile->GetGlobalGenerator()->EnableInstallTarget();
  15. cmTargets& tgts = this->Makefile->GetTargets();
  16. std::vector<std::string>::const_iterator s = args.begin();
  17. ++s;
  18. std::string runtime_dir = "/bin";
  19. for (; s != args.end(); ++s) {
  20. if (*s == "RUNTIME_DIRECTORY") {
  21. ++s;
  22. if (s == args.end()) {
  23. this->SetError("called with RUNTIME_DIRECTORY but no actual "
  24. "directory");
  25. return false;
  26. }
  27. runtime_dir = *s;
  28. } else {
  29. cmTargets::iterator ti = tgts.find(*s);
  30. if (ti != tgts.end()) {
  31. ti->second.SetInstallPath(args[0].c_str());
  32. ti->second.SetRuntimeInstallPath(runtime_dir.c_str());
  33. ti->second.SetHaveInstallRule(true);
  34. } else {
  35. std::string str = "Cannot find target: \"" + *s + "\" to install.";
  36. this->SetError(str);
  37. return false;
  38. }
  39. }
  40. }
  41. this->Makefile->GetGlobalGenerator()->AddInstallComponent(
  42. this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
  43. return true;
  44. }