Hi, This is caused by doing an in source build and thereby causing the issue. The custom command is outputting a file called 'foo', which is also the chosen name of a target in the ninja file. All of this results in ninja conflating the two and causing a circular dependency.
Your options are to not to in source builds, or to choose a different name for your custom target. On Thu, May 4, 2017 at 3:55 AM, Ignacio Fernández Galván via CMake < cmake@cmake.org> wrote: > Hello, > > I have a project where circular dependencies are generated when I use the > Ninja generator, but not the default Unix Makefiles. I could create a > minimal test like this: > > $ cat CMakeLists.txt > add_subdirectory (ext ${PROJECT_BINARY_DIR}/ext) > > $ cat ext/CMakeLists.txt > set (OUT ${CMAKE_CURRENT_LIST_DIR}) > > add_custom_command (OUTPUT ${OUT}/foo > COMMAND touch ${OUT}/foo > ) > > add_custom_target (foo ALL > DEPENDS ${OUT}/foo > ) > > add_custom_command (TARGET foo > POST_BUILD > COMMAND cp ${OUT}/foo ${CMAKE_BINARY_DIR}/foo > ) > > $ touch ext/bar > > $ cmake -G Ninja . > [...] > > $ ninja > ninja: warning: multiple rules generate ext/foo. builds involving this > target will not be correct; continuing anyway [-w dupbuild=warn] > ninja: error: dependency cycle: ext/foo -> ext/CMakeFiles/foo.util -> > ext/CMakeFiles/foo -> ext/foo > > I used a freshly compiled CMake 3.8 and the latest binary ninja from > https://github.com/Kitware/ninja/releases. > > Ignacio > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at http://www.kitware.com/opensou > rce/opensource.html > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/cmake >
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake