找不到 CTest 配置

Cannot locate CTest configuration

我正在尝试对使用 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 后,select 设置 > 项目 > 杂项 > 下载 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

另一个问题是您没有要提交的覆盖率文件,因为您跳过了测试脚本中的 buildtest 步骤。