Removed curl dependency by using cmake internal curl
[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",
19                                ArgumentFlags(PROCESS_BEFORE | PROCESS_SYSTEM));
20 }
21
22 //----------------------------------------------------------------------------
23 void cmTargetIncludeDirectoriesCommand
24 ::HandleImportedTarget(const std::string &tgt)
25 {
26   cmOStringStream e;
27   e << "Cannot specify include directories for imported target \""
28     << tgt << "\".";
29   this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
30 }
31
32 //----------------------------------------------------------------------------
33 void cmTargetIncludeDirectoriesCommand
34 ::HandleMissingTarget(const std::string &name)
35 {
36   cmOStringStream e;
37   e << "Cannot specify include directories for target \"" << name << "\" "
38        "which is not built by this project.";
39   this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
40 }
41
42 //----------------------------------------------------------------------------
43 std::string cmTargetIncludeDirectoriesCommand
44 ::Join(const std::vector<std::string> &content)
45 {
46   std::string dirs;
47   std::string sep;
48   std::string prefix = this->Makefile->GetStartDirectory() + std::string("/");
49   for(std::vector<std::string>::const_iterator it = content.begin();
50     it != content.end(); ++it)
51     {
52     if (cmSystemTools::FileIsFullPath(it->c_str())
53         || cmGeneratorExpression::Find(*it) != std::string::npos)
54       {
55       dirs += sep + *it;
56       }
57     else
58       {
59       dirs += sep + prefix + *it;
60       }
61     sep = ";";
62     }
63   return dirs;
64 }
65
66 //----------------------------------------------------------------------------
67 void cmTargetIncludeDirectoriesCommand
68 ::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
69                       bool prepend, bool system)
70 {
71   cmListFileBacktrace lfbt;
72   this->Makefile->GetBacktrace(lfbt);
73   cmValueWithOrigin entry(this->Join(content), lfbt);
74   tgt->InsertInclude(entry, prepend);
75   if (system)
76     {
77     tgt->AddSystemIncludeDirectories(content);
78     }
79 }
80
81 //----------------------------------------------------------------------------
82 void cmTargetIncludeDirectoriesCommand
83 ::HandleInterfaceContent(cmTarget *tgt,
84                          const std::vector<std::string> &content,
85                          bool prepend, bool system)
86 {
87   cmTargetPropCommandBase::HandleInterfaceContent(tgt, content,
88                                                   prepend, system);
89
90   if (system)
91     {
92     std::string joined;
93     std::string sep;
94     for(std::vector<std::string>::const_iterator it = content.begin();
95       it != content.end(); ++it)
96       {
97       joined += sep;
98       sep = ";";
99       joined += *it;
100       }
101     tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
102                         joined.c_str());
103     }
104 }