构建 – 如何使用CMake收集源文件?

栏目: C · 发布时间: 7年前

内容简介:http://stackoverflow.com/questions/10914607/how-to-collect-source-files-with-cmake-without-globbing

CMake documentation 明确声明文件(GLOB …)不是

建议收集源文件进行构建,但不会

提到实际推荐的方法.

手动指定每个源文件有一点点手动

对我来说.那么,收集源文件的方法是什么呢?

文件(GLOB …)?

手册确实是推荐的方法.通过建议不要使用GLOB,文档只是针对依赖于文件的构建系统进行警告.例如,您要添加一个测试可执行文件,因此您可以创建mytest.cpp.哎呀.现在你的图书馆编译了. AUX_SOURCE_DIRECTORY的文档(与源文件的globbing类似的目的)给出以下警告:

It is tempting to use this command to avoid writing the list of source  files for a library or executable target. While this seems to work,  there is no way for CMake to generate a build system that knows when a  new source file has been added. Normally the generated build system  knows when it needs to rerun CMake because the CMakeLists.txt file is  modified to add a new source. When the source is just added to the  directory without modifying this file, one would have to manually  rerun CMake to generate a build system incorporating the new file.

如果您确定要使用目录的所有内容,并且不打算添加新的目录,那么一定要使用GLOB.

此外,不要忘记手动列出文件不必涉及所有文件名的打字.你可以做,例如,ls * .cpp>> CMakeLists.txt,然后使用您的编辑器将文件列表移动到文件中正确的位置.

http://stackoverflow.com/questions/10914607/how-to-collect-source-files-with-cmake-without-globbing


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Ajax for Web Application Developers

Ajax for Web Application Developers

Kris Hadlock / Sams / 2006-10-30 / GBP 32.99

Book Description Reusable components and patterns for Ajax-driven applications Ajax is one of the latest and greatest ways to improve users’ online experience and create new and innovative web f......一起来看看 《Ajax for Web Application Developers》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试