-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindQGIS.cmake
248 lines (241 loc) · 7.52 KB
/
FindQGIS.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
## Once run this will define:
##
## QGIS_FOUND = system has QGIS lib
##
## QGIS_CORE_LIBRARY = full path to the CORE library
## QGIS_GUI_LIBRARY = full path to the GUI library
## QGIS_ANALYSIS_LIBRARY = full path to the ANALYSIS library
## QGIS_PLUGIN_DIR = full path to where QGIS plugins are installed
## QGIS_INCLUDE_DIR = where to find headers
## QGIS_UI_INCLUDE_DIR = where to find ui_* generated headers
##
## QGIS_VERSION = version as defined in qgsconfig.h, as major.minor.patch
##
## Definitions or ENV variables affecting search locations
##
## OSGEO4W_ROOT = [A-Z]:/path/to/OSGeo4W/install/root
## (^ use forward slashes!)
## OSGEO4W_QGIS_SUBDIR = qgis[-rel|-ltr][-dev], in OSGEO4W_ROOT/apps/
## QGIS_MAC_PATH = /path/to/any/QGIS.app/Contents
## QGIS_BUILD_PATH = [A-Z:]/path/to/QGIS/build/directory
##
## Tim Sutton
## Larry Shaffer (2017-01-31)
#MESSAGE("Searching for QGIS")
IF(WIN32)
# OSGEO4W_QGIS_SUBDIR relative install: qgis[-rel|-ltr][-dev], etc.
IF (NOT OSGEO4W_QGIS_SUBDIR OR "${OSGEO4W_QGIS_SUBDIR}" STREQUAL "")
IF (NOT "$ENV{OSGEO4W_QGIS_SUBDIR}" STREQUAL "")
SET (OSGEO4W_QGIS_SUBDIR $ENV{OSGEO4W_QGIS_SUBDIR})
ELSE ()
SET (OSGEO4W_QGIS_SUBDIR qgis)
ENDIF ()
ENDIF ()
#MESSAGE("Searching for QGIS in $ENV{PROGRAMFILES}/QGIS")
IF (MINGW)
FIND_PATH(QGIS_PLUGIN_DIR
NAMES libofflineeditingplugin.dll
PATHS
"$ENV{PROGRAMFILES}/QGIS/plugins"
)
FIND_PATH(QGIS_INCLUDE_DIR
NAMES qgsapplication.h
PATHS
"$ENV{PROGRAMFILES}/QGIS/include"
)
FIND_LIBRARY(QGIS_CORE_LIBRARY
NAMES qgis_core
PATHS
"$ENV{PROGRAMFILES}/QGIS/"
)
FIND_LIBRARY(QGIS_GUI_LIBRARY
NAMES qgis_gui
PATHS
"$ENV{PROGRAMFILES}/QGIS/"
)
ENDIF (MINGW)
IF (MSVC)
FIND_PATH(QGIS_PLUGIN_DIR
NAMES offlineeditingplugin.dll
PATHS
"$ENV{OSGEO4W_ROOT}/apps/${OSGEO4W_QGIS_SUBDIR}/plugins"
"$ENV{PROGRAMFILES}/QGIS/plugins"
)
FIND_PATH(QGIS_INCLUDE_DIR
NAMES qgsapplication.h
PATHS
"$ENV{INCLUDE}"
"$ENV{LIB_DIR}/include/qgis"
"$ENV{OSGEO4W_ROOT}/include"
"$ENV{OSGEO4W_ROOT}/apps/${OSGEO4W_QGIS_SUBDIR}/include"
"$ENV{PROGRAMFILES}/QGIS/include"
)
FIND_LIBRARY(QGIS_CORE_LIBRARY
NAMES qgis_core
PATHS
"$ENV{LIB_DIR}/lib/"
"$ENV{LIB}"
"$ENV{OSGEO4W_ROOT}/lib"
"$ENV{OSGEO4W_ROOT}/apps/${OSGEO4W_QGIS_SUBDIR}/lib"
"$ENV{PROGRAMFILES}/QGIS/lib"
)
FIND_LIBRARY(QGIS_GUI_LIBRARY
NAMES qgis_gui
PATHS
"$ENV{LIB_DIR}"
"$ENV{LIB}"
"$ENV{OSGEO4W_ROOT}/lib"
"$ENV{OSGEO4W_ROOT}/apps/${OSGEO4W_QGIS_SUBDIR}/lib"
"$ENV{PROGRAMFILES}/QGIS/lib"
)
FIND_LIBRARY(QGIS_ANALYSIS_LIBRARY
NAMES qgis_analysis
PATHS
"$ENV{LIB_DIR}"
"$ENV{LIB}"
"$ENV{OSGEO4W_ROOT}/lib"
"$ENV{OSGEO4W_ROOT}/apps/${OSGEO4W_QGIS_SUBDIR}/lib"
"$ENV{PROGRAMFILES}/QGIS/lib"
)
ENDIF (MSVC)
ELSE(WIN32)
IF(UNIX)
#MESSAGE("Searching for QGIS in /usr/bin; /usr/local/bin")
FIND_PATH(QGIS_PLUGIN_DIR
NAMES libofflineeditingplugin.so
PATHS
${QGIS_BUILD_PATH}/PlugIns/qgis
${QGIS_MAC_PATH}/PlugIns/qgis
${QGIS_PREFIX_PATH}/lib/qgis/plugins/
/usr/lib64/qgis/plugins
/usr/lib/qgis
/usr/lib/qgis/plugins
/usr/local/lib/qgis/plugins
"$ENV{LIB_DIR}/lib/qgis/plugins"
"$ENV{LIB_DIR}/lib/qgis"
)
FIND_PATH(QGIS_INCLUDE_DIR
NAMES qgis.h
PATHS
${QGIS_BUILD_PATH}/output/lib/qgis_core.framework/Headers
${QGIS_MAC_PATH}/Frameworks/qgis_core.framework/Headers
${QGIS_PREFIX_PATH}/include/qgis
/usr/include/qgis
/usr/local/include/qgis
/Library/Frameworks/qgis_core.framework/Headers
"$ENV{LIB_DIR}/include/qgis"
)
FIND_PATH(QGIS_UI_INCLUDE_DIR
NAMES ui_qgscredentialdialog.h
PATHS
${QGIS_BUILD_PATH}/src/ui
${QGIS_MAC_PATH}/Frameworks/qgis_gui.framework/Headers
${QGIS_PREFIX_PATH}/include/qgis
/usr/include/qgis
/usr/local/include/qgis
/Library/Frameworks/qgis_gui.framework/Headers
"$ENV{LIB_DIR}/include/qgis"
)
# also get other frameworks' headers folders on OS X
IF (APPLE)
FIND_PATH(QGIS_GUI_INCLUDE_DIR
NAMES qgsguiutils.h
PATHS
${QGIS_BUILD_PATH}/output/lib
${QGIS_MAC_PATH}/Frameworks
/Library/Frameworks
PATH_SUFFIXES qgis_gui.framework/Headers
)
FIND_PATH(QGIS_ANALYSIS_INCLUDE_DIR
NAMES qgsinterpolator.h
PATHS
${QGIS_BUILD_PATH}/output/lib
${QGIS_MAC_PATH}/Frameworks
/Library/Frameworks
PATH_SUFFIXES qgis_analysis.framework/Headers
)
SET(QGIS_INCLUDE_DIR
${QGIS_INCLUDE_DIR}
${QGIS_GUI_INCLUDE_DIR}
${QGIS_ANALYSIS_INCLUDE_DIR}
${QGIS_UI_INCLUDE_DIR}
)
ENDIF (APPLE)
FIND_LIBRARY(QGIS_CORE_LIBRARY
NAMES qgis_core
PATHS
${QGIS_BUILD_PATH}/output/lib
${QGIS_MAC_PATH}/Frameworks
${QGIS_MAC_PATH}/lib
${QGIS_PREFIX_PATH}/lib/
/usr/lib64
/usr/lib
/usr/local/lib
/Library/Frameworks
"$ENV{LIB_DIR}/lib/"
)
FIND_LIBRARY(QGIS_GUI_LIBRARY
NAMES qgis_gui
PATHS
${QGIS_BUILD_PATH}/output/lib
${QGIS_MAC_PATH}/Frameworks
${QGIS_MAC_PATH}/lib
${QGIS_PREFIX_PATH}/lib/
/usr/lib64
/usr/lib
/usr/local/lib
/Library/Frameworks
"$ENV{LIB_DIR}/lib/"
)
FIND_LIBRARY(QGIS_ANALYSIS_LIBRARY
NAMES qgis_analysis
PATHS
${QGIS_BUILD_PATH}/output/lib
${QGIS_MAC_PATH}/Frameworks
${QGIS_MAC_PATH}/lib
${QGIS_PREFIX_PATH}/lib/
/usr/lib64
/usr/lib
/usr/local/lib
/Library/Frameworks
"$ENV{LIB_DIR}/lib/"
)
ENDIF(UNIX)
ENDIF(WIN32)
IF (QGIS_INCLUDE_DIR)
SET(QGIS_VERSION QGIS_VERSION-NOTFOUND)
FIND_FILE(_qgsconfig_h qgsconfig.h PATHS ${QGIS_INCLUDE_DIR})
IF (_qgsconfig_h)
FILE(READ ${_qgsconfig_h} _qgsconfig)
IF (_qgsconfig)
# version defined like #define VERSION "2.14.8-Essen"
FILE(STRINGS "${_qgsconfig_h}" _qgsversion_str REGEX "^#define VERSION .*$")
STRING(REGEX REPLACE "^#define VERSION +\"([0-9]+\\.[0-9]+\\.[0-9]+).*$" "\\1" _qgsversion "${_qgsversion_str}")
IF (_qgsversion)
SET(QGIS_VERSION ${_qgsversion})
ELSE ()
MESSAGE(WARNING "No QGIS version determined: failed to parse qgsconfig.h")
ENDIF ()
ELSE()
MESSAGE(WARNING "No QGIS version determined: failed to read qgsconfig.h")
ENDIF ()
ELSE ()
MESSAGE(WARNING "No QGIS version determined: failed to find qgsconfig.h")
ENDIF ()
ENDIF ()
IF (QGIS_INCLUDE_DIR AND QGIS_CORE_LIBRARY AND QGIS_GUI_LIBRARY AND QGIS_ANALYSIS_LIBRARY)
SET(QGIS_FOUND TRUE)
ENDIF ()
IF (QGIS_FOUND)
IF (NOT QGIS_FIND_QUIETLY)
MESSAGE(STATUS "Found QGIS: ${QGIS_VERSION}")
MESSAGE(STATUS "Found QGIS core: ${QGIS_CORE_LIBRARY}")
MESSAGE(STATUS "Found QGIS gui: ${QGIS_GUI_LIBRARY}")
MESSAGE(STATUS "Found QGIS analysis: ${QGIS_ANALYSIS_LIBRARY}")
MESSAGE(STATUS "Found QGIS plugins directory: ${QGIS_PLUGIN_DIR}")
ENDIF (NOT QGIS_FIND_QUIETLY)
ELSE (QGIS_FOUND)
IF (QGIS_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find QGIS")
ENDIF (QGIS_FIND_REQUIRED)
ENDIF (QGIS_FOUND)