cmTargetLinkLibrariesCommand.cxx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. // must have one argument
  18. if(argsIn.size() < 1)
  19. {
  20. this->SetError("called with incorrect number of arguments");
  21. return false;
  22. }
  23. // but we might not have any libs after variable expansion
  24. if(argsIn.size() < 2)
  25. {
  26. return true;
  27. }
  28. std::vector<std::string> args;
  29. cmSystemTools::ExpandListArguments(argsIn, args);
  30. // add libraries, nothe that there is an optional prefix
  31. // of debug and optimized than can be used
  32. std::vector<std::string>::const_iterator i = args.begin();
  33. for(++i; i != args.end(); ++i)
  34. {
  35. if (*i == "debug")
  36. {
  37. ++i;
  38. m_Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
  39. cmTarget::DEBUG);
  40. }
  41. else if (*i == "optimized")
  42. {
  43. ++i;
  44. m_Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
  45. cmTarget::OPTIMIZED);
  46. }
  47. else
  48. {
  49. m_Makefile->AddLinkLibraryForTarget(args[0].c_str(),i->c_str(),
  50. cmTarget::GENERAL);
  51. }
  52. // if this is a library that cmake knows about, and LIBRARY_OUTPUT_PATH
  53. // is not set, then add the link directory
  54. const char* ldir = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
  55. if (cmSystemTools::IsOff(ldir))
  56. {
  57. std::string libPath = *i + "_CMAKE_PATH";
  58. const char* dir = m_Makefile->GetDefinition(libPath.c_str());
  59. if( dir )
  60. {
  61. m_Makefile->AddLinkDirectoryForTarget(args[0].c_str(), dir );
  62. }
  63. }
  64. else
  65. {
  66. m_Makefile->AddLinkDirectoryForTarget(args[0].c_str(), ldir );
  67. }
  68. }
  69. return true;
  70. }