从与cmake使用的构建目录不同的目录运行ctest? [英] Run ctest from different directory than build directory used by cmake?

查看:142
本文介绍了从与cmake使用的构建目录不同的目录运行ctest?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够以类似的方式运行 cmake ,例如

I would like to be able in a similar manner as I can run cmake like

cmake --build <bld_directory>

运行 ctest 之类的

ctest --build< bld_directory>

显然正在运行<从< bld-directory> 中的code> ctest 可以工作,
,但是如果我能告诉 ctest 在哪里查找其配置文件以及测试可执行文件的位置。

Obviously running ctest from the <bld-directory> will work, but it would be nice if I can just tell ctest where to look for its configuration file and where the test executables are located.

从文档中可以看出是不太清楚(或者我可能没有在正确的位置看)是否完全有可能。

From the documentation it is not very clear (or I might not have looked in the right place) if this is possible at all or not.

如果有人能够阐明一些信息,那就太好了这有可能吗?
非常感谢,
Jiri

It would great if somebody could shed some light on if this is possible or not ? Many thanks, Jiri

推荐答案

我找不到通过<$做到这一点的方法c $ c> ctest 选项,但可以使用链接到ctest的规则 make test 来实现。

I couldn't find the way to do it through ctest options, but it is doable using the rule make test which is linked to ctest.

在cmake生成的 Makefile 的构建文件夹中,您可以找到以下规则:

In the Makefile generated by cmake in your build folder you can find the rule:

#Special rule for the target test
test:
    @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running tests..."
    /usr/bin/ctest --force-new-ctest-process $(ARGS)
.PHONY : test

make 通过 -C / path / to / build_directory / 提供所需的选项,并且您可以添加任何 ctest 选项,并带有 ARGS ='此处为您的ctest选项'

make provides the option that you want with -C /path/to/build_directory/, and you can add any ctest options with ARGS='your ctest options here'

例如,从系统中的任何目录中,您都可以编写:

For example, from any directory in your system you can write:

进行测试-C / path / to / build_folder ARGS ='-R SpecificTestIWantToRun- VV'

cmake --build< bld_directory> --target测试-ARGS =< ctest_args>

没有 make ,是在终端中使用括号来创建子外壳。这将在不更改当前外壳程序文件夹的情况下执行命令。

Another approach without make, is to use parenthesis in your terminal to create a subshell. This will execute the command without changing the folder of your current shell.

(cd $build_folder; ctest -V)

这篇关于从与cmake使用的构建目录不同的目录运行ctest?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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