summaryrefslogtreecommitdiffstats
path: root/Source/cmGetDirectoryPropertyCommand.cxx
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2005-09-13 14:39:42 (GMT)
committerKen Martin <ken.martin@kitware.com>2005-09-13 14:39:42 (GMT)
commit2a45d5cd684c835f6e97c28ef997ef5824f4827d (patch)
tree03d597745a3d1cb9c7b7923ca60c6ae420eee04e /Source/cmGetDirectoryPropertyCommand.cxx
parentc09a1fa7993fae6e2f73be8a82677529c29b8c59 (diff)
downloadCMake-2a45d5cd684c835f6e97c28ef997ef5824f4827d.zip
CMake-2a45d5cd684c835f6e97c28ef997ef5824f4827d.tar.gz
CMake-2a45d5cd684c835f6e97c28ef997ef5824f4827d.tar.bz2
ENH: added DIRECTORY option to GET_DIRECTORY_PROPERTIES
Diffstat (limited to 'Source/cmGetDirectoryPropertyCommand.cxx')
-rw-r--r--Source/cmGetDirectoryPropertyCommand.cxx83
1 files changed, 66 insertions, 17 deletions
diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx
index 06302d8..735a03d 100644
--- a/Source/cmGetDirectoryPropertyCommand.cxx
+++ b/Source/cmGetDirectoryPropertyCommand.cxx
@@ -29,17 +29,55 @@ bool cmGetDirectoryPropertyCommand::InitialPass(
}
std::vector<std::string>::size_type cc;
- std::string variable = args[0];
+ std::vector<std::string>::const_iterator i = args.begin();
+ std::string variable = *i;
+ ++i;
std::string output = "";
+
+ // get the directory argument if there is one
+ cmMakefile *dir = m_Makefile;
+ if (*i == "DIRECTORY")
+ {
+ ++i;
+ if (i == args.end())
+ {
+ this->SetError
+ ("DIRECTORY argument provided without subsequent arguments");
+ return false;
+ }
+ std::string sd = *i;
+ // make sure the start dir is a full path
+ if (!cmSystemTools::FileIsFullPath(sd.c_str()))
+ {
+ sd = m_Makefile->GetStartDirectory();
+ sd += "/";
+ sd += *i;
+ }
+ // lookup the makefile from the directory name
+ cmLocalGenerator *lg =
+ m_Makefile->GetLocalGenerator()->GetGlobalGenerator()->
+ FindLocalGenerator(sd.c_str());
+ if (!lg)
+ {
+ this->SetError
+ ("DIRECTORY argument provided but requested directory not found. This could be because the directory argument was invalid or, it is valid but has not been processed yet.");
+ return false;
+ }
+ dir = lg->GetMakefile();
+ ++i;
+ }
- if ( args[1] == "VARIABLES" || args[1] == "CACHE_VARIABLES" )
+ // OK, now we have the directory to process, we just get the requested
+ // information out of it
+
+ if ( *i == "VARIABLES" || *i == "CACHE_VARIABLES" )
{
int cacheonly = 0;
- if ( args[1] == "CACHE_VARIABLES" )
+ if ( *i == "CACHE_VARIABLES" )
{
cacheonly = 1;
}
- std::vector<std::string> vars = m_Makefile->GetDefinitions(cacheonly);
+ std::vector<std::string> vars = dir->GetDefinitions(cacheonly);
for ( cc = 0; cc < vars.size(); cc ++ )
{
if ( cc > 0 )
@@ -49,21 +87,21 @@ bool cmGetDirectoryPropertyCommand::InitialPass(
output += vars[cc];
}
}
- else if ( args[1] == "MACROS" )
+ else if ( *i == "MACROS" )
{
- m_Makefile->GetListOfMacros(output);
+ dir->GetListOfMacros(output);
}
- else if ( args[1] == "DEFINITIONS" )
+ else if ( *i == "DEFINITIONS" )
{
- output=m_Makefile->GetDefineFlags();
+ output = dir->GetDefineFlags();
}
- else if ( args[1] == "INCLUDE_DIRECTORIES" )
+ else if ( *i == "INCLUDE_DIRECTORIES" )
{
std::vector<std::string>::iterator it;
int first = 1;
cmOStringStream str;
- for ( it = m_Makefile->GetIncludeDirectories().begin();
- it != m_Makefile->GetIncludeDirectories().end();
+ for ( it = dir->GetIncludeDirectories().begin();
+ it != dir->GetIncludeDirectories().end();
++ it )
{
if ( !first )
@@ -75,17 +113,17 @@ bool cmGetDirectoryPropertyCommand::InitialPass(
}
output = str.str();
}
- else if ( args[1] == "INCLUDE_REGULAR_EXPRESSION" )
+ else if ( *i == "INCLUDE_REGULAR_EXPRESSION" )
{
- output = m_Makefile->GetIncludeRegularExpression();
+ output = dir->GetIncludeRegularExpression();
}
- else if ( args[1] == "LINK_DIRECTORIES" )
+ else if ( *i == "LINK_DIRECTORIES" )
{
std::vector<std::string>::iterator it;
int first = 1;
cmOStringStream str;
- for ( it = m_Makefile->GetLinkDirectories().begin();
- it != m_Makefile->GetLinkDirectories().end();
+ for ( it = dir->GetLinkDirectories().begin();
+ it != dir->GetLinkDirectories().end();
++ it )
{
if ( !first )
@@ -97,9 +135,20 @@ bool cmGetDirectoryPropertyCommand::InitialPass(
}
output = str.str();
}
+ else if ( *i == "DEFINITION" )
+ {
+ ++i;
+ if (i == args.end())
+ {
+ this->SetError
+ ("A request for a variable definition was made without providing the name of the variable to get.");
+ return false;
+ }
+ output = dir->GetSafeDefinition(i->c_str());
+ }
else
{
- const char *prop = m_Makefile->GetProperty(args[1].c_str());
+ const char *prop = dir->GetProperty(i->c_str());
if (prop)
{
m_Makefile->AddDefinition(variable.c_str(), prop);