Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why Cmake's " file(REMOVE_RECURSE [file1 ...]) "does not remove file having *.xxx.yy extension file?

Tags:

cmake

I want to remove all the files from my binary directory which has ".asm.js" extension below is my source code

file (REMOVE
    ${CMAKE_BINARY_DIR}/dist/*.asm.js
    )

Unfortunately, It's not able to delete the file which has .asm.js extension. is there anyone who can help me with this Thanks in advance

like image 353
Praveer Kumar Avatar asked Sep 16 '25 02:09

Praveer Kumar


2 Answers

As CMake docs says :

Remove the given files. The REMOVE_RECURSE mode will remove the given files and directories, also non-empty directories. No error is emitted if a given file does not exist.

So you need to do a list of files to send it to file(REMOVE)

To do it you can use :

file(GLOB MY_FILES ${CMAKE_BINARY_DIR}/dist/*.asm.js)

Or if you want to match them in subdirectories :

file(GLOB_RECURSE MY_FILES ${CMAKE_BINARY_DIR}/dist/*.asm.js)

Then you can use your command :

file (REMOVE ${MY_FILES} )

like image 180
Aurélien Foucault Avatar answered Sep 19 '25 14:09

Aurélien Foucault


if you want to delete all the "asm.js" type of files in the subdirectory as well then you can use the below command

file(GLOB_RECURSE MY_FILES  ${CMAKE_BINARY_DIR}/dist/**/*.asm.js)
like image 31
Praveer Kumar Avatar answered Sep 19 '25 15:09

Praveer Kumar