cmLinkLibrariesCommand.cxx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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 "cmLinkLibrariesCommand.h"
  14. // cmLinkLibrariesCommand
  15. bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& argsIn)
  16. {
  17. if(argsIn.size() < 1 )
  18. {
  19. this->SetError("called with incorrect number of arguments");
  20. return false;
  21. }
  22. std::vector<std::string> args;
  23. cmSystemTools::ExpandListArguments(argsIn, args);
  24. // add libraries, nothe that there is an optional prefix
  25. // of debug and optimized than can be used
  26. for(std::vector<std::string>::const_iterator i = args.begin();
  27. i != args.end(); ++i)
  28. {
  29. if (*i == "debug")
  30. {
  31. ++i;
  32. m_Makefile->AddLinkLibrary(i->c_str(),
  33. cmTarget::DEBUG);
  34. }
  35. else if (*i == "optimized")
  36. {
  37. ++i;
  38. m_Makefile->AddLinkLibrary(i->c_str(),
  39. cmTarget::OPTIMIZED);
  40. }
  41. else
  42. {
  43. m_Makefile->AddLinkLibrary(i->c_str());
  44. }
  45. const char* ldir = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
  46. if (cmSystemTools::IsOff(ldir))
  47. {
  48. std::string libPath = *i + "_CMAKE_PATH";
  49. const char* dir = m_Makefile->GetDefinition(libPath.c_str());
  50. if( dir )
  51. {
  52. m_Makefile->AddLinkDirectory( dir );
  53. }
  54. }
  55. else
  56. {
  57. m_Makefile->AddLinkDirectory( ldir );
  58. }
  59. }
  60. return true;
  61. }