cmake_minimum_required(VERSION 3.10) project(art-inkscape LANGUAGES NONE) set(icons example ) set(formats pdf svg png jpg ) foreach(icon ${icons}) foreach(format ${formats}) if(format STREQUAL jpg) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/icons/${icon}.${format} COMMAND magick ${CMAKE_CURRENT_BINARY_DIR}/icons/${icon}.png ${CMAKE_CURRENT_BINARY_DIR}/icons/${icon}.${format} DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/icons/${icon}.png ) else() add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/icons/${icon}.${format} COMMAND SELF_CALL=xxx # https://gitlab.com/inkscape/inkscape/-/issues/4716 inkscape --export-type=${format} --export-filename=${CMAKE_CURRENT_BINARY_DIR}/icons/${icon}.${format} ${CMAKE_CURRENT_SOURCE_DIR}/icons/${icon}.svg DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/icons/${icon}.svg ) endif() add_custom_target( "icon-${icon}-${format}" ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/icons/${icon}.${format} ) endforeach() endforeach()