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:
- Do
make all && make test
all 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 hijackadd_test
because 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?