Attempting to integrate two CMake-generated Ninja projects that use CMAKE_NINJA_OUTPUT_PATH_PREFIX
with subninja
directives fails. See the following interaction:
alex@alex-ubuntu:~/Development/subninja-demo$ tree
.
├── A
│ └── CMakeLists.txt
├── B
│ └── CMakeLists.txt
└── build.sh
2 directories, 3 files
alex@alex-ubuntu:~/Development/subninja-demo$ cat A/CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
project(A LANGUAGES NONE)
alex@alex-ubuntu:~/Development/subninja-demo$ cat B/CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
project(B LANGUAGES NONE)
alex@alex-ubuntu:~/Development/subninja-demo$ cat build.sh
#!/bin/bash
cmake -G Ninja -S A -B build/A -DCMAKE_BUILD_TYPE=Release -DCMAKE_NINJA_OUTPUT_PATH_PREFIX=A
cmake -G Ninja -S B -B build/B -DCMAKE_BUILD_TYPE=Release -DCMAKE_NINJA_OUTPUT_PATH_PREFIX=B
cat >build/build.ninja <<HERE
subninja A/build.ninja
subninja B/build.ninja
HERE
(cd build && ninja -v)
$ ./build.sh
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/Development/subninja-demo/build/A
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/Development/subninja-demo/build/B
ninja: error: B/build.ninja:94: multiple rules generate /usr/share/cmake-3.21/Modules/CMakeDetermineSystem.cmake [-w dupbuild=err]
alex@alex-ubuntu:~/Development/subninja-demo$ cmake --version
cmake version 3.21.3
CMake suite maintained and supported by Kitware (kitware.com/cmake).