ENH: Add relative tag and add test for relative tag
This commit is contained in:
parent
9dbf4438dc
commit
d41f97a5e6
|
@ -210,6 +210,17 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
|
|||
bool first = true;
|
||||
for ( ; i != args.end(); ++i )
|
||||
{
|
||||
if ( *i == "RELATIVE" )
|
||||
{
|
||||
++i; // skip RELATIVE
|
||||
if ( i == args.end() )
|
||||
{
|
||||
this->SetError("GLOB requires a directory after the RELATIVE tag");
|
||||
return false;
|
||||
}
|
||||
g.SetRelative(i->c_str());
|
||||
++i;
|
||||
}
|
||||
if ( !cmsys::SystemTools::FileIsFullPath(i->c_str()) )
|
||||
{
|
||||
std::string expr = this->Makefile->GetCurrentDirectory();
|
||||
|
|
|
@ -67,8 +67,8 @@ public:
|
|||
" FILE(WRITE filename \"message to write\"... )\n"
|
||||
" FILE(APPEND filename \"message to write\"... )\n"
|
||||
" FILE(READ filename variable)\n"
|
||||
" FILE(GLOB variable [globbing expressions]...)\n"
|
||||
" FILE(GLOB_RECURSE variable [globbing expressions]...)\n"
|
||||
" FILE(GLOB variable [RELATIVE path] [globbing expressions]...)\n"
|
||||
" FILE(GLOB_RECURSE variable [RELATIVE path] [globbing expressions]...)\n"
|
||||
" FILE(REMOVE [directory]...)\n"
|
||||
" FILE(REMOVE_RECURSE [directory]...)\n"
|
||||
" FILE(MAKE_DIRECTORY [directory]...)\n"
|
||||
|
@ -87,7 +87,9 @@ public:
|
|||
"variable.\n"
|
||||
"GLOB will generate a list of all files that match the globbing "
|
||||
"expressions and store it into the variable. Globbing expressions "
|
||||
"are similar to regular expressions, but much simpler.\n"
|
||||
"are similar to regular expressions, but much simpler. If RELATIVE "
|
||||
"flag is specified for an expression, the results will be returned "
|
||||
"as a relative path to the given path.\n"
|
||||
"Examples of globbing expressions include:\n"
|
||||
" *.cxx - match all files with extension cxx\n"
|
||||
" *.vt? - match all files with extension vta,...,vtz\n"
|
||||
|
|
|
@ -91,9 +91,12 @@ SET(expr "${CMAKE_CURRENT_SOURCE_DIR}/[sS][!a-su-zA-Z0-9][^a-qs-zA-Z0-9]ing?ile*
|
|||
MESSAGE("Glob expression is [${expr}].")
|
||||
FILE(GLOB src_files "${expr}")
|
||||
MESSAGE("Globbed files [${src_files}].")
|
||||
|
||||
ADD_EXECUTABLE(StringFileTest ${src_files})
|
||||
|
||||
SET(expr "${CMAKE_CURRENT_SOURCE_DIR}/../*.cxx")
|
||||
FILE(GLOB_RECURSE rel_src_files RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/.." "${expr}")
|
||||
MESSAGE("Globbed files [${rel_src_files}].")
|
||||
|
||||
# Test FOREACH range
|
||||
MESSAGE("Cheack if FOREACH with RANGE works")
|
||||
MACRO(TEST_RANGE ARGS CHECK)
|
||||
|
|
Loading…
Reference in New Issue