In CMake, for some reason, the
test rule only runs the tests, it does not build them. If I want to actually compile the tests first, my options seem to be:
make all && make testall the time (which requires building more targets than necessary, potentially significantly so)
- Create a new target (like
build-tests) and have all the test binaries depend on it (which requires effort since you can’t just hijack
add_testbecause it doesn’t necessary take a target/binary, and the name of that new target isn’t consistent across repos)
Contrast this to, for instance,
bazel test //... which just builds and runs all the tests.
Is there a better way in CMake to facilitate building all the tests?