如何自动添加头文件到项目中?
我将如何拥有一个 CMake 构建系统,它现在使用 AUX_SOURCE_DIRECTORY,也在同一目录中扫描头文件,最好使用类似的命令?
我还没有在文档中找到一个简单的方法来做到这一点,所以我现在有一个蹩脚的 bash 脚本来后处理我的 (CodeBlocks) 项目文件...
How would I go about having a CMake buildsystem, which scans for source files now using AUX_SOURCE_DIRECTORY, scan for header files too in the same directory, preferably using a similar command?
I didn't find an easy way to do this in the documentation yet, so I now have a crappy bash script to post-process my (CodeBlocks) project file...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 file(GLOB ... ) 命令。 例如:
此命令还可以递归,并列出相对于给定路径的文件。 请参阅 cmake 文档中的 "file" 命令条目 。
You can use the file(GLOB ... ) command. For example:
This command can also recurse, and list your files relative to a given path. See the "file" command entry in the cmake doc.
AUX_SOURCE_DIRECTORY 的文档表明它不打算以这种方式使用,所以我宁愿怀疑您所要求的是否可能。 如果您想要权威答案,可以通过 [email protected](他们实际上很好相处)。
我强烈建议不要使用通配符来指定构建中包含的内容。 构建文件应指定库的确切内容,而不取决于目录中存在的内容。 一开始它可能很麻烦(如果您习惯了通配符,或者 IDE 的工作方式相同),但是当您习惯了它后,您就不想再以任何其他方式使用它了。
The documentation to AUX_SOURCE_DIRECTORY suggests that it was not intended to be used that way, so I'd rather doubt that what you're asking is possible. If you want an authoritative answer, you can reach the CMake developers at [email protected] (they're actually very nice to deal with).
I'd recommend strongly against using wildcards to specify what is included in the build. The build files should specify the exact contents of the libraries, and not depend on what happens to exist in the directory. It may be cumbersome at first (if you're used to wildcards, or IDE's which works the same way), but when you get used to it, you don't want to have it any other way.