-
Notifications
You must be signed in to change notification settings - Fork 2
/
FindFUSE.cmake
148 lines (113 loc) · 4.82 KB
/
FindFUSE.cmake
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#------------------------------------------------------------------------------
#
# Copyright (C) 2010 Artem Rodygin
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#------------------------------------------------------------------------------
#
# This module finds if C API of FUSE library is installed and determines where required
# include files and libraries are. The module sets the following variables:
#
# FUSE_FOUND - system has FUSE
# FUSE_INCLUDE_DIR - the FUSE include directory
# FUSE_LIBRARIES - the libraries needed to use FUSE
# FUSE_DEFINITIONS - the compiler definitions, required for building with FUSE
# FUSE_VERSION_MAJOR - the major version of the FUSE release
# FUSE_VERSION_MINOR - the minor version of the FUSE release
#
# You can help the module to find FUSE by specifying its root path
# in environment variable named "FUSE_ROOTDIR". If this variable is not set
# then module will search for files in "/usr/local" and "/usr" by default.
#
#------------------------------------------------------------------------------
set(FUSE_FOUND TRUE)
# search for header
find_path(FUSE_INCLUDE_DIR
NAMES "fuse/fuse.h"
"fuse/fuse_common.h"
PATHS "/usr/local"
"/usr"
ENV FUSE_ROOTDIR
PATH_SUFFIXES "include")
# header is found
if (FUSE_INCLUDE_DIR)
set(FUSE_INCLUDE_DIR "${FUSE_INCLUDE_DIR}/fuse")
# retrieve version information from the header
file(READ "${FUSE_INCLUDE_DIR}/fuse_common.h" FUSE_COMMON_H_FILE)
string(REGEX REPLACE ".*#define[ \t]+FUSE_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" FUSE_VERSION_MAJOR "${FUSE_COMMON_H_FILE}")
string(REGEX REPLACE ".*#define[ \t]+FUSE_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" FUSE_VERSION_MINOR "${FUSE_COMMON_H_FILE}")
# search for library
find_library(FUSE_LIBRARIES
NAMES "libfuse.so"
PATHS "/usr/local"
"/usr"
ENV FUSE_ROOTDIR
PATH_SUFFIXES "lib")
endif (FUSE_INCLUDE_DIR)
# header is not found
if (NOT FUSE_INCLUDE_DIR)
set(FUSE_FOUND FALSE)
endif (NOT FUSE_INCLUDE_DIR)
# library is not found
if (NOT FUSE_LIBRARIES)
set(FUSE_FOUND FALSE)
endif (NOT FUSE_LIBRARIES)
# set default error message
if (FUSE_FIND_VERSION)
set(FUSE_ERROR_MESSAGE "Unable to find FUSE library v${FUSE_FIND_VERSION}")
else (FUSE_FIND_VERSION)
set(FUSE_ERROR_MESSAGE "Unable to find FUSE library")
endif (FUSE_FIND_VERSION)
# check found version
if (FUSE_FIND_VERSION AND FUSE_FOUND)
set(FUSE_FOUND_VERSION "${FUSE_VERSION_MAJOR}.${FUSE_VERSION_MINOR}")
if (FUSE_FIND_VERSION_EXACT)
if (NOT ${FUSE_FOUND_VERSION} VERSION_EQUAL ${FUSE_FIND_VERSION})
set(FUSE_FOUND FALSE)
endif (NOT ${FUSE_FOUND_VERSION} VERSION_EQUAL ${FUSE_FIND_VERSION})
else (FUSE_FIND_VERSION_EXACT)
if (${FUSE_FOUND_VERSION} VERSION_LESS ${FUSE_FIND_VERSION})
set(FUSE_FOUND FALSE)
endif (${FUSE_FOUND_VERSION} VERSION_LESS ${FUSE_FIND_VERSION})
endif (FUSE_FIND_VERSION_EXACT)
if (NOT FUSE_FOUND)
set(FUSE_ERROR_MESSAGE "Unable to find FUSE library v${FUSE_FIND_VERSION} (${FUSE_FOUND_VERSION} was found)")
endif (NOT FUSE_FOUND)
endif (FUSE_FIND_VERSION AND FUSE_FOUND)
# add definitions
if (FUSE_FOUND)
if (CMAKE_SYSTEM_PROCESSOR MATCHES ia64)
set(FUSE_DEFINITIONS "-D_REENTRANT -D_FILE_OFFSET_BITS=64")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES amd64)
set(FUSE_DEFINITIONS "-D_REENTRANT -D_FILE_OFFSET_BITS=64")
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES x86_64)
set(FUSE_DEFINITIONS "-D_REENTRANT -D_FILE_OFFSET_BITS=64")
else (CMAKE_SYSTEM_PROCESSOR MATCHES ia64)
set(FUSE_DEFINITIONS "-D_REENTRANT")
endif (CMAKE_SYSTEM_PROCESSOR MATCHES ia64)
endif (FUSE_FOUND)
# final status messages
if (FUSE_FOUND)
if (NOT FUSE_FIND_QUIETLY)
message(STATUS "FUSE ${FUSE_VERSION_MAJOR}.${FUSE_VERSION_MINOR}")
endif (NOT FUSE_FIND_QUIETLY)
mark_as_advanced(FUSE_INCLUDE_DIR
FUSE_LIBRARIES
FUSE_DEFINITIONS)
else (FUSE_FOUND)
if (FUSE_FIND_REQUIRED)
message(SEND_ERROR "${FUSE_ERROR_MESSAGE}")
endif (FUSE_FIND_REQUIRED)
endif (FUSE_FOUND)