cmTargetLinkLibrariesCommand.cxx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "cmTargetLinkLibrariesCommand.h"
  14. // cmTargetLinkLibrariesCommand
  15. bool cmTargetLinkLibrariesCommand::InitialPass(std::vector<std::string> const& argsIn)
  16. {
  17. if(argsIn.size() < 2)
  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. std::vector<std::string>::const_iterator i = args.begin();
  27. for(++i; i != args.end(); ++i)
  28. {
  29. if (*i == "debug")
  30. {
  31. ++i;
  32. m_Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
  33. cmTarget::DEBUG);
  34. }
  35. else if (*i == "optimized")
  36. {
  37. ++i;
  38. m_Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
  39. cmTarget::OPTIMIZED);
  40. }
  41. else
  42. {
  43. m_Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
  44. cmTarget::GENERAL);
  45. }
  46. // if this is a library that cmake knows about, and LIBRARY_OUTPUT_PATH
  47. // is not set, then add the link directory
  48. const char* ldir = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
  49. if (cmSystemTools::IsOff(ldir))
  50. {
  51. std::string libPath = *i + "_CMAKE_PATH";
  52. const char* dir = m_Makefile->GetDefinition(libPath.c_str());
  53. if( dir )
  54. {
  55. m_Makefile->AddLinkDirectoryForTarget(args[0].c_str(), dir );
  56. }
  57. }
  58. else
  59. {
  60. m_Makefile->AddLinkDirectoryForTarget(args[0].c_str(), ldir );
  61. }
  62. }
  63. return true;
  64. }