Discussion:
[CMake] Deleting a directory
Yann Renard
2006-08-30 13:53:12 UTC
Permalink
Cheers list,

when using cmake for building my libraries, I add additional commands in
order to copy all the corresponding header tree to a target directory.
On clean stage, I would like to remove this tree so removed the .h files
one by one using ADDITIONAL_MAKE_CLEAN_FILES. This empties the tree but
after that, it would be nice to remove the tree itself. How could I
remove those directories ? cmake -E seems not to be able to remove
directories.

Best regards,
Yann Renard
Brandon J. Van Every
2006-08-30 17:07:41 UTC
Permalink
Post by Yann Renard
Cheers list,
when using cmake for building my libraries, I add additional commands
in order to copy all the corresponding header tree to a target
directory. On clean stage, I would like to remove this tree so removed
the .h files one by one using ADDITIONAL_MAKE_CLEAN_FILES. This
empties the tree but after that, it would be nice to remove the tree
itself. How could I remove those directories ? cmake -E seems not to
be able to remove directories.
FILE(REMOVE_RECURSE [directory]...)
is what you want? Can't remember if I've used it. Also, I note that
the docs list the command, but don't say what it does, although it's
fairly obvious.

I'm going to make a feature request about sorting or indexing the
documentation by topic. There is a bit of a "needle in the haystack"
feel to it now, although fortunately, it's not that big of a haystack.


Cheers,
Brandon Van Every
Brad King
2006-08-30 20:05:12 UTC
Permalink
Post by Brandon J. Van Every
Post by Yann Renard
Cheers list,
when using cmake for building my libraries, I add additional commands
in order to copy all the corresponding header tree to a target
directory. On clean stage, I would like to remove this tree so removed
the .h files one by one using ADDITIONAL_MAKE_CLEAN_FILES. This
empties the tree but after that, it would be nice to remove the tree
itself. How could I remove those directories ? cmake -E seems not to
be able to remove directories.
FILE(REMOVE_RECURSE [directory]...)
is what you want? Can't remember if I've used it. Also, I note that
the docs list the command, but don't say what it does, although it's
fairly obvious.
This will remove a directory but there is no way to get it to run during
a "make clean" right now. The INSTALL(CODE) and INSTALL(SCRIPT)
commands allow code to be inserted for execution during installation but
there is no equivalent for cleaning.

The clean target in the Makefile generators is meant to get the build
rules to run again from scratch, not to make things look nice on disk.
The Visual Studio generators do not even support cleaning directly: the
IDE provides its own clean rules based on the generated project files.
This is why we suggest using out-of-source builds so that the source
tree is never touched and the build tree can just be wiped clean by
removing the directory.

-Brad

Continue reading on narkive:
Loading...