未生成 CMake 目标 RUN_TESTS [英] CMake target RUN_TESTS was not generated

查看:25
本文介绍了未生成 CMake 目标 RUN_TESTS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 2015 中未生成 CMake 目标 RUN_TESTS 的原因可能是什么?我不能包含完整的 CMakeLists.txt,因为它很大并且由许多具有自己的 CMakeLists.txt 的子项目组成,但它包含执行的 enable_testing() 命令,添加和构建测试,只是没有预定义的目标.其他预定义目标如:ZERO_CHECK、INSTALL、ALL_BUILD 也在那里.我的 cmake 执行是:

What may be the reason that CMake target RUN_TESTS was not generated in Visual Studio 2015? I can't include the complete CMakeLists.txt as it is huge and consists of many subprojects with own CMakeLists.txt, but it contains enable_testing() command executed, tests are added and built, there is simply no predefined target. Other predefined targets like: ZERO_CHECK, INSTALL, ALL_BUILD are there. My cmake execution is:

cmake -C conaninitialcache.cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Debug <source_path>

会不会是柯南的错?

推荐答案

事实证明,当项目包含子项目时,enable_testing() 必须位于根 CMakeLists.txt 中,而不是在子项目中,因为正如文档所说:

It turns out, that when having a project with subprojects, enable_testing() must be located in the root CMakeLists.txt, not in the subprojects, since as the documentation says:

这个命令应该在源目录根目录下,因为ctest希望在构建目录根目录中找到一个测试文件.

https://cmake.org/cmake/help/latest/command/enable_testing.html

这篇关于未生成 CMake 目标 RUN_TESTS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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