1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmGetDirectoryPropertyCommand.cxx,v $
6 Date: $Date: 2008/01/23 15:27:59 $
7 Version: $Revision: 1.11 $
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 "cmGetDirectoryPropertyCommand.h"
21 // cmGetDirectoryPropertyCommand
22 bool cmGetDirectoryPropertyCommand
23 ::InitialPass(std::vector
<std::string
> const& args
, cmExecutionStatus
&)
27 this->SetError("called with incorrect number of arguments");
31 std::vector
<std::string
>::const_iterator i
= args
.begin();
32 std::string variable
= *i
;
34 std::string output
= "";
36 // get the directory argument if there is one
37 cmMakefile
*dir
= this->Makefile
;
38 if (*i
== "DIRECTORY")
44 ("DIRECTORY argument provided without subsequent arguments");
48 // make sure the start dir is a full path
49 if (!cmSystemTools::FileIsFullPath(sd
.c_str()))
51 sd
= this->Makefile
->GetStartDirectory();
56 // The local generators are associated with collapsed paths.
57 sd
= cmSystemTools::CollapseFullPath(sd
.c_str());
59 // lookup the makefile from the directory name
60 cmLocalGenerator
*lg
=
61 this->Makefile
->GetLocalGenerator()->GetGlobalGenerator()->
62 FindLocalGenerator(sd
.c_str());
66 ("DIRECTORY argument provided but requested directory not found. "
67 "This could be because the directory argument was invalid or, "
68 "it is valid but has not been processed yet.");
71 dir
= lg
->GetMakefile();
75 // OK, now we have the directory to process, we just get the requested
76 // information out of it
78 if ( *i
== "DEFINITION" )
83 this->SetError("A request for a variable definition was made without "
84 "providing the name of the variable to get.");
87 output
= dir
->GetSafeDefinition(i
->c_str());
88 this->Makefile
->AddDefinition(variable
.c_str(), output
.c_str());
92 const char *prop
= dir
->GetProperty(i
->c_str());
95 this->Makefile
->AddDefinition(variable
.c_str(), prop
);
98 this->Makefile
->AddDefinition(variable
.c_str(), "");