Skip to content

Ninja error: multiple rule generate file when using CMAKE_CONFIGURE_DEPENDS

The bug

The bug occurs when using the ninja generator, not with make. If a same file is given as dependency to one or more folders using different paths, the build step fail with the error:

ninja: error: build.ninja:113: multiple rules generate ../toto/tutu [-w dupbuild=err]

(This was a warning on ninja previously and became an error recently).

Minimal step to reproduce

Using a hello world cpp file in test.cpp, and an empty file toto/tutu.
Minimal CMakeLists.txt:

project(Test)

  set_property(
    DIRECTORY
      "${CMAKE_CURRENT_SOURCE_DIR}"
    APPEND PROPERTY
    CMAKE_CONFIGURE_DEPENDS
      toto/tutu
  )

  set_property(
    DIRECTORY
      "${CMAKE_CURRENT_SOURCE_DIR}"
    APPEND PROPERTY
    CMAKE_CONFIGURE_DEPENDS
      toto/../toto/tutu
  )

add_executable(Test test.cpp)

Commands:

cmake . -GNinja    # ok
cmake --build .    # error

Another version

The bug can also be triggered using exactly the same name for the CMAKE_CONFIGURE_DEPENDS from two different scopes. A minimal state is here:dep.tgz

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information