forked from qgis/QGIS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
245 lines (179 loc) · 7.2 KB
/
CMakeLists.txt
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
PROJECT(qgis)
# TODO:
# - install includes for libs
# - nice output when configured
# - rename *.ui files to have the same filename as their implementation
# e.g. instead of blahblahbase.ui use blahblah.ui
# because it's more common in Qt4
#############################################################
# CMake settings
CMAKE_MINIMUM_REQUIRED(VERSION 2.4.3)
SET(CMAKE_COLOR_MAKEFILE ON)
# set path to additional CMake modules
SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# it's possible to set PLUGINS_ALSO_BINARIES to TRUE
# then some plugins that can run as standalone apps will be built
# also as standalone apps
SET (PLUGINS_ALSO_BINARIES FALSE)
# try to configure and build GRASS plugin by default
SET (WITH_GRASS TRUE CACHE BOOL "Determines whether GRASS plugin should be built")
SET (GRASS_PREFIX "" CACHE PATH "Path to GRASS base directory")
# try to configure and build python bindings by default
SET (WITH_BINDINGS TRUE CACHE BOOL "Determines whether python bindings should be built")
# By default bindings will be installed only to QGIS directory
# Someone might want to install it to python site-packages directory
# as otherwise user has to use PYTHONPATH environemnt variable to add
# QGIS bindings to package search path
SET (BINDINGS_GLOBAL_INSTALL FALSE CACHE BOOL "Install bindings to global python directory? (might need root)")
# Compile flag. Make it posible to turn it off.
SET (PEDANTIC TRUE CACHE BOOL "Determines if we should compile with -Wall -Werror.")
# hide this variable because building of python bindings might fail
# if set to other directory than expected
MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH)
#############################################################
# check if lexer and parser are not missing
# http://www.mail-archive.com/[email protected]/msg02861.html
INCLUDE(Flex)
FIND_FLEX()
IF (NOT FLEX_EXECUTABLE)
MESSAGE(FATAL_ERROR "Couldn't find Flex")
ENDIF (NOT FLEX_EXECUTABLE)
INCLUDE(Bison)
FIND_BISON()
IF (NOT BISON_EXECUTABLE)
MESSAGE(FATAL_ERROR "Couldn't find Bison")
ENDIF (NOT BISON_EXECUTABLE)
#############################################################
# search for dependencies
# required
FIND_PACKAGE(Proj)
FIND_PACKAGE(Sqlite3)
FIND_PACKAGE(GEOS)
FIND_PACKAGE(GDAL)
# optional
FIND_PACKAGE(Postgres) # PostgreSQL provider, SPIT plugin
FIND_PACKAGE(Expat) # GPS importer plugin
FIND_PACKAGE(GSL) # Georeferencer
FIND_PACKAGE(GRASS) # GRASS plugin
# python support:
# - mapserver export tool
# - bindings
INCLUDE (Python) # file cmake/Python.cmake
IF (NOT PROJ_FOUND OR NOT SQLITE3_FOUND OR NOT GEOS_FOUND OR NOT GDAL_FOUND)
MESSAGE (SEND_ERROR "Some dependencies were not found!")
ENDIF (NOT PROJ_FOUND OR NOT SQLITE3_FOUND OR NOT GEOS_FOUND OR NOT GDAL_FOUND)
IF (POSTGRES_FOUND)
# following variable is used in qgsconfig.h
SET (HAVE_POSTGRESQL TRUE)
ENDIF (POSTGRES_FOUND)
#############################################################
# search for Qt4
SET( QT_USE_QT3SUPPORT TRUE )
SET( QT_USE_QTXML TRUE )
SET( QT_USE_QTNETWORK TRUE )
SET( QT_USE_QTSVG TRUE )
# TODO: should not be needed, report it to CMake devs
IF (APPLE AND QT_USE_QT3SUPPORT)
SET( QT_USE_QTSQL TRUE )
ENDIF (APPLE AND QT_USE_QT3SUPPORT)
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE( ${QT_USE_FILE} )
FIND_PROGRAM(QT_LRELEASE_EXECUTABLE
NAMES lrelease
PATHS ${QT_BINARY_DIR}
NO_DEFAULT_PATH
)
#############################################################
# enable warnings
IF (PEDANTIC)
ADD_DEFINITIONS( -Wall -Werror )
ENDIF (PEDANTIC)
IF (CMAKE_BUILD_TYPE MATCHES Debug)
ADD_DEFINITIONS(-DQGISDEBUG=1)
ENDIF (CMAKE_BUILD_TYPE MATCHES Debug)
#############################################################
# platform specific stuff
IF (WIN32)
SET (QGIS_BIN_DIR ${CMAKE_INSTALL_PREFIX})
SET (QGIS_DATA_DIR ${CMAKE_INSTALL_PREFIX})
SET (QGIS_PLUGIN_DIR ${CMAKE_INSTALL_PREFIX}/plugins)
SET (QGIS_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
SET (QGIS_SOURCE_DIR ${CMAKE_SOURCE_DIR})
ELSE (WIN32)
IF (APPLE)
# for Mac OS X, everything is put inside an application bundle
SET (CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}.app/Contents/MacOS)
# path for library references
SET (CMAKE_INSTALL_NAME_DIR @executable_path/lib)
ENDIF (APPLE)
# common for MAC and UNIX
SET (QGIS_BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin)
SET (QGIS_DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/qgis)
SET (QGIS_PLUGIN_DIR ${CMAKE_INSTALL_PREFIX}/lib/qgis)
SET(QGIS_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include/qgis")
SET (QGIS_SOURCE_DIR ${CMAKE_SOURCE_DIR})
IF (UNIX AND NOT APPLE)
ADD_DEFINITIONS(-DPREFIX=\\"${CMAKE_INSTALL_PREFIX}\\")
ADD_DEFINITIONS(-DPLUGINPATH=\\"${QGIS_PLUGIN_DIR}\\")
ADD_DEFINITIONS(-DPKGDATAPATH=\\"${QGIS_DATA_DIR}\\")
ENDIF (UNIX AND NOT APPLE)
ENDIF (WIN32)
IF (WIN32)
# expect that classes are being imported
# Note: MSVC doesn't like when the macros are quotes
# and MSYS doesn't like them unqouted (bacause of braces)
IF (MSVC)
ADD_DEFINITIONS("-DCORE_EXPORT=__declspec(dllimport)")
ADD_DEFINITIONS("-DGUI_EXPORT=__declspec(dllimport)")
ELSE (MSVC)
ADD_DEFINITIONS("\"-DCORE_EXPORT=__declspec(dllimport)\"")
ADD_DEFINITIONS("\"-DGUI_EXPORT=__declspec(dllimport)\"")
ENDIF (MSVC)
ELSE (WIN32)
# other compilers don't use that MSVC construct
ADD_DEFINITIONS(-DCORE_EXPORT=)
ADD_DEFINITIONS(-DGUI_EXPORT=)
ENDIF (WIN32)
#############################################################
# create qgsconfig.h
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/qgsconfig.h.in ${CMAKE_BINARY_DIR}/qgsconfig.h)
INSTALL(FILES ${CMAKE_BINARY_DIR}/qgsconfig.h DESTINATION ${QGIS_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
#############################################################
# create qgssvnversion.h
FIND_FILE(SVN_MARKER entries PATHS ${CMAKE_SOURCE_DIR}/.svn)
IF (NOT SVN_MARKER)
SET (SVN_MARKER ${CMAKE_SOURCE_DIR}/CMakeLists.txt) # Dummy file
ENDIF (NOT SVN_MARKER)
# Add a custom command to drive the svn script whenever the svn entries
# file changes.
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/svnscript.cmake.in_cmake
${CMAKE_CURRENT_BINARY_DIR}/svnscript.cmake
@ONLY)
ADD_CUSTOM_COMMAND (
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h
DEPENDS ${SVN_MARKER}
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/svnscript.cmake
)
ADD_CUSTOM_TARGET(svnversion ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/qgssvnversion.h)
#############################################################
# process subdirs
SUBDIRS(src doc images resources i18n tools)
IF (HAVE_PYTHON)
SUBDIRS (python)
ENDIF (HAVE_PYTHON)
#############################################################
# install stuff
INSTALL (FILES AUTHORS SPONSORS
DESTINATION ${QGIS_DATA_DIR}/doc)
# manual page... install also on windows?
INSTALL (FILES qgis.man
DESTINATION ${CMAKE_INSTALL_PREFIX}/man/man1)
#############################################################
# Uninstall stuff see: http://www.vtk.org/Wiki/CMake_FAQ
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")