为什么是cmake文件GLOB?

编程入门 行业动态 更新时间:2024-10-25 10:25:17
本文介绍了为什么是cmake文件GLOB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

CMake文件说明命令文件GLOB :

The CMake doc says about the command file GLOB:

我们不建议使用GLOB从源代码树中收集源文件列表。如果在添加或删除源时没有CMakeLists.txt文件更改,那么生成的构建系统无法知道何时请求CMake重新生成。

We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate.

但是,为了让构建系统知道源代码已经被添加或删除,说

However, to make the build system know that a source has been added or removed, it's sufficient to say

touch CMakeLists.txt

对不对?

那么编辑 CMakeLists.txt 可以插入或删除源文件名。也不是很难记住。所以我没有看到任何好的理由,建议反对文件GLOB 。

Then that's less effort than editing CMakeLists.txt to insert or delete a source file name. Nor is it more difficult to remember. So I don't see any good reason to advise against file GLOB.

这个参数有什么问题? / p>

What's wrong with this argument?

推荐答案

问题是当你不是一个人在一个项目上工作。

The problem is when you're not alone working on a project.

让我们假设项目有开发人员A和B.

Let's say project has developer A and B.

A添加了一个新的源文件 xc 。他不会更改 CMakeLists.txt ,并在他完成实施 xc 后提交。

A adds a new source file x.c. He doesn't changes CMakeLists.txt and commits after he's finished implementing x.c.

现在B做了 git pull ,因为没有修改 CMakeLists.txt ,CMake不会再次运行,并且B在编译时有链接器错误,因为 xc 尚未添加到其源文件列表。

Now B does a git pull, and since there have been no modifications to the CMakeLists.txt, CMake isn't run again and B have linker errors when compiling, because x.c has not been added to its source files list.

更多推荐

为什么是cmake文件GLOB?

本文发布于:2023-10-07 14:39:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469658.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   为什么是   cmake   GLOB

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!