[CMake] Execute_process with wildcard characters

Bill Hoffman bill.hoffman at kitware.com
Tue Jul 31 12:03:54 EDT 2007


Ajay Divekar wrote:
> I want to execute the following command using EXECUTE_PROCESS.
>
> EXECUTE_PROCESS( COMMAND rm -vf  */*.*~ RESULT_VARIABLE ret_var)
>
> I have some abc.txt~ files.
>
> The result variable shows 0 as its value, signifying that the command has been 
> executed properly. The above mentioned files still exists.
>
> Thanks for your advice in advance.
>   
You should change it to do:
EXECUTE_PROCESS( COMMAND rm -rf  /* RESULT_VARIABLE ret_var)

:-)

Only kidding....

The problem is that you are running rm without a shell.   The shell is 
the one that
expands the */*.~ stuff and passes the expanded list to rm.   So, this 
might work:

EXECUTE_PROCESS( COMMAND sh rm -vf  */*.*~ RESULT_VARIABLE ret_var)

To be more portable, you should look at the FILE command.
Specifically these two options:

 FILE(GLOB_RECURSE variable [RELATIVE path])
 FILE(REMOVE [file1 ...])


-Bill







More information about the CMake mailing list