summaryrefslogtreecommitdiff
path: root/CMake/FindInkscape.cmake
blob: 0ed703457ea7e1c3173cd00d8759247f09d273de (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

# Try to find the Inkscape command-line SVG rasterizer
# Once done this will define
#
# Inkscape_FOUND
# Inkscape_EXECUTABLE   Where to find Inkscape
# Inkscape_VERSION      The Inkscape version number
# Inkscape_EXPORT       Option to specify the destination file
# Inkscape_GUI          Option to disable the GUI if needed
#
# Module is from https://github.com/arx/ArxLibertatis

find_program(
	Inkscape_EXECUTABLE
	NAMES inkscape
    HINTS "C:/Program Files/Inkscape/bin" 
	DOC "Inkscape command-line SVG rasterizer"
)

execute_process(COMMAND ${Inkscape_EXECUTABLE} "--version" OUTPUT_VARIABLE _Inkscape_VERSION ERROR_QUIET)
STRING(REGEX MATCH "[1-9]\.[0-9\+\.[0-9]+" _Inkscape_VERSION ${_Inkscape_VERSION})

set(Inkscape_VERSION ${_Inkscape_VERSION} CACHE STRING "Inkscape Version")

execute_process(COMMAND ${Inkscape_EXECUTABLE} "--help" OUTPUT_VARIABLE _Inkscape_HELP ERROR_QUIET)

if(_Inkscape_HELP MATCHES "--without-gui")
	set(Inkscape_GUI "--without-gui" CACHE STRING "Inkscape option to disable the GUI if needed")
endif()

if(NOT DEFINED Inkscape_EXPORT)
	foreach(option IN ITEMS "--export-filename=" "--export-file=" "--export-png=")
		if(_Inkscape_HELP MATCHES "${option}")
			set(Inkscape_EXPORT "${option}" CACHE STRING "Inkscape option to specify the export filename")
			break()
		endif()
	endforeach()
	if(NOT DEFINED Inkscape_EXPORT)
		message(WARNING "Could not determine Inkscape export file option, assuming -o")
		set(Inkscape_EXPORT "-o " CACHE STRING "Inkscape option to specify the export filename")
	endif()
endif()

# handle the QUIETLY and REQUIRED arguments and set Inkscape_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Inkscape REQUIRED_VARS Inkscape_EXECUTABLE)