简体   繁体   中英

Why do I not need a call to `add_test` in cmake?

I've seen add_test a few times in cmake and I'm confused because I'm using googletest and I haven't needed a single call to add_test . Could somebody please explain why? Is this handled directly by googletest or is this call just not used when you use googletest ?

The command adds a target (or custom command) to CTest . So whenenver you execute ctest inside the build directory, all added tests get executed. If you don't want to use CTest and simply execute your test binary manually, then there is no need to use add_test .

In larger projects, where tests usually consist of several binaries, it is more convenient to execute all tests using using a single command (especially when your build pipeline is automated).

Since CMake 3.10 there is the gtest_discover_tests() ...

ref: https://cmake.org/cmake/help/latest/module/GoogleTest.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM