FIX: stupid pb fixed (close to being medieval'ed by The Ken)
[cmake.git] / Source / cmAddLibraryCommand.cxx
blobd7fd9c5129e5c7be9e61ec0f21948b8e48164505
1 /*=========================================================================
3 Program: Insight Segmentation & Registration Toolkit
4 Module: $RCSfile: cmAddLibraryCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2002-05-02 17:17:10 $
7 Version: $Revision: 1.18 $
9 Copyright (c) 2002 Insight Consortium. All rights reserved.
10 See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmAddLibraryCommand.h"
18 #include "cmCacheManager.h"
20 // cmLibraryCommand
21 bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
23 if(argsIn.size() < 1 )
25 this->SetError("called with incorrect number of arguments");
26 return false;
28 std::vector<std::string> args;
29 cmSystemTools::ExpandListArguments(argsIn, args);
30 // Library type defaults to value of BUILD_SHARED_LIBS, if it exists,
31 // otherwise it defaults to static library.
32 int shared = !cmSystemTools::IsOff(m_Makefile->GetDefinition("BUILD_SHARED_LIBS"));
34 std::vector<std::string>::const_iterator s = args.begin();
36 m_LibName = *s;
38 ++s;
40 // If the second argument is "SHARED" or "STATIC", then it controls
41 // the type of library. Otherwise, it is treated as a source or
42 // source list name.
43 if(s != args.end())
45 std::string libType = *s;
46 if(libType == "STATIC")
48 ++s;
49 shared = 0;
51 else if(libType == "SHARED")
53 ++s;
54 shared = 1;
56 else if(libType == "MODULE")
58 ++s;
59 shared = 2;
63 std::vector<std::string> srclists;
64 while (s != args.end())
66 srclists.push_back(*s);
67 ++s;
70 m_Makefile->AddLibrary(m_LibName.c_str(), shared, srclists);
72 return true;