CMake排除子目录中的测试 [英] CMake exclude tests in subdirectories

查看:118
本文介绍了CMake排除子目录中的测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含libevent库的c ++项目。项目结构:

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
    |_ ...

构建并运行测试时,也会执行libevent测试。如何排除它们并只运行自己的测试?

When I build and run my tests, libevent tests are also executed. How can I exclude them and run only my own tests?

推荐答案

查看在libevent的CMakeLists.txt文件中可用的选项 s ,通过将 EVENT__DISABLE_TESTS 设置为 ON ,您似乎很容易禁用这些功能。

Looking at the available options in libevent's CMakeLists.txt file, it appears that you can disable these pretty easily by setting EVENT__DISABLE_TESTS to ON.

您可以在包含libevent之前在自己的CMakeLists.txt中执行此操作:

You can either do this in your own CMakeLists.txt before libevent is included:

set(EVENT__DISABLE_TESTS ON)
...
add_subdirectory(lib/libevent)

在命令行上调用CMake:

or when you invoke CMake on the command line:

cmake . -DEVENT__DISABLE_TESTS=ON

这篇关于CMake排除子目录中的测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆