1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmIncludeDirectoryCommand.cxx,v $
6 Date: $Date: 2008/01/23 15:27:59 $
7 Version: $Revision: 1.27 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmIncludeDirectoryCommand.h"
19 // cmIncludeDirectoryCommand
20 bool cmIncludeDirectoryCommand
21 ::InitialPass(std::vector
<std::string
> const& args
, cmExecutionStatus
&)
28 std::vector
<std::string
>::const_iterator i
= args
.begin();
30 bool before
= this->Makefile
->IsOn("CMAKE_INCLUDE_DIRECTORIES_BEFORE");
38 else if ((*i
) == "AFTER")
44 for(; i
!= args
.end(); ++i
)
53 const char* versionValue
=
54 this->Makefile
->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY");
55 const char* errorMessage
56 = "Empty Include Directory Passed into INCLUDE_DIRECTORIES command.";
57 if(atof(versionValue
) < 2.5)
59 cmSystemTools::Error(errorMessage
);
63 this->SetError(errorMessage
);
68 this->AddDirectory(i
->c_str(),before
,system
);
74 // do a lot of cleanup on the arguments because this is one place where folks
75 // sometimes take the output of a program and pass it directly into this
76 // command not thinking that a single argument could be filled with spaces
77 // and newlines etc liek below:
80 // /boo/hoo /dingle/berry "
82 // ideally that should be three seperate arguments but when sucking the
83 // output from a program and passing it into a command the cleanup doesn't
86 void cmIncludeDirectoryCommand::AddDirectory(const char *i
,
90 // break apart any line feed arguments
92 std::string::size_type pos
= 0;
93 if((pos
= ret
.find('\n', pos
)) != std::string::npos
)
97 this->AddDirectory(ret
.substr(0,pos
).c_str(), before
, system
);
101 this->AddDirectory(ret
.substr(pos
+1,ret
.size()-pos
-1).c_str(),
107 // remove any leading or trailing spaces and \r
109 while(ret
[pos
] == ' ' || ret
[pos
] == '\r')
115 while(ret
.size() && ret
[pos
] == ' ' || ret
[pos
] == '\r')
124 if (!cmSystemTools::IsOff(ret
.c_str()))
126 cmSystemTools::ConvertToUnixSlashes(ret
);
127 if(!cmSystemTools::FileIsFullPath(ret
.c_str()))
129 std::string tmp
= this->Makefile
->GetStartDirectory();
135 this->Makefile
->AddIncludeDirectory(ret
.c_str(), before
);
138 this->Makefile
->AddSystemIncludeDirectory(ret
.c_str());