cmAddLibraryCommand.cxx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html 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. // cmLibraryCommand
  15. bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
  16. {
  17. if(argsIn.size() < 1 )
  18. {
  19. this->SetError("called with incorrect number of arguments");
  20. return false;
  21. }
  22. std::vector<std::string> args;
  23. cmSystemTools::ExpandListArguments(argsIn, args);
  24. // Library type defaults to value of BUILD_SHARED_LIBS, if it exists,
  25. // otherwise it defaults to static library.
  26. int shared = !cmSystemTools::IsOff(m_Makefile->GetDefinition("BUILD_SHARED_LIBS"));
  27. std::vector<std::string>::const_iterator s = args.begin();
  28. m_LibName = *s;
  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. if(libType == "STATIC")
  37. {
  38. ++s;
  39. shared = 0;
  40. }
  41. else if(libType == "SHARED")
  42. {
  43. ++s;
  44. shared = 1;
  45. }
  46. else if(libType == "MODULE")
  47. {
  48. ++s;
  49. shared = 2;
  50. }
  51. }
  52. std::vector<std::string> srclists;
  53. while (s != args.end())
  54. {
  55. srclists.push_back(*s);
  56. ++s;
  57. }
  58. m_Makefile->AddLibrary(m_LibName.c_str(), shared, srclists);
  59. return true;
  60. }