cmFindLibraryCommand.cxx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. #include "cmFindLibraryCommand.h"
  12. // cmFindLibraryCommand
  13. bool cmFindLibraryCommand::Invoke(std::vector<std::string>& args)
  14. {
  15. if(args.size() < 2 )
  16. {
  17. this->SetError("called with incorrect number of arguments");
  18. return false;
  19. }
  20. std::vector<std::string> path;
  21. // add any user specified paths
  22. for (int j = 2; j < args.size(); j++)
  23. {
  24. // expand variables
  25. std::string exp = args[j];
  26. m_Makefile->ExpandVariablesInString(exp);
  27. path.push_back(exp);
  28. }
  29. // add the standard path
  30. cmSystemTools::GetPath(path);
  31. for(int k=0; k < path.size(); k++)
  32. {
  33. std::string tryPath = path[k];
  34. tryPath += "/";
  35. tryPath += args[1];
  36. if(cmSystemTools::FileExists(tryPath.c_str()))
  37. {
  38. m_Makefile->AddDefinition(args[0].c_str(), path[k].c_str());
  39. return true;
  40. }
  41. }
  42. }