Imported Upstream version 2.8.9
[platform/upstream/cmake.git] / Source / cmInstallTargetsCommand.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 "cmInstallTargetsCommand.h"
13
14 // cmExecutableCommand
15 bool cmInstallTargetsCommand
16 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
17 {
18   if(args.size() < 2 )
19     {
20     this->SetError("called with incorrect number of arguments");
21     return false;
22     }
23
24   // Enable the install target.
25   this->Makefile->GetLocalGenerator()
26     ->GetGlobalGenerator()->EnableInstallTarget();
27
28   cmTargets &tgts = this->Makefile->GetTargets();
29   std::vector<std::string>::const_iterator s = args.begin();
30   ++s;
31   std::string runtime_dir = "/bin";
32   for (;s != args.end(); ++s)
33     {
34     if (*s == "RUNTIME_DIRECTORY")
35       {
36       ++s;
37       if ( s == args.end() )
38         {
39         this->SetError("called with RUNTIME_DIRECTORY but no actual "
40                        "directory");
41         return false;
42         }
43
44       runtime_dir = *s;
45       }
46     else if (tgts.find(*s) != tgts.end())
47       {
48       tgts[*s].SetInstallPath(args[0].c_str());
49       tgts[*s].SetRuntimeInstallPath(runtime_dir.c_str());
50       tgts[*s].SetHaveInstallRule(true);
51       }
52     else
53       {
54       std::string str = "Cannot find target: \"" + *s + "\" to install.";
55       this->SetError(str.c_str());
56       return false;
57       }
58     }
59
60   this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
61                        ->AddInstallComponent(this->Makefile->GetSafeDefinition(
62                                       "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
63
64   return true;
65 }
66