cmTargetLinkLibrariesCommand.cxx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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
  40. ("The \"debug\" argument must be followed by a library");
  41. return false;
  42. }
  43. this->Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
  44. cmTarget::DEBUG);
  45. }
  46. else if (*i == "optimized")
  47. {
  48. ++i;
  49. if(i == args.end())
  50. {
  51. this->SetError(
  52. "The \"optimized\" argument must be followed by a library");
  53. return false;
  54. }
  55. this->Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
  56. cmTarget::OPTIMIZED);
  57. }
  58. else
  59. {
  60. this->Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
  61. cmTarget::GENERAL);
  62. }
  63. }
  64. return true;
  65. }