I'm porting some obscure library from autotools to cmake.
The library in question compiles custom tool that outputs header into stdout, and this header is used later in the project.
How can I port that to cmake?
I can compile "header generator" using
add_executable(generator generator.c)
But how can I run it and redirect its output to header file using cmake? I'll also need dependency handling of course... (i.e. if generator.c changes, generator must be recompiled and header must be regenerated).
To generate the header file we need to create a custom_command which will run the command to generate the header file, when the file it is based on has changed. The following shows how to use the hypothetical generatewordlistheader command to create wordlist. h everytime wordlist. txt changes.
A CMake Generator is responsible for writing the input files for a native build system. Exactly one of the CMake Generators must be selected for a build tree to determine what native build system is to be used.
Found it: "How can I generate a source file during the build?"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With