cmAddLibraryCommand.cxx 1.8 KB

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