forked from openstreetmap/mod_tile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
298 lines (256 loc) · 8.34 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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
#-----------------------------------------------------------------------------
#
# CMake Config
#
#-----------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
#-----------------------------------------------------------------------------
#
# Project version
#
#-----------------------------------------------------------------------------
project(mod_tile VERSION 0.7.0)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
set(ENABLE_MAN ON CACHE BOOL "Build man pages")
set(ENABLE_TESTS OFF CACHE BOOL "Build test suite")
set(CMAKE_INSTALL_MODULESDIR CACHE PATH "Apache HTTP Server module installation directory")
#-----------------------------------------------------------------------------
#
# Find external dependencies
#
#-----------------------------------------------------------------------------
include(GNUInstallDirs)
# Packages
find_package(CURL)
find_package(ICU REQUIRED uc)
find_package(Threads REQUIRED)
find_package(APR REQUIRED)
find_package(CAIRO REQUIRED)
find_package(GLIB REQUIRED)
find_package(HTTPD REQUIRED)
find_package(INIPARSER REQUIRED)
find_package(LIBMAPNIK REQUIRED)
find_package(LIBMEMCACHED)
find_package(LIBRADOS)
if(LIBMAPNIK_VERSION STRGREATER_EQUAL "4")
set(CMAKE_CXX_STANDARD 14)
endif()
# Programs
find_program(APXS_EXECUTABLE apxs REQUIRED)
# Functions
include(CheckFunctionExists)
# check_function_exists(bzero HAVE_BZERO)
check_function_exists(daemon HAVE_DAEMON)
# check_function_exists(gethostbyname HAVE_GETHOSTBYNAME)
check_function_exists(getloadavg HAVE_GETLOADAVG)
# check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
# check_function_exists(inet_ntoa HAVE_INET_NTOA)
# check_function_exists(memset HAVE_MEMSET)
# check_function_exists(mkdir HAVE_MKDIR)
# check_function_exists(pow HAVE_POW)
# check_function_exists(select HAVE_SELECT)
# check_function_exists(socket HAVE_SOCKET)
# check_function_exists(strchr HAVE_STRCHR)
# check_function_exists(strdup HAVE_STRDUP)
# check_function_exists(strerror HAVE_STRERROR)
# check_function_exists(strrchr HAVE_STRRCHR)
# check_function_exists(strstr HAVE_STRSTR)
# check_function_exists(strtol HAVE_STRTOL)
# check_function_exists(strtoul HAVE_STRTOUL)
# check_function_exists(utime HAVE_UTIME)
# Include files
include(CheckIncludeFile)
# check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
# check_include_file(fcntl.h HAVE_FCNTL_H)
# check_include_file(limits.h HAVE_LIMITS_H)
# check_include_file(netdb.h HAVE_NETDB_H)
# check_include_file(netinet/in.h HAVE_NETINET_IN_H)
check_include_file(paths.h HAVE_PATHS_H)
# check_include_file(stdint.h HAVE_STDINT_H)
# check_include_file(stdlib.h HAVE_STDLIB_H)
# check_include_file(string.h HAVE_STRING_H)
check_include_file(sys/cdefs.h HAVE_SYS_CDEFS_H)
check_include_file(sys/loadavg.h HAVE_SYS_LOADAVG_H)
# check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
# check_include_file(sys/time.h HAVE_SYS_TIME_H)
# check_include_file(syslog.h HAVE_SYSLOG_H)
# check_include_file(unistd.h HAVE_UNISTD_H)
# check_include_file(utime.h HAVE_UTIME_H)
#-----------------------------------------------------------------------------
#
# Set variables
#
#-----------------------------------------------------------------------------
execute_process(COMMAND ${APXS_EXECUTABLE} -q libexecdir
OUTPUT_VARIABLE HTTPD_LIBEXECDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(COMMAND ${APXS_EXECUTABLE} -q sysconfdir
OUTPUT_VARIABLE HTTPD_SYSCONFDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(LIBMAPNIK_VERSION STRLESS "4")
find_program(MAPNIK_CONFIG_EXECUTABLE NAMES mapnik-config REQUIRED)
execute_process(COMMAND ${MAPNIK_CONFIG_EXECUTABLE} --fonts
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE MAPNIK_FONTS_DIR
)
execute_process(COMMAND ${MAPNIK_CONFIG_EXECUTABLE} --input-plugins
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE MAPNIK_PLUGINS_DIR
)
elseif(LIBMAPNIK_VERSION STRGREATER_EQUAL "4")
pkg_get_variable(MAPNIK_FONTS_DIR libmapnik fonts_dir)
pkg_get_variable(MAPNIK_PLUGINS_DIR libmapnik plugins_dir)
endif()
if(NOT CMAKE_INSTALL_MODULESDIR)
set(CMAKE_INSTALL_MODULESDIR ${HTTPD_LIBEXECDIR})
endif()
if(CAIRO_FOUND)
set(HAVE_CAIRO 1)
endif()
if(CURL_FOUND)
set(HAVE_LIBCURL 1)
endif()
if(LIBMEMCACHED_FOUND)
set(HAVE_LIBMEMCACHED 1)
endif()
if(LIBRADOS_FOUND)
set(HAVE_LIBRADOS 1)
endif()
if(CMAKE_HAVE_PTHREAD_H)
set(HAVE_PTHREAD 1)
endif()
set(MAPNIK_FONTS_DIR "${MAPNIK_FONTS_DIR}")
set(MAPNIK_FONTS_DIR_RECURSE 0)
set(MAPNIK_PLUGINS_DIR "${MAPNIK_PLUGINS_DIR}")
set(RENDERD_CONFIG "/${CMAKE_INSTALL_SYSCONFDIR}/renderd.conf")
set(RENDERD_RUN_DIR "/${CMAKE_INSTALL_RUNSTATEDIR}/renderd")
set(RENDERD_TILE_DIR "/${CMAKE_INSTALL_LOCALSTATEDIR}/cache/renderd/tiles")
set(RENDERD_PIDFILE "${RENDERD_RUN_DIR}/renderd.pid")
set(RENDERD_SOCKET "${RENDERD_RUN_DIR}/renderd.sock")
set(TILE_LOAD_DIRECTORY "${HTTPD_SYSCONFDIR}")
set(TILE_LOAD_FILENAME "tile.load")
set(VERSION "${PROJECT_VERSION}")
#-----------------------------------------------------------------------------
#
# Configure
#
#-----------------------------------------------------------------------------
# include/config.h.in
configure_file(
${PROJECT_SOURCE_DIR}/includes/config.h.in
${PROJECT_SOURCE_DIR}/includes/config.h
)
# etc/apache2/tile.load.in
configure_file(
${PROJECT_SOURCE_DIR}/etc/apache2/tile.load.in
${PROJECT_BINARY_DIR}/tile.load
)
# etc/renderd/renderd.conf.in
configure_file(
${PROJECT_SOURCE_DIR}/etc/renderd/renderd.conf.in
${PROJECT_BINARY_DIR}/renderd.conf
)
#-----------------------------------------------------------------------------
#
# Build
#
#-----------------------------------------------------------------------------
add_subdirectory(src)
#-----------------------------------------------------------------------------
#
# Install
#
#-----------------------------------------------------------------------------
# Determine install destination for 'etc/apache2/tile.load.in'
if(EXISTS "/etc/os-release")
execute_process(COMMAND sh -c ". /etc/os-release && echo $ID"
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE DISTRO_ID
)
message(STATUS "Found ID='${DISTRO_ID}' in '/etc/os-release'")
if(DISTRO_ID MATCHES "arch")
set(TILE_LOAD_DIRECTORY "${HTTPD_SYSCONFDIR}/extra")
set(TILE_LOAD_FILENAME "httpd-tile.conf")
elseif(DISTRO_ID MATCHES "centos|fedora|rhel")
set(TILE_LOAD_DIRECTORY "${HTTPD_SYSCONFDIR}.modules.d")
set(TILE_LOAD_FILENAME "11-tile.conf")
elseif(DISTRO_ID MATCHES "debian|ubuntu")
set(TILE_LOAD_DIRECTORY "${HTTPD_SYSCONFDIR}/mods-available")
elseif(DISTRO_ID MATCHES "freebsd")
set(TILE_LOAD_DIRECTORY "${HTTPD_SYSCONFDIR}/modules.d")
set(TILE_LOAD_FILENAME "080_tile.conf")
elseif(DISTRO_ID MATCHES "opensuse-leap")
set(TILE_LOAD_DIRECTORY "${HTTPD_SYSCONFDIR}/conf.d")
set(TILE_LOAD_FILENAME "mod_tile.conf")
endif()
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(TILE_LOAD_DIRECTORY "${HTTPD_SYSCONFDIR}/extra")
set(TILE_LOAD_FILENAME "httpd-tile.conf")
endif()
message(STATUS "File 'etc/apache2/tile.load.in' will be installed to '${TILE_LOAD_DIRECTORY}/${TILE_LOAD_FILENAME}'")
# Directories
install(
DIRECTORY
DESTINATION ${RENDERD_TILE_DIR}
)
install(
DIRECTORY
DESTINATION ${RENDERD_RUN_DIR}
)
# Configuration files
install(
FILES
${PROJECT_BINARY_DIR}/tile.load
DESTINATION ${TILE_LOAD_DIRECTORY}
RENAME ${TILE_LOAD_FILENAME}
)
install(
FILES
${PROJECT_BINARY_DIR}/renderd.conf
DESTINATION /${CMAKE_INSTALL_SYSCONFDIR}
)
# Targets
install(
TARGETS
mod_tile
render_expired
render_list
render_old
render_speedtest
renderd
LIBRARY DESTINATION ${CMAKE_INSTALL_MODULESDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# Man files
if(ENABLE_MAN)
install(
FILES
docs/man/render_expired.1
docs/man/render_list.1
docs/man/render_old.1
docs/man/render_speedtest.1
docs/man/renderd.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
)
install(
FILES
docs/man/renderd.conf.5
DESTINATION ${CMAKE_INSTALL_MANDIR}/man5
)
endif()
#-----------------------------------------------------------------------------
#
# Test
#
#-----------------------------------------------------------------------------
if(ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)
endif()