Hacker News new | ask | show | jobs
by wmu 2306 days ago
Instead of creating C code inside cmake scripts it's better to use command configure_file (https://cmake.org/cmake/help/latest/command/configure_file.h...). The command creates a source file based on a template file.
1 comments

That doesn't run at compile time though.
I'm not sure what you mean here. It should use CMake's usual change-detection/dependency-tracking mechanism. [0]

The generation of the .h file from the .h.in file does happen at compile-time. (Well, at build time, right before the compiler is invoked.)

[0] https://stackoverflow.com/a/24246566/