Imported Upstream version 2.8.11.2
[platform/upstream/cmake.git] / Source / cmTargetIncludeDirectoriesCommand.cxx
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2013 Stephen Kelly <steveire@gmail.com>
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 "cmTargetIncludeDirectoriesCommand.h"
13
14 //----------------------------------------------------------------------------
15 bool cmTargetIncludeDirectoriesCommand
16 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
17 {
18   return this->HandleArguments(args, "INCLUDE_DIRECTORIES", PROCESS_BEFORE);
19 }
20
21 //----------------------------------------------------------------------------
22 void cmTargetIncludeDirectoriesCommand
23 ::HandleImportedTarget(const std::string &tgt)
24 {
25   cmOStringStream e;
26   e << "Cannot specify include directories for imported target \""
27     << tgt << "\".";
28   this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
29 }
30
31 //----------------------------------------------------------------------------
32 void cmTargetIncludeDirectoriesCommand
33 ::HandleMissingTarget(const std::string &name)
34 {
35   cmOStringStream e;
36   e << "Cannot specify include directories for target \"" << name << "\" "
37        "which is not built by this project.";
38   this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
39 }
40
41 //----------------------------------------------------------------------------
42 std::string cmTargetIncludeDirectoriesCommand
43 ::Join(const std::vector<std::string> &content)
44 {
45   std::string dirs;
46   std::string sep;
47   std::string prefix = this->Makefile->GetStartDirectory() + std::string("/");
48   for(std::vector<std::string>::const_iterator it = content.begin();
49     it != content.end(); ++it)
50     {
51     if (cmSystemTools::FileIsFullPath(it->c_str())
52         || cmGeneratorExpression::Find(*it) != std::string::npos)
53       {
54       dirs += sep + *it;
55       }
56     else
57       {
58       dirs += sep + prefix + *it;
59       }
60     sep = ";";
61     }
62   return dirs;
63 }
64
65 //----------------------------------------------------------------------------
66 void cmTargetIncludeDirectoriesCommand
67 ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
68                       bool prepend)
69 {
70   cmListFileBacktrace lfbt;
71   this->Makefile->GetBacktrace(lfbt);
72   cmValueWithOrigin entry(this->Join(content), lfbt);
73   tgt->InsertInclude(entry, prepend);
74 }