小编dib*_*dib的帖子

CMake:使用 exclude_from_all 在子目录中启用_testing

在我的顶级 CMakeLists.txt 中,我包含了一些外部库。如果我为我的项目启用测试并且外部库的 CMakeLists 也调用 enable_testing(),这些测试将添加到我自己的项目测试中,然后无法运行,因为没有构建库的测试。

我不希望构建测试,也不希望它们干扰我自己的项目测试。我怎样才能做到这一点?

在我的 CMakeLists.txt 中:

add_subdirectory(some_ext_lib EXCLUDE_FROM_ALL) ' some_ext_libs tests should not be built nor run

enable_testing()
add_subdirectory(my_own_stuff) ' here the tests should be run
[...]
Run Code Online (Sandbox Code Playgroud)

cmake

5
推荐指数
1
解决办法
1790
查看次数

标签 统计

cmake ×1