cmTargetLinkLibrariesCommand.cxx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmTargetLinkLibrariesCommand.h"
  14. // cmTargetLinkLibrariesCommand
  15. bool cmTargetLinkLibrariesCommand::InitialPass(std::vector<std::string>
  16. const& args)
  17. {
  18. // must have one argument
  19. if(args.size() < 1)
  20. {
  21. this->SetError("called with incorrect number of arguments");
  22. return false;
  23. }
  24. // but we might not have any libs after variable expansion
  25. if(args.size() < 2)
  26. {
  27. return true;
  28. }
  29. // add libraries, nothe that there is an optional prefix
  30. // of debug and optimized than can be used
  31. std::vector<std::string>::const_iterator i = args.begin();
  32. for(++i; i != args.end(); ++i)
  33. {
  34. if (*i == "debug")
  35. {
  36. ++i;
  37. if(i == args.end())
  38. {
  39. this->SetError("The \"debug\" argument must be followed by a library");
  40. return false;
  41. }
  42. this->Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
  43. cmTarget::DEBUG);
  44. }
  45. else if (*i == "optimized")
  46. {
  47. ++i;
  48. if(i == args.end())
  49. {
  50. this->SetError(
  51. "The \"optimized\" argument must be followed by a library");
  52. return false;
  53. }
  54. this->Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
  55. cmTarget::OPTIMIZED);
  56. }
  57. else
  58. {
  59. this->Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
  60. cmTarget::GENERAL);
  61. }
  62. }
  63. return true;
  64. }