Skip to content
Snippets Groups Projects
Commit f57e4d77 authored by David Cole's avatar David Cole
Browse files

ENH: Improve FILE GLOB_RECURSE handling of symlinks with a new CMake policy....

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.
parent 7b17140d
No related branches found
No related tags found
No related merge requests found
......@@ -67,6 +67,7 @@ Glob::Glob()
this->RecurseThroughSymlinks = true;
// RecurseThroughSymlinks is true by default for backwards compatibility,
// not because it's a good idea...
this->FollowedSymlinkCount = 0;
}
//----------------------------------------------------------------------------
......@@ -266,9 +267,13 @@ void Glob::RecurseDirectory(kwsys_stl::string::size_type start,
}
if ( kwsys::SystemTools::FileIsDirectory(realname.c_str()) )
{
if (!kwsys::SystemTools::FileIsSymlink(realname.c_str()) ||
this->RecurseThroughSymlinks)
bool isSymLink = kwsys::SystemTools::FileIsSymlink(realname.c_str());
if (!isSymLink || this->RecurseThroughSymlinks)
{
if (isSymLink)
{
++this->FollowedSymlinkCount;
}
this->RecurseDirectory(start+1, realname, dir_only);
}
}
......
......@@ -64,6 +64,9 @@ public:
void SetRecurseThroughSymlinks(bool i) { this->RecurseThroughSymlinks = i; }
bool GetRecurseThroughSymlinks() { return this->RecurseThroughSymlinks; }
//! Get the number of symlinks followed through recursion
unsigned int GetFollowedSymlinkCount() { return this->FollowedSymlinkCount; }
//! Set relative to true to only show relative path to files.
void SetRelative(const char* dir);
const char* GetRelative();
......@@ -98,6 +101,7 @@ protected:
bool Recurse;
kwsys_stl::string Relative;
bool RecurseThroughSymlinks;
unsigned int FollowedSymlinkCount;
private:
Glob(const Glob&); // Not implemented.
......
......@@ -4,7 +4,7 @@
SET(KWSYS_DATE_STAMP_YEAR 2008)
# KWSys version date month component. Format is MM.
SET(KWSYS_DATE_STAMP_MONTH 08)
SET(KWSYS_DATE_STAMP_MONTH 09)
# KWSys version date day component. Format is DD.
SET(KWSYS_DATE_STAMP_DAY 20)
SET(KWSYS_DATE_STAMP_DAY 11)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment