I have a c++ project which includes libevent library. Project structure:
.
|_ CMakeLists.txt
|_ Makefile
|_ src
| |_ my_lib.cpp
|_ test
| |_ my_lib_test.cpp
|_ lib
|_ libevent
|_ CMakeLists.txt
|_ ...
When I build and run my tests, libevent tests are also executed. How can I exclude them and run only my own tests?
There is also a more general way to do it. Add a file named CTestCustom.cmake
to your source tree and add a list of tests that you want CTest
not to run:
set(CTEST_CUSTOM_TESTS_IGNORE
test1
....
testN
)
Than copy this file to the build directory where tests are executed:
configure_file(${CMAKE_SOURCE_DIR}/CTestCustom.cmake ${CMAKE_BINARY_DIR})
This will make CTest
ignore the listed tests. See this for more info.
Looking at the available option
s in libevent's CMakeLists.txt file, it appears that you can disable these pretty easily by setting EVENT__DISABLE_TESTS
to ON
.
You can either do this in your own CMakeLists.txt before libevent is included:
set(EVENT__DISABLE_TESTS ON)
...
add_subdirectory(lib/libevent)
or when you invoke CMake on the command line:
cmake . -DEVENT__DISABLE_TESTS=ON
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With