cmInstallTargetsCommand.cxx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  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 "cmInstallTargetsCommand.h"
  11. // cmExecutableCommand
  12. bool cmInstallTargetsCommand
  13. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  14. {
  15. if(args.size() < 2 )
  16. {
  17. this->SetError("called with incorrect number of arguments");
  18. return false;
  19. }
  20. // Enable the install target.
  21. this->Makefile->GetLocalGenerator()
  22. ->GetGlobalGenerator()->EnableInstallTarget();
  23. cmTargets &tgts = this->Makefile->GetTargets();
  24. std::vector<std::string>::const_iterator s = args.begin();
  25. ++s;
  26. std::string runtime_dir = "/bin";
  27. for (;s != args.end(); ++s)
  28. {
  29. if (*s == "RUNTIME_DIRECTORY")
  30. {
  31. ++s;
  32. if ( s == args.end() )
  33. {
  34. this->SetError("called with RUNTIME_DIRECTORY but no actual "
  35. "directory");
  36. return false;
  37. }
  38. runtime_dir = *s;
  39. }
  40. else if (tgts.find(*s) != tgts.end())
  41. {
  42. tgts[*s].SetInstallPath(args[0].c_str());
  43. tgts[*s].SetRuntimeInstallPath(runtime_dir.c_str());
  44. tgts[*s].SetHaveInstallRule(true);
  45. }
  46. else
  47. {
  48. std::string str = "Cannot find target: \"" + *s + "\" to install.";
  49. this->SetError(str);
  50. return false;
  51. }
  52. }
  53. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  54. ->AddInstallComponent(this->Makefile->GetSafeDefinition(
  55. "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
  56. return true;
  57. }