Using external programs with CMake
CMake has pretty broad functionality, so it can cover many tasks when building software. However, there are situations when developers will need to do something that is not covered. Common examples include running special tools that do some pre-or post-processing of files for a target, using source code generators that produce input for the compiler, and compressing and archiving artifacts that are not handled with CPack. The list of such special tasks that must be accomplished during a build step is probably near-endless. CMake supports three ways of executing custom tasks:
- By defining a target that executes a command with
add_custom_target
- By attaching a custom command to an existing target by using
add_custom_command
, or by making a target depend on a file that’s been generated by a custom command - By using the
execute_process
function, which executes a command during the configuration step
Whenever possible, external...