summaryrefslogtreecommitdiffstats
path: root/Source/cmFileCommand.cxx
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2008-09-11 18:34:04 (GMT)
committerDavid Cole <david.cole@kitware.com>2008-09-11 18:34:04 (GMT)
commitbd1935dcd12d23a23878dc727545743fb078c7cb (patch)
treef25e552c73dc9ea3c31ff186829f5bdd905c1324 /Source/cmFileCommand.cxx
parent0e5319f21dc6a6079a8af82e40ca3e9da563b6de (diff)
downloadCMake-bd1935dcd12d23a23878dc727545743fb078c7cb.zip
CMake-bd1935dcd12d23a23878dc727545743fb078c7cb.tar.gz
CMake-bd1935dcd12d23a23878dc727545743fb078c7cb.tar.bz2
ENH: Improve FILE GLOB_RECURSE handling of symlinks with a new CMake policy. CMP0009 establishes NEW default behavior of not recursing through symlinks. OLD default behavior or explicit FOLLOW_SYMLINKS argument to FILE GLOB_RECURSE will still recurse through symlinks.
Diffstat (limited to 'Source/cmFileCommand.cxx')
-rw-r--r--Source/cmFileCommand.cxx58
1 files changed, 55 insertions, 3 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index bbd8396..032d603 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -668,18 +668,39 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
i++;
cmsys::Glob g;
g.SetRecurse(recurse);
+
+ bool explicitFollowSymlinks = false;
+ cmPolicies::PolicyStatus status =
+ this->Makefile->GetPolicyStatus(cmPolicies::CMP0009);
+ if(recurse)
+ {
+ switch(status)
+ {
+ case cmPolicies::NEW:
+ g.RecurseThroughSymlinksOff();
+ break;
+ case cmPolicies::OLD:
+ case cmPolicies::WARN:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ g.RecurseThroughSymlinksOn();
+ break;
+ }
+ }
+
std::string output = "";
bool first = true;
for ( ; i != args.end(); ++i )
{
- if ( *i == "RECURSE_SYMLINKS_OFF" )
+ if ( recurse && (*i == "FOLLOW_SYMLINKS") )
{
- g.RecurseThroughSymlinksOff();
+ explicitFollowSymlinks = true;
+ g.RecurseThroughSymlinksOn();
++i;
if ( i == args.end() )
{
this->SetError(
- "GLOB requires a glob expression after RECURSE_SYMLINKS_OFF");
+ "GLOB_RECURSE requires a glob expression after FOLLOW_SYMLINKS");
return false;
}
}
@@ -732,6 +753,37 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
first = false;
}
}
+
+ if(recurse && !explicitFollowSymlinks)
+ {
+ switch (status)
+ {
+ case cmPolicies::NEW:
+ // Correct behavior, yay!
+ break;
+ case cmPolicies::OLD:
+ // Probably not really the expected behavior, but the author explicitly
+ // asked for the old behavior... no warning.
+ case cmPolicies::WARN:
+ // Possibly unexpected old behavior *and* we actually traversed
+ // symlinks without being explicitly asked to: warn the author.
+ if(g.GetFollowedSymlinkCount() != 0)
+ {
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
+ this->Makefile->GetPolicies()->
+ GetPolicyWarning(cmPolicies::CMP0009));
+ }
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ this->SetError("policy CMP0009 error");
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ this->Makefile->GetPolicies()->
+ GetRequiredPolicyError(cmPolicies::CMP0009));
+ return false;
+ }
+ }
+
this->Makefile->AddDefinition(variable.c_str(), output.c_str());
return true;
}