cmAddLibraryCommand.cxx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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& argsIn)
  17. {
  18. if(argsIn.size() < 1 )
  19. {
  20. this->SetError("called with incorrect number of arguments");
  21. return false;
  22. }
  23. std::vector<std::string> args;
  24. cmSystemTools::ExpandListArguments(argsIn, args);
  25. // Library type defaults to value of BUILD_SHARED_LIBS, if it exists,
  26. // otherwise it defaults to static library.
  27. int shared = !cmSystemTools::IsOff(m_Makefile->GetDefinition("BUILD_SHARED_LIBS"));
  28. std::vector<std::string>::const_iterator s = args.begin();
  29. std::string libname = *s;
  30. ++s;
  31. // If the second argument is "SHARED" or "STATIC", then it controls
  32. // the type of library. Otherwise, it is treated as a source or
  33. // source list name.
  34. if(s != args.end())
  35. {
  36. std::string libType = *s;
  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. srclists.push_back(*s);
  57. ++s;
  58. }
  59. m_Makefile->AddLibrary(libname.c_str(), shared, srclists);
  60. return true;
  61. }