Generated Dependency Files in CMake

廉价感情. 提交于 2021-02-07 09:44:54

问题


We have some source processing tools that generate things like raw assembly files from multiple 'snippets'.

When using these tools from make we can ensure up-to-date builds by having the source processing tools emit 'dependency files', just like gcc would with its -MD flag.

For example, let's say I have a assembly template file Frob.asmtmpl, and a templating engine called asm_templater that acts like a beefed up C pre-processor.

We run asm_templater -d Frob.asmtmpl which produces Frob.s and Frob.d. The latter is a makefile dependency snippet like the following:

Frob.s: Frob.asmtmpl ThingIncludedByFrob.asmincl OtherThingIncluded.asmincl

In a makefile based build system, we would include(Frob.d) if it existed, to tell make what the actual deps of Frob.asmtmpl are.

How do we do something similar for CMake? It seems that the two-pass nature of CMake (Generate then Build), and needing to support multiple generation engines leads to the conclusion that there must be some sort of native CMake way to do it that I haven't figure out yet.

I need to indicate to CMake somehow that there's a dependency between Frob.s. and ThingIncludedByFrob.asmincl, but that's all determined by the contents of Frob.asmtmpl and so need to be extracted by a tool.

来源:https://stackoverflow.com/questions/45169207/generated-dependency-files-in-cmake

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!