On Tue, Mar 15, 2016 at 10:06:12 -0400, Brad King wrote: > add_custom_command(OUTPUT foo.h ...) > add_library(foo foo.c foo.h) > add_library(bar bar.c) > target_link_libraries(bar foo) > > The order-only dependency of `bar.c.o` on the target `foo` is just > in case `bar.c` needs to include `foo.h`. It is a conservative > approach and does generate many unneeded dependencies in practice.
FWIW, I've looked into the logic which needs to be done here before and as far as I can tell, it is (pseudocode): deps = direct_deps_of(bar) cc_deps = filter(is_custom_command, deps) obj_deps = [] foreach dep in deps r_deps = all_deps_of(dep) r_cc_deps = filter(is_custom_command, r_deps) if r_cc_deps is not subset of cc_deps obj_deps.add(dep) # alternatively, just pass on the # missing custom command dependencies # (optionally with a warning). # objects of bar should depend on the obj_deps targets for any # potential implicit custom command dependencies. > With a bit of analysis the Ninja generator could detect when `foo` > has no custom commands and does not have a target-level dependency > on other targets with custom commands. Then dependencies on `foo` > from compilations in `bar` could be omitted automatically. This algorithm, I believe, can be applied to all generators, not just Ninja. --Ben -- 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-developers