[CMake] Ninja generator does not clean up non-empty directories

Jos van den Oever jos at vandenoever.info
Thu Sep 11 08:42:18 EDT 2014


Hi all,

Ninja does not clean out non-empty directories.

Given this CMakeLists.txt:
======
cmake_minimum_required(VERSION 2.8)

add_custom_command(
  OUTPUT dir
  COMMAND ${CMAKE_COMMAND} -E make_directory dir
  COMMAND ${CMAKE_COMMAND} -E touch dir/file
)

add_custom_target(
  dir-target DEPENDS dir
)
======

the follow commands work fine:

$ cmake -GUnix Makefiles srcdir
...
$ make
Scanning dependencies of target dir-target
[100%] Generating dir
[100%] Built target dir-target
$ make clean
$

But with Ninja, this fails:

$ cmake -GNina srcdir
..
$ ninja
[1/1] Generating dir
$ ninja clean
[1/1] Cleaning all built files...
FAILED: /home/oever/.nix-profile/bin/ninja -t clean
ninja: error: remove(dir): Directory not empty
Cleaning... 0 files.
ninja: build stopped: subcommand failed.

I assume this is a bug. I tried creating a bug db account, but could not get 
past the captcha, so I'm writing here.

Cheers,
Jos


More information about the CMake mailing list