问题
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