使用CMake将具有给定扩展名的所有文件复制到输出目录 [英] Copy all files with given extension to output directory using CMake

查看:391
本文介绍了使用CMake将具有给定扩展名的所有文件复制到输出目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到我可以使用以下命令来使用cmake复制目录:

I've seen that I can use this command in order to copy a directory using cmake:

file(COPY "myDir" DESTINATION "myDestination")

(来自这篇文章

我的问题是我不想复制所有 myDir ,而只复制其中的.h文件。我已经尝试过

My problem is that I don't want to copy all of myDir, but only the .h files that are in there. I've tried with

file(COPY "myDir/*.h" DESTINATION "myDestination")

,但出现以下错误:

CMake Error at CMakeLists.txt:23 (file):
  file COPY cannot find
  "/full/path/to/myDIR/*.h".

如何过滤要复制到目标文件夹的文件?

How can I filter the files that I want to copy to a destination folder?

推荐答案

我自己找到了解决方案:

I've found the solution by myself:

file(GLOB MY_PUBLIC_HEADERS
  "myDir/*.h"
)
file(COPY ${MY_PUBLIC_HEADERS} DESTINATION myDestination)

这篇关于使用CMake将具有给定扩展名的所有文件复制到输出目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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