cmAddLibraryCommand.cxx 2.0 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 "cmAddLibraryCommand.h"
  14. #include "cmCacheManager.h"
  15. // cmLibraryCommand
  16. bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args)
  17. {
  18. if(args.size() < 1 )
  19. {
  20. this->SetError("called with incorrect number of arguments");
  21. return false;
  22. }
  23. // Library type defaults to value of BUILD_SHARED_LIBS, if it exists,
  24. // otherwise it defaults to static library.
  25. int shared = !cmSystemTools::IsOff(m_Makefile->GetDefinition("BUILD_SHARED_LIBS"));
  26. std::vector<std::string>::const_iterator s = args.begin();
  27. std::string libname = *s;
  28. m_Makefile->ExpandVariablesInString(libname);
  29. ++s;
  30. // If the second argument is "SHARED" or "STATIC", then it controls
  31. // the type of library. Otherwise, it is treated as a source or
  32. // source list name.
  33. if(s != args.end())
  34. {
  35. std::string libType = *s;
  36. m_Makefile->ExpandVariablesInString(libType);
  37. if(libType == "STATIC")
  38. {
  39. ++s;
  40. shared = 0;
  41. }
  42. else if(libType == "SHARED")
  43. {
  44. ++s;
  45. shared = 1;
  46. }
  47. else if(libType == "MODULE")
  48. {
  49. ++s;
  50. shared = 2;
  51. }
  52. }
  53. std::vector<std::string> srclists;
  54. while (s != args.end())
  55. {
  56. std::string copy = *s;
  57. m_Makefile->ExpandVariablesInString(copy);
  58. srclists.push_back(copy);
  59. ++s;
  60. }
  61. m_Makefile->AddLibrary(libname.c_str(), shared, srclists);
  62. return true;
  63. }