cmake:如何制作一个脚本来复制我的程序附带的数据文件
我正在尝试使用 cmake 自动化我的构建过程。 目前只有一个问题:
在cmake的哲学中(如果有的话),最好的地方在哪里 放置数据文件的复制。
我有一个图书馆和一些例子。例子需要数据。
我目前执行以下操作:
我在每个示例的 CMakeLists.txt 中使用自定义命令将所有数据复制到 构建后步骤中的CMAKE_CURRENT_BINARY_DIR
。 我在调试工作流程中使用它,因此尚未执行安装目标。
这工作得很好,但有一定的缺点:
- 每次构建项目时都会发生复制。对于 VS 2005,即使不是新建的,有时也会发生这种情况。由于数据文件夹很大,复制需要时间,而且有点烦人。
- 我确信这是一种非常笨拙的方法。
我想将这些目录复制到可执行路径,因此我不需要提示如何设置调试工作目录
复制这些目录的最佳时间是在 cmake 配置/生成时,至少我是这么认为的。 我应该这样做吗?我该怎么做?
I am trying to automate my build process with cmake.
There is currently only one issue:
Where is, in cmake's philosophy (if there is one), the best place
to put the copying of data files.
I have a library and a few examples. The examples need the data.
I currently do the following:
I use a custom command in each example's CMakeLists.txt to copy all the Data into theCMAKE_CURRENT_BINARY_DIR
in a post-build step.
I use this in my debugging workflow, so no install target is executed yet.
This works quite well, but has certain drawbacks:
- The copying occurs everytime the project is built. With VS 2005 this sometimes occurs even if it is not newly built. Since the data folders are big, the copying takes time, and it gets a bit annoying.
- I am certain that this is a very clumsy way of doing this.
I want to copy those directories to the executable paths, so I don't need hints how to set the debug working directory
The perfect time to copy these directories would be at cmake configuration/generation time, at least I think so.
Should I do this, and how would I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如最近在这个问题中看到的,您可以使用configure_file 将文件复制到构建目录:
这会在构建时执行一次,并且仅在需要时执行。
As recently seen in this question, you can use configure_file to copy files to the build directory:
That does it once at build time and only when needed.