Imported Upstream version 2.8.12.2
[platform/upstream/cmake.git] / Source / cmLinkLibrariesCommand.cxx
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #include "cmLinkLibrariesCommand.h"
13
14 // cmLinkLibrariesCommand
15 bool cmLinkLibrariesCommand
16 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
17 {
18   if(args.size() < 1 )
19     {
20     return true;
21     }
22   // add libraries, nothe that there is an optional prefix
23   // of debug and optimized than can be used
24   for(std::vector<std::string>::const_iterator i = args.begin();
25       i != args.end(); ++i)
26     {
27     if (*i == "debug")
28       {
29       ++i;
30       if(i == args.end())
31         {
32         this->SetError("The \"debug\" argument must be followed by "
33                        "a library");
34         return false;
35         }
36       this->Makefile->AddLinkLibrary(i->c_str(),
37                                  cmTarget::DEBUG);
38       }
39     else if (*i == "optimized")
40       {
41       ++i;
42       if(i == args.end())
43         {
44         this->SetError("The \"optimized\" argument must be followed by "
45                        "a library");
46         return false;
47         }
48       this->Makefile->AddLinkLibrary(i->c_str(),
49                                  cmTarget::OPTIMIZED);
50       }
51     else
52       {
53       this->Makefile->AddLinkLibrary(i->c_str());
54       }
55     }
56
57   return true;
58 }
59