在我的顶级 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 ×1