https://github.com/friendlyanon/cmake-init-codegen
Code generation using a program in the source tree
https://github.com/friendlyanon/cmake-init-codegen
Last synced: 6 days ago
JSON representation
Code generation using a program in the source tree
- Host: GitHub
- URL: https://github.com/friendlyanon/cmake-init-codegen
- Owner: friendlyanon
- Created: 2022-01-24T17:17:46.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-24T17:52:03.000Z (almost 4 years ago)
- Last Synced: 2025-03-11T08:12:52.715Z (10 months ago)
- Language: CMake
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# codegen
This project was generated by [cmake-init][1].
It's heavily stripped down to focus on showing how to compile and use a tool
that is checked into the project for code generation.
There is a program in [`tools/parse`](tools/parse), which does some processing
to an input and writes it to an output, both of which are provided from the
command-line.
This time around, there is no superbuild orchestration via CMake and the tool
is simply installed to a prefix, then wired up to the consuming project. For
such a superbuild, see [another example project][2].
The tool is found in the [root CMakeLists.txt](CMakeLists.txt#L16) and then
used in a custom command.
Do note that build systems that CMake uses do not track changes to the
executable(s) used in custom commands and adding a file level dependency will
result in an always stale node, which can result in constant, potentially
expensive regenerations via the tool. If the external tool changes and you wish
to rerun the custom commands that use it, then you must manually clear the
output(s) or add some custom logic around this. The latter is usually not
required, as it is a solution to situations when the tool is in under heavy
development. The lazy approach would be having a dedicated output directory per
tool, which can be easily deleted to trigger commands using a specific tool.
Note that while normally it is pointless to add headers to targets as sources,
when that header is a generated file, it must be added as a source to the
target to establish a dependency, otherwise the header would not be generated.
[1]: https://github.com/friendlyanon/cmake-init
[2]: https://github.com/friendlyanon/cmake-init-gif-engine