cmAddLibraryCommand.cxx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. ++s;
  29. // If the second argument is "SHARED" or "STATIC", then it controls
  30. // the type of library. Otherwise, it is treated as a source or
  31. // source list name.
  32. if(s != args.end())
  33. {
  34. std::string libType = *s;
  35. if(libType == "STATIC")
  36. {
  37. ++s;
  38. shared = 0;
  39. }
  40. else if(libType == "SHARED")
  41. {
  42. ++s;
  43. shared = 1;
  44. }
  45. else if(libType == "MODULE")
  46. {
  47. ++s;
  48. shared = 2;
  49. }
  50. }
  51. std::vector<std::string> srclists;
  52. while (s != args.end())
  53. {
  54. srclists.push_back(*s);
  55. ++s;
  56. }
  57. m_Makefile->AddLibrary(libname.c_str(), shared, srclists);
  58. return true;
  59. }