set(icons example ) set(formats pdf svg ) foreach(icon ${icons}) foreach(format ${formats}) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${icon}.${format} COMMAND SELF_CALL=xxx # https://gitlab.com/inkscape/inkscape/-/issues/4716 inkscape --export-type=${format} --export-filename=${CMAKE_CURRENT_BINARY_DIR}/${icon}.${format} ${CMAKE_CURRENT_SOURCE_DIR}/${icon}.svg WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${icon}.svg ) add_custom_target( "icon-${icon}-${format}" ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${icon}.${format} ) endforeach() endforeach()