我正在尝试对使用 CMake+CTest 的项目进行覆盖率分析。我创建了一个简单的TestingScript.cmake,如下所示:
set(CTEST_SOURCE_DIRECTORY .)
set(CTEST_BINARY_DIRECTORY build_coverage)
ctest_start(TestCoverage)
ctest_coverage(BUILD ${CTEST_BINARY_DIR})
我正在尝试运行它:
doriad@david-desktop:~/build/Examples/Coverage$ ctest -S ~/src/Examples/Coverage/TestingScript.cmake
Cannot locate CTest configuration: in BuildDirectory: /home/doriad/build/Examples/Coverage/build_coverage/CTestConfig.cmake
Cannot locate CTest configuration: in SourceDirectory: /home/doriad/build/Examples/Coverage/CTestConfig.cmake
Cannot find any coverage files. Ignoring Coverage request.
我需要做什么来生成它正在寻找的这个 CTestConfig.cmake 文件?
最佳答案
文件CTestConfig.cmake
通常由CDash生成。登录 CDash 后,选择设置 > 项目 > 其他 > 下载 CTestConfig。该文件保存将结果提交到仪表板服务器的配置。
The default settings of the module are to submit the dashboard to Kitware's Public Dashboard, where you can register your project for free.
In order to submit to some other server,
CTestConfig.cmake
in the top level directory of your source, and set your own dashboard preferences. If you are using a CDash server, you can download a preconfigured file from the respective project page on that server (Settings / Project, tab Miscellaneous).Source: https://gitlab.kitware.com/cmake/community/wikis/doc/ctest/Testing-With-CTest
另一个问题是您没有要提交的覆盖率文件,因为您跳过了测试脚本中的构建和测试步骤。
关于cmake - 无法找到 CTest 配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35143909/