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?
I agree with @Ivan Baidakou.
I'm not sure this is much better, but here's a non-portable hack (won't work on Windows by default) to get it done.
Where
${CMAKE_SOURCE_DIR}/relative_paths
can be multiple paths for multiple libraries if you want.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 wantCTest
not to run:Than copy this file to the build directory where tests are executed:
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 settingEVENT__DISABLE_TESTS
toON
.You can either do this in your own CMakeLists.txt before libevent is included:
or when you invoke CMake on the command line: