cmInstallTargetsCommand.cxx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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->GetGlobalGenerator()->EnableInstallTarget();
  22. cmTargets &tgts = this->Makefile->GetTargets();
  23. std::vector<std::string>::const_iterator s = args.begin();
  24. ++s;
  25. std::string runtime_dir = "/bin";
  26. for (;s != args.end(); ++s)
  27. {
  28. if (*s == "RUNTIME_DIRECTORY")
  29. {
  30. ++s;
  31. if ( s == args.end() )
  32. {
  33. this->SetError("called with RUNTIME_DIRECTORY but no actual "
  34. "directory");
  35. return false;
  36. }
  37. runtime_dir = *s;
  38. }
  39. else if (tgts.find(*s) != tgts.end())
  40. {
  41. tgts[*s].SetInstallPath(args[0].c_str());
  42. tgts[*s].SetRuntimeInstallPath(runtime_dir.c_str());
  43. tgts[*s].SetHaveInstallRule(true);
  44. }
  45. else
  46. {
  47. std::string str = "Cannot find target: \"" + *s + "\" to install.";
  48. this->SetError(str);
  49. return false;
  50. }
  51. }
  52. this->Makefile->GetGlobalGenerator()
  53. ->AddInstallComponent(this->Makefile->GetSafeDefinition(
  54. "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
  55. return true;
  56. }