ctest seems to ignore -C for "Ninja Multi-Config" generator
cmake version 3.22.3
Steps to reproduce:
- Configure and generate:
cmake -G"Ninja Multi-Config" -Bbuild -S. --toolchain scripts/toolchain/clang-13-aarch64-linux-gnu.cmake
- Pre-build everything for release:
ninja -f build-Release.ninja
- Run ctest:
ctest -C Release --verbose
I would expect that nothing needs to be built in our project, because the default target built by step 2 above already has built everything. I see that the debug configuration is being built though, instead of using the already existing release build. There is output like the following:
Checking test dependency graph...
Checking test dependency graph end
test 1
Start 1: ctest_kernel_abi_test
1: Test command: /usr/local/bin/cmake "--build" "." "--target" "run_kernel_abi_test"
1: Test timeout computed to be: 600
1: [1/132] Building C object boot/CMakeFiles/boot.dir/Debug/src/driver/serial.c.obj
1: [2/132] Building C object boot/CMakeFiles/boot.dir/Debug/src/gzip.c.obj
1: [3/132] Building C object boot/CMakeFiles/boot.dir/Debug/src/arch/driver/serial/pl011.c.obj
I can observe that ninja -f build-Release.ninja run_kernel_abi_test
(which corresponds to ctest_kernel_abi_test) does not build anything, which is as expected. The files are already built by step 2 above. I assume that what ctest does internally is just to call ninja run_kernel_abi_test
without specifying the -f part for Release. This leads to building and running the debug version of that target.
I would have expected that specifying -C as in ctest -C Release
will cause ctest to call the test targets internally with ninja -f build-Release.ninja
, but it seems this is not the case. Apparently the call made by ctest omits the -f part.
Is this a bug or am I misunderstanding what -C option of ctest is for?
The posted output is specific to our project, sorry for this. I hope it is still possible to understand the core problem.