Skip to content

CMake: Use add_custom_command() to ensure noop incremental builds

Currently, the mkdir and validate custom targets rerun every build because no dependency information is attached to them. By using add_custom_command(), we can attach dependency information to avoid rerunning these steps every build. For breeze-validate-svg, as validate_svg.sh doesn't produce any output files of its own, we use a stamp file to create the necessary dependency information so CMake can detect if the validate step has already been run.

For the icon generation steps, we add a CMake version gate so we can use CONFIGURE_DEPENDS to gather all the icon files which saves us from having to list them manually in the CMake files.

Before:

[root@mkosi-6d74994ef13e4f22a0b9e34687571996 breeze-icons]# ninja
[3/5] Generating 24px icons-dark
[4/5] Generating 24px icons
[5/5] Validating SVG
[root@mkosi-6d74994ef13e4f22a0b9e34687571996 breeze-icons]#

After:

[root@mkosi-6d74994ef13e4f22a0b9e34687571996 breeze-icons]# ninja
[0/2] Re-checking globbed directories...
ninja: no work to do.
[root@mkosi-6d74994ef13e4f22a0b9e34687571996 breeze-icons]#

Merge request reports