This project was generated by cmake-init.
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
, 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.
The tool is found in the root CMakeLists.txt 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.