summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 797128f9562d2734e430ba816080f99846770db4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
cmake_minimum_required(VERSION 3.10)

project(art-inkscape LANGUAGES NONE)

file(GLOB icon_files "${CMAKE_CURRENT_SOURCE_DIR}/icons/*.svg")

set(formats
	pdf
	svg
	png
	ico
)

find_program(imagemagick magick convert)

foreach(icon_file ${icon_files})
	get_filename_component(icon ${icon_file} NAME_WE)
	foreach(format ${formats})
		set(source "${CMAKE_CURRENT_SOURCE_DIR}/icons/${icon}.svg")
		set(sink "${CMAKE_CURRENT_BINARY_DIR}/icons/${format}/${icon}.${format}")
		if(format STREQUAL ico)
			set(intermediate "${CMAKE_CURRENT_BINARY_DIR}/icons/png/${icon}.png")
			add_custom_command(
				OUTPUT
					${sink}
				COMMAND
					${imagemagick}
					${intermediate}
					${sink}
				DEPENDS
					${intermediate}
			)
		else()
			add_custom_command(
				OUTPUT
					${sink}
				COMMAND
					SELF_CALL=xxx # https://gitlab.com/inkscape/inkscape/-/issues/4716
					inkscape
					--export-type=${format}
					--export-filename=${sink}
					${source}
				DEPENDS
					${source}
			)
		endif()
		add_custom_target(
			"icon-${icon}-${format}"
			ALL
			DEPENDS
				${sink}
		)
	endforeach()
endforeach()