packaging: Initial packaging
[platform/upstream/cmake.git] / Source / cmLinkDirectoriesCommand.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 "cmLinkDirectoriesCommand.h"
13
14 // cmLinkDirectoriesCommand
15 bool cmLinkDirectoriesCommand
16 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
17 {
18  if(args.size() < 1 )
19     {
20     return true;
21     }
22
23   for(std::vector<std::string>::const_iterator i = args.begin();
24       i != args.end(); ++i)
25     {
26     this->AddLinkDir(*i);
27     }
28   return true;
29 }
30
31 //----------------------------------------------------------------------------
32 void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
33 {
34   std::string unixPath = dir;
35   cmSystemTools::ConvertToUnixSlashes(unixPath);
36   if(!cmSystemTools::FileIsFullPath(unixPath.c_str()))
37     {
38     bool convertToAbsolute = false;
39     cmOStringStream e;
40     e << "This command specifies the relative path\n"
41       << "  " << unixPath << "\n"
42       << "as a link directory.\n";
43     cmPolicies* policies = this->Makefile->GetPolicies();
44     switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0015))
45       {
46       case cmPolicies::WARN:
47         e << policies->GetPolicyWarning(cmPolicies::CMP0015);
48         this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, e.str());
49       case cmPolicies::OLD:
50         // OLD behavior does not convert
51         break;
52       case cmPolicies::REQUIRED_IF_USED:
53       case cmPolicies::REQUIRED_ALWAYS:
54         e << policies->GetRequiredPolicyError(cmPolicies::CMP0015);
55         this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
56       case cmPolicies::NEW:
57         // NEW behavior converts
58         convertToAbsolute = true;
59         break;
60       }
61     if (convertToAbsolute)
62       {
63       std::string tmp = this->Makefile->GetStartDirectory();
64       tmp += "/";
65       tmp += unixPath;
66       unixPath = tmp;
67       }
68     }
69   this->Makefile->AddLinkDirectory(unixPath.c_str());
70 }