ENH: Add the RECURSE_SYMLINKS_OFF flag to the FILE GLOB_RECURSE command. Exposes the recently added kwsys capability that prevents recursing through symlinks to CMake scripts.

This commit is contained in:
David Cole 2008-08-23 13:33:13 -04:00
parent 2e0dd80957
commit ccf603f0c2
2 changed files with 18 additions and 2 deletions

View File

@ -672,6 +672,18 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
bool first = true; bool first = true;
for ( ; i != args.end(); ++i ) for ( ; i != args.end(); ++i )
{ {
if ( *i == "RECURSE_SYMLINKS_OFF" )
{
g.RecurseThroughSymlinksOff();
++i;
if ( i == args.end() )
{
this->SetError(
"GLOB requires a glob expression after RECURSE_SYMLINKS_OFF");
return false;
}
}
if ( *i == "RELATIVE" ) if ( *i == "RELATIVE" )
{ {
++i; // skip RELATIVE ++i; // skip RELATIVE
@ -688,6 +700,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
return false; return false;
} }
} }
if ( !cmsys::SystemTools::FileIsFullPath(i->c_str()) ) if ( !cmsys::SystemTools::FileIsFullPath(i->c_str()) )
{ {
std::string expr = this->Makefile->GetCurrentDirectory(); std::string expr = this->Makefile->GetCurrentDirectory();
@ -706,6 +719,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
{ {
g.FindFiles(*i); g.FindFiles(*i);
} }
std::vector<std::string>::size_type cc; std::vector<std::string>::size_type cc;
std::vector<std::string>& files = g.GetFiles(); std::vector<std::string>& files = g.GetFiles();
for ( cc = 0; cc < files.size(); cc ++ ) for ( cc = 0; cc < files.size(); cc ++ )

View File

@ -77,7 +77,7 @@ public:
" [NO_HEX_CONVERSION])\n" " [NO_HEX_CONVERSION])\n"
" file(GLOB variable [RELATIVE path] [globbing expressions]...)\n" " file(GLOB variable [RELATIVE path] [globbing expressions]...)\n"
" file(GLOB_RECURSE variable [RELATIVE path] \n" " file(GLOB_RECURSE variable [RELATIVE path] \n"
" [globbing expressions]...)\n" " [RECURSE_SYMLINKS_OFF] [globbing expressions]...)\n"
" file(REMOVE [file1 ...])\n" " file(REMOVE [file1 ...])\n"
" file(REMOVE_RECURSE [file1 ...])\n" " file(REMOVE_RECURSE [file1 ...])\n"
" file(MAKE_DIRECTORY [directory1 directory2 ...])\n" " file(MAKE_DIRECTORY [directory1 directory2 ...])\n"
@ -126,7 +126,9 @@ public:
" f[3-5].txt - match files f3.txt, f4.txt, f5.txt\n" " f[3-5].txt - match files f3.txt, f4.txt, f5.txt\n"
"GLOB_RECURSE will generate similar list as the regular GLOB, except " "GLOB_RECURSE will generate similar list as the regular GLOB, except "
"it will traverse all the subdirectories of the matched directory and " "it will traverse all the subdirectories of the matched directory and "
"match the files.\n" "match the files. Subdirectories that are symlinks are traversed by "
"default to match the behavior or older CMake releases. Use "
"RECURSE_SYMLINKS_OFF to prevent recursion through symlinks.\n"
"Examples of recursive globbing include:\n" "Examples of recursive globbing include:\n"
" /dir/*.py - match all python files in /dir and subdirectories\n" " /dir/*.py - match all python files in /dir and subdirectories\n"
"MAKE_DIRECTORY will create the given directories, also if their parent " "MAKE_DIRECTORY will create the given directories, also if their parent "