cmake:安装程序时运行程序

发布于 2025-02-07 07:10:44 字数 1438 浏览 2 评论 0原文

我需要在执行A时运行sed(或等效)命令

install(FILES t/a/a.h t/b/b.h ... DESTINATION include/t)

,以过滤#include< t/a/a/ah> - > #include< t/ah>

我应该如何在cmakelists.txt中指定相关命令?

我需要的原因是,我有一个外部维护的库,我需要在代码中导入。

该库(实际上是 ccan 如果很重要的话)的结构如下:

ccan
├── block_pool
│   ├── block_pool.c
│   ├── block_pool.h
│   ├── _info
│   ├── LICENSE -> ../../licenses/BSD-MIT
│   └── test
│       └── run.c
├── build_assert
│   ├── build_assert.h
│   ├── _info
│   ├── LICENSE -> ../../licenses/CC0
...
├── check_type
│   ├── check_type.h
...
├── CMakeLists.txt
├── compiler
│   ├── compiler.h
...
├── container_of
...

每个ccan> ccan /xxx/xxx.h可能具有类似的构造:

...
#include <stdbool.h>
#include <assert.h>
#include <ccan/str/str.h>
#include <ccan/container_of/container_of.h>
#include <ccan/check_type/check_type.h>
...

我想将dir树“压缩”到更简单的:

#include <ccan/str.h>
#include <ccan/container_of.h>
#include <ccan/check_type.h>

另外,如果以上太复杂,那么正确的咒语是什么 复制包含目录为IS?我应该添加install(files ...) 每个文件?

I need to run a sed (or equivalent) command while performing a

install(FILES t/a/a.h t/b/b.h ... DESTINATION include/t)

in order to filter #include <t/a/a.h> -> #include <t/a.h>.

How should I specify the relevant command in CMakeLists.txt?

Reason why I need this is I have an externally maintained library I need to import in my code.

This library (actually a piece of ccan, if it matters) is structured like:

ccan
├── block_pool
│   ├── block_pool.c
│   ├── block_pool.h
│   ├── _info
│   ├── LICENSE -> ../../licenses/BSD-MIT
│   └── test
│       └── run.c
├── build_assert
│   ├── build_assert.h
│   ├── _info
│   ├── LICENSE -> ../../licenses/CC0
...
├── check_type
│   ├── check_type.h
...
├── CMakeLists.txt
├── compiler
│   ├── compiler.h
...
├── container_of
...

each ccan/xxx/xxx.h may have constructs like:

...
#include <stdbool.h>
#include <assert.h>
#include <ccan/str/str.h>
#include <ccan/container_of/container_of.h>
#include <ccan/check_type/check_type.h>
...

and I would like to "compress" the dir tree to a simpler:

#include <ccan/str.h>
#include <ccan/container_of.h>
#include <ccan/check_type.h>

Alternatively, if the above is too complex, what is the right spell
to copy the include directory as-is? Should I add an install(FILES...)
for each file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文