CTest: Specifying build tree on command line
I found that it is possible build faster using cmake when is used Ninja generator. https://kloczek.wordpress.com/2020/09/27/gnu-make-vs-ninja-performance/
So I've decided to reshape my rpm macros to use by default Ninja (by passing -G Ninja
in my %cmake rpm macro parameters) and looks like I've stamped on some cmake/ctest design issue.
I'm usig off source tree cmake build by defult in my %cmake macro by use -B <build_dir>
in that macro, and then after generate all files actiual build is done iusing cmake --build <build_dir> -j<N> --verbose
.
So fa so good ..
Than on testing build rpm package I'm using 'ctest' because cmake does not provide something like cmake --test <build_dir> -j<N> --verbose
. So I've decided to use on testing:
cd <build_dir>
/usr/bin/ctest --output-on-failure --force-new-ctest-process -j<N>
cd -
All because ctest
does not allow specify in params in which directory are results of the build.
Result is that because before ctest execution any test units which are using some files from source tree are failing.
Generally looks like it works somehow when Gni make generator is used because it is possible to use make -C <build_dir>
which is not chengeing current directory.
The same with Ninja does not work becaise in <build_dir>/build.ninja
is:
# Utility command for test
build CMakeFiles/test.util: CUSTOM_COMMAND
COMMAND = cd <absolute_build_dir> && /usr/bin/ctest <ctest_options>
DESC = Running tests...
pool = console
restat = 1
I've been testing above on evolution-data-server. Initially I've been trying to use cmake <build_dir>
and ctest didn't complain that some extra directory parameter have been passed to ctest and whole testing have been failing because there is no generated for ctest configuration file.
[tkloczko@barrel evolution-data-server-3.38.1]$ ctest --force-new-ctest-process
Test project /home/tkloczko/rpmbuild/BUILD/evolution-data-server-3.38.1
No tests were found!!!
Of course it sdoes not work as well:
[tkloczko@barrel evolution-data-server-3.38.1]$ ctest --force-new-ctest-process x86_64-redhat-linux-gnu/
Test project /home/tkloczko/rpmbuild/BUILD/evolution-data-server-3.38.1
No tests were found!!!
So question is: how to marry cmake, ctest, Ninja and off tree build and/or is it bug/missig sometnig in cmake/ctest or I'm trying to bite that wrong way?