1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
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 "cmGetDirectoryPropertyCommand.h"
16 // cmGetDirectoryPropertyCommand
17 bool cmGetDirectoryPropertyCommand
18 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
22 this->SetError("called with incorrect number of arguments");
26 std::vector<std::string>::const_iterator i = args.begin();
27 std::string variable = *i;
29 std::string output = "";
31 // get the directory argument if there is one
32 cmMakefile *dir = this->Makefile;
33 if (*i == "DIRECTORY")
39 ("DIRECTORY argument provided without subsequent arguments");
43 // make sure the start dir is a full path
44 if (!cmSystemTools::FileIsFullPath(sd.c_str()))
46 sd = this->Makefile->GetStartDirectory();
51 // The local generators are associated with collapsed paths.
52 sd = cmSystemTools::CollapseFullPath(sd.c_str());
54 // lookup the makefile from the directory name
55 cmLocalGenerator *lg =
56 this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
57 FindLocalGenerator(sd.c_str());
61 ("DIRECTORY argument provided but requested directory not found. "
62 "This could be because the directory argument was invalid or, "
63 "it is valid but has not been processed yet.");
66 dir = lg->GetMakefile();
70 // OK, now we have the directory to process, we just get the requested
71 // information out of it
73 if ( *i == "DEFINITION" )
78 this->SetError("A request for a variable definition was made without "
79 "providing the name of the variable to get.");
82 output = dir->GetSafeDefinition(i->c_str());
83 this->Makefile->AddDefinition(variable.c_str(), output.c_str());
87 const char *prop = dir->GetProperty(i->c_str());
90 this->Makefile->AddDefinition(variable.c_str(), prop);
93 this->Makefile->AddDefinition(variable.c_str(), "");