CMake:管理源文件列表 [英] CMake: Managing a list of source files

查看:265
本文介绍了CMake:管理源文件列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在遇到的问题是,我只是想通过抓取一切,并删除我不需要的几个奇数和结束来管理我的源文件列表。我希望Cmake为此提供了很好的内置工具。

The problem I'm having at the moment is that I simply wish to manage my list of source files by grabbing everything and removing the few odds and ends that I do not need. I was hoping that Cmake provided nice built-in tools for this.

所以我可以从:

file(GLOB A "Application/*.cpp")

我想要创建另一个要删除的文件列表,我想告诉CMake:从列表B中删除列表B中的项目。

I feel like I want to create another list of files to be removed and I want to tell CMake: Remove from list A items that are in list B.

如果这是Python我可能会做类似下面的事情:

If this were Python I might do something like:

C = [f for f in A if f not in B]

我可能已经拧了那个语法,但我想知道是否有内置的支持管理这些文件列表更优雅的方式?

I may have screwed that syntax up but I'm wondering if there is built-in support for managing these lists of files in a more elegant way?

即使我可以做我的Python示例,A是绝对路径列表,因此构建B是笨重的。

Even if I could do something like my Python example, A is list of absolute paths so constructing B is clunky.

为什么绝对路径?

推荐答案

如果你喜欢Python,你可以生成你的包含 execute_process 的源文件列表。还可以使用列表

If you like Python, you can generate your list of source files with execute_process. There is also possiblity to work with lists.

但我建议您硬编码您的源文件列表。
文件命令文档说明:

But I would recommend you to "hardcode" your list of source files. File command documentation states:


我们不建议使用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.

这篇关于CMake:管理源文件列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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