Hello, I would like to be able to use a build.ninja file generated by CMake as a subninja file of a super build.ninja file generated by a custom generator. This way I could include a CMake projects in a bigger one.
Currently, I call ninja recursively to build the CMake sub-project. But this approach goes against ninja philosophy (one file to ease parallel job handling because recursive makefile are considered harmful, etc...) and the maintainers are not willing to accept patches to properly support it [1, 2]. Consider the following build directory layout: top/build.ninja top/sub/build.ninja Where: - top/build.ninja contains, among other things, "subninja sub/build.ninja" and is generated by a custom generator - "top/sub/build.ninja" is generated by CMake. To properly work, build edge outputs in "top/sub/build.ninja" must be relative to the "top/" directory. Currently, it is impossible because to generate the "top/sub/build.ninja" file CMake must be invoked like this: "cd top/sub && cmake -G Ninja <src_dir>". It has no knowledge of the "top/" directory being special and generates all the outputs relative to the "top/sub/" directory instead of the "top/" directory. For example, we should have this kind of generated build statements for an helloworld project: build sub/build.ninja: RERUN_CMAKE .... build sub/clean: CLEAN build hello: C_EXECUTABLE_LINKER__hello sub/CMakeFiles/hello.dir/hello.c.o build sub/all: phony sub/hello default sub/all To enable this type of generation, the "top/" directory must be passed to CMake somehow. An environment variable or a CMake variable called CMAKE_NINJA_TOP_BUILD_DIR would do the trick. Note that such a change requires scoped rules which was introduced by ninja 1.6. [3] I am willing to write the patch if you think there is a chance that it will be accepted. Best regards, [1] https://github.com/ninja-build/ninja/pull/1079 [2] https://github.com/ninja-build/ninja/pull/1078 [3] https://ninja-build.org/manual.html#ref_scope -- Nicolas Desprès
-- 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