blob: ee6495627e287925490b90f0f6a2de6e05a59847 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
# - Try to find the shared-mime-info package
#
# SHARED_MIME_INFO_MINIMUM_VERSION - Set this to the minimum version you need, default is 0.18
#
# Once done this will define
#
# SHARED_MIME_INFO_FOUND - system has the shared-mime-info package
# UPDATE_MIME_DATABASE_EXECUTABLE - the update-mime-database executable
# Copyright (c) 2007, Pino Toscano, <toscano.pino@tiscali.it>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# the minimum version of shared-mime-database we require
if (NOT SHARED_MIME_INFO_MINIMUM_VERSION)
set(SHARED_MIME_INFO_MINIMUM_VERSION "0.18")
endif (NOT SHARED_MIME_INFO_MINIMUM_VERSION)
if (UPDATE_MIME_DATABASE_EXECUTABLE)
# in cache already
set(SHARED_MIME_INFO_FOUND TRUE)
else (UPDATE_MIME_DATABASE_EXECUTABLE)
include (MacroEnsureVersion)
find_program (UPDATE_MIME_DATABASE_EXECUTABLE NAMES update-mime-database)
if (UPDATE_MIME_DATABASE_EXECUTABLE)
exec_program (${UPDATE_MIME_DATABASE_EXECUTABLE} ARGS -v RETURN_VALUE _null OUTPUT_VARIABLE _smiVersionRaw)
string(REGEX REPLACE "update-mime-database \\([a-zA-Z\\-]+\\) ([0-9]\\.[0-9]+).*"
"\\1" smiVersion "${_smiVersionRaw}")
set (SHARED_MIME_INFO_FOUND TRUE)
endif (UPDATE_MIME_DATABASE_EXECUTABLE)
if (SHARED_MIME_INFO_FOUND)
if (NOT SharedMimeInfo_FIND_QUIETLY)
message(STATUS "Found shared-mime-info version: ${smiVersion}")
macro_ensure_version(${SHARED_MIME_INFO_MINIMUM_VERSION} ${smiVersion} _smiVersion_OK)
if (NOT _smiVersion_OK)
message(FATAL_ERROR "The found version of shared-mime-info (${smiVersion}) is below the minimum required (${SHARED_MIME_INFO_MINIMUM_VERSION})")
endif (NOT _smiVersion_OK)
endif (NOT SharedMimeInfo_FIND_QUIETLY)
else (SHARED_MIME_INFO_FOUND)
if (SharedMimeInfo_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find shared-mime-info. See http://freedesktop.org/wiki/Software/shared-mime-info.")
endif (SharedMimeInfo_FIND_REQUIRED)
endif (SHARED_MIME_INFO_FOUND)
endif (UPDATE_MIME_DATABASE_EXECUTABLE)
mark_as_advanced(UPDATE_MIME_DATABASE_EXECUTABLE)
macro(UPDATE_XDG_MIMETYPES _path)
get_filename_component(_xdgmimeDir "${_path}" NAME)
if("${_xdgmimeDir}" STREQUAL packages )
get_filename_component(_xdgmimeDir "${_path}" PATH)
else("${_xdgmimeDir}" STREQUAL packages )
set(_xdgmimeDir "${_path}")
endif("${_xdgmimeDir}" STREQUAL packages )
install(CODE "
set(DESTDIR_VALUE \"\$ENV{DESTDIR}\")
if (NOT DESTDIR_VALUE)
# under Windows relative paths are used, that's why it runs from CMAKE_INSTALL_PREFIX
execute_process(COMMAND ${UPDATE_MIME_DATABASE_EXECUTABLE} ${_xdgmimeDir}
WORKING_DIRECTORY \"${CMAKE_INSTALL_PREFIX}\")
endif (NOT DESTDIR_VALUE)
")
endmacro (UPDATE_XDG_MIMETYPES)
|