CMake如何使用单元测试安装测试文件 [英] CMake how to install test files with unit tests

查看:92
本文介绍了CMake如何使用单元测试安装测试文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CMake来构建我的系统和单元测试。

I am using CMake to build my system and my unit tests.

我也在做一个源码外的构建。

I am also doing an out-of-source build.

我发现ADD_TEST()命令不需要安装测试可执行文件(它将在运行make install时运行。很棒。)

I've found with the ADD_TEST() command, that you don't need to install the test executable (it will just be run when you run make install, which is great).

但是,我的单元测试取决于一些输入文件,这些文件需要复制到构建可执行文件的位置。

However, my unit tests depend on some input files, which need to be copied to where the executable is built.

据我所知,我不能使用INSTALL()将文件复制到那里,因为我没有指定在哪里

As far as I am aware, I can't use INSTALL() to copy the files there, because I haven't specified where there is - it depends on where the build command is called.

是否可以通过某种方式告诉CMake将测试文件复制到生成可执行文件的位置?

Is there some way I can tell CMake to copy my test files to the same location that it builds the executable?

推荐答案

这可能不是最好的解决方案,但目前我正在这样做:

This may not be the best solution, but currently I am doing this:

file(COPY my_directory DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

似乎可以解决问题。

这篇关于CMake如何使用单元测试安装测试文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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