K3D_ADD_SHARE_FILES(*.svg k3d/ngui/scalable)

FIND_PROGRAM(RSVG_COMMAND rsvg)

IF(RSVG_COMMAND)
	FILE(GLOB SVG_FILES *.svg)
	LIST(SORT SVG_FILES)

	FOREACH(SVG_FILE ${SVG_FILES})
		GET_FILENAME_COMPONENT(SVG_NAME ${SVG_FILE} NAME_WE)
		SET(PNG_BINARY_FILE "${share_BINARY_DIR}/ngui/rasterized/${SVG_NAME}.png")
		LIST(APPEND PNG_BINARY_FILES ${PNG_BINARY_FILE})

		ADD_CUSTOM_COMMAND(
			DEPENDS ${SVG_FILE}
			COMMAND ${RSVG_COMMAND} ${SVG_FILE} ${PNG_BINARY_FILE}
			OUTPUT ${PNG_BINARY_FILE}
			)
	ENDFOREACH(SVG_FILE)

	ADD_CUSTOM_TARGET(rasterize-svg-resources
		DEPENDS ${PNG_BINARY_FILES}
		)
ENDIF()

