Skip to content

Commit f4ee376

Browse files
hummeltechǝɹʇʇɐʃǝ◖ xıʃǝɟ
authored andcommitted
Build mod_tile with cmake
1 parent 6c8a1d9 commit f4ee376

15 files changed

Lines changed: 1113 additions & 0 deletions

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*.slo
88
aclocal.m4
99
autom4te.cache/
10+
build
11+
!docs/build
1012
compile
1113
config.guess
1214
config.guess~

CMakeLists.txt

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
#-----------------------------------------------------------------------------
2+
#
3+
# CMake Config
4+
#
5+
#-----------------------------------------------------------------------------
6+
7+
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
8+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
9+
10+
#-----------------------------------------------------------------------------
11+
#
12+
# Project version
13+
#
14+
#-----------------------------------------------------------------------------
15+
16+
project(mod_tile VERSION 0.6.1)
17+
18+
set(CMAKE_C_STANDARD 99)
19+
set(CMAKE_C_STANDARD_REQUIRED ON)
20+
set(CMAKE_CXX_STANDARD 11)
21+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
22+
set(THREADS_PREFER_PTHREAD_FLAG ON)
23+
24+
set(ENABLE_MAN ON CACHE BOOL "Build man pages")
25+
set(ENABLE_TESTS OFF CACHE BOOL "Build test suite")
26+
27+
#-----------------------------------------------------------------------------
28+
#
29+
# Find external dependencies
30+
#
31+
#-----------------------------------------------------------------------------
32+
33+
include(GNUInstallDirs)
34+
35+
# Packages
36+
find_package(CURL)
37+
find_package(ICU REQUIRED uc)
38+
find_package(Threads REQUIRED)
39+
40+
find_package(APR REQUIRED)
41+
find_package(Cairo REQUIRED)
42+
find_package(GLib REQUIRED)
43+
find_package(HTTPD REQUIRED)
44+
find_package(IniParser REQUIRED)
45+
find_package(LibMemcached)
46+
find_package(LibRados)
47+
find_package(Mapnik REQUIRED)
48+
49+
# Programs
50+
find_program(APXS_EXECUTABLE apxs REQUIRED)
51+
52+
# Functions
53+
include(CheckFunctionExists)
54+
# check_function_exists(bzero HAVE_BZERO)
55+
check_function_exists(daemon HAVE_DAEMON)
56+
# check_function_exists(gethostbyname HAVE_GETHOSTBYNAME)
57+
check_function_exists(getloadavg HAVE_GETLOADAVG)
58+
# check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
59+
# check_function_exists(inet_ntoa HAVE_INET_NTOA)
60+
# check_function_exists(memset HAVE_MEMSET)
61+
# check_function_exists(mkdir HAVE_MKDIR)
62+
# check_function_exists(pow HAVE_POW)
63+
# check_function_exists(select HAVE_SELECT)
64+
# check_function_exists(socket HAVE_SOCKET)
65+
# check_function_exists(strchr HAVE_STRCHR)
66+
# check_function_exists(strdup HAVE_STRDUP)
67+
# check_function_exists(strerror HAVE_STRERROR)
68+
# check_function_exists(strrchr HAVE_STRRCHR)
69+
# check_function_exists(strstr HAVE_STRSTR)
70+
# check_function_exists(strtol HAVE_STRTOL)
71+
# check_function_exists(strtoul HAVE_STRTOUL)
72+
# check_function_exists(utime HAVE_UTIME)
73+
74+
# Include files
75+
include(CheckIncludeFile)
76+
# check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
77+
# check_include_file(fcntl.h HAVE_FCNTL_H)
78+
# check_include_file(limits.h HAVE_LIMITS_H)
79+
# check_include_file(netdb.h HAVE_NETDB_H)
80+
# check_include_file(netinet/in.h HAVE_NETINET_IN_H)
81+
check_include_file(paths.h HAVE_PATHS_H)
82+
# check_include_file(stdint.h HAVE_STDINT_H)
83+
# check_include_file(stdlib.h HAVE_STDLIB_H)
84+
# check_include_file(string.h HAVE_STRING_H)
85+
check_include_file(sys/cdefs.h HAVE_SYS_CDEFS_H)
86+
check_include_file(sys/loadavg.h HAVE_SYS_LOADAVG_H)
87+
# check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
88+
# check_include_file(sys/time.h HAVE_SYS_TIME_H)
89+
# check_include_file(syslog.h HAVE_SYSLOG_H)
90+
# check_include_file(unistd.h HAVE_UNISTD_H)
91+
# check_include_file(utime.h HAVE_UTIME_H)
92+
93+
#-----------------------------------------------------------------------------
94+
#
95+
# Set variables
96+
#
97+
#-----------------------------------------------------------------------------
98+
99+
execute_process(COMMAND ${APXS_EXECUTABLE} -q exp_libexecdir
100+
OUTPUT_VARIABLE HTTPD_MODULES_DIR
101+
OUTPUT_STRIP_TRAILING_WHITESPACE
102+
)
103+
104+
if(Cairo_FOUND)
105+
set(HAVE_CAIRO 1)
106+
endif()
107+
108+
if(CURL_FOUND)
109+
set(HAVE_LIBCURL 1)
110+
endif()
111+
112+
if(LibMemcached_FOUND)
113+
set(HAVE_LIBMEMCACHED 1)
114+
endif()
115+
116+
if(LibRados_FOUND)
117+
set(HAVE_LIBRADOS 1)
118+
endif()
119+
120+
if(CMAKE_HAVE_PTHREAD_H)
121+
set(HAVE_PTHREAD 1)
122+
endif()
123+
124+
set(VERSION ${PROJECT_VERSION})
125+
126+
#-----------------------------------------------------------------------------
127+
#
128+
# config.h
129+
#
130+
#-----------------------------------------------------------------------------
131+
132+
configure_file(
133+
${PROJECT_SOURCE_DIR}/includes/config.h.in
134+
${PROJECT_SOURCE_DIR}/includes/config.h
135+
)
136+
137+
#-----------------------------------------------------------------------------
138+
#
139+
# Build
140+
#
141+
#-----------------------------------------------------------------------------
142+
143+
add_subdirectory(src)
144+
145+
#-----------------------------------------------------------------------------
146+
#
147+
# Install
148+
#
149+
#-----------------------------------------------------------------------------
150+
151+
install(
152+
TARGETS
153+
mod_tile
154+
render_expired
155+
render_list
156+
render_old
157+
render_speedtest
158+
renderd
159+
LIBRARY DESTINATION ${HTTPD_MODULES_DIR}
160+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
161+
)
162+
163+
if (ENABLE_MAN)
164+
install(
165+
FILES
166+
docs/man/render_expired.1
167+
docs/man/render_list.1
168+
docs/man/render_old.1
169+
docs/man/render_speedtest.1
170+
docs/man/renderd.1
171+
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
172+
)
173+
endif()
174+
175+
#-----------------------------------------------------------------------------
176+
#
177+
# Test
178+
#
179+
#-----------------------------------------------------------------------------
180+
181+
if (ENABLE_TESTS)
182+
enable_testing()
183+
add_subdirectory(tests)
184+
endif()

cmake/FindAPR.cmake

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# - Find APR
2+
# Find the APR includes and libraries.
3+
# This module defines:
4+
# APR_FOUND
5+
# APR_INCLUDE_DIRS
6+
# APR_LIBRARIES
7+
8+
find_package(PkgConfig QUIET)
9+
pkg_check_modules(APR QUIET apr-1)
10+
11+
find_path(APR_INCLUDE_DIR
12+
NAMES apr.h
13+
PATHS ${APR_INCLUDE_DIRS}
14+
PATH_SUFFIXES apr-1
15+
)
16+
17+
if((NOT APR_INCLUDE_DIRS) AND (APR_INCLUDE_DIR))
18+
set(APR_INCLUDE_DIRS ${APR_INCLUDE_DIR})
19+
elseif(APR_INCLUDE_DIRS AND APR_INCLUDE_DIR)
20+
list(APPEND APR_INCLUDE_DIRS ${APR_INCLUDE_DIR})
21+
endif()
22+
23+
find_library(APR_LIBRARY
24+
NAMES ${APR_LIBRARIES} apr-1
25+
)
26+
27+
if((NOT APR_LIBRARIES) AND (APR_LIBRARY))
28+
set(APR_LIBRARIES ${APR_LIBRARY})
29+
elseif(APR_LIBRARIES AND APR_LIBRARY)
30+
list(APPEND APR_LIBRARIES ${APR_LIBRARY})
31+
endif()
32+
33+
message(VERBOSE "APR_INCLUDE_DIRS=${APR_INCLUDE_DIRS}")
34+
message(VERBOSE "APR_INCLUDE_DIR=${APR_INCLUDE_DIR}")
35+
message(VERBOSE "APR_LIBRARIES=${APR_LIBRARIES}")
36+
message(VERBOSE "APR_LIBRARY=${APR_LIBRARY}")
37+
38+
if((NOT APR_FOUND) AND (APR_INCLUDE_DIRS) AND (APR_LIBRARIES))
39+
set(APR_FOUND True)
40+
endif()
41+
42+
include(FindPackageHandleStandardArgs)
43+
find_package_handle_standard_args(APR
44+
FOUND_VAR APR_FOUND
45+
REQUIRED_VARS APR_FOUND APR_INCLUDE_DIRS APR_LIBRARIES
46+
VERSION_VAR APR_VERSION
47+
)
48+
49+
mark_as_advanced(APR_INCLUDE_DIR APR_LIBRARY)

cmake/FindCairo.cmake

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# - Find Cairo
2+
# Find the Cairo includes and libraries.
3+
# This module defines:
4+
# Cairo_FOUND
5+
# Cairo_INCLUDE_DIRS
6+
# Cairo_LIBRARIES
7+
8+
find_package(PkgConfig QUIET)
9+
pkg_check_modules(Cairo QUIET cairo)
10+
11+
find_path(Cairo_INCLUDE_DIR
12+
NAMES cairo.h
13+
PATHS ${Cairo_INCLUDE_DIRS}
14+
PATH_SUFFIXES cairo
15+
)
16+
17+
if((NOT Cairo_INCLUDE_DIRS) AND (Cairo_INCLUDE_DIR))
18+
set(Cairo_INCLUDE_DIRS ${Cairo_INCLUDE_DIR})
19+
elseif(Cairo_INCLUDE_DIRS AND Cairo_INCLUDE_DIR)
20+
list(APPEND Cairo_INCLUDE_DIRS ${Cairo_INCLUDE_DIR})
21+
endif()
22+
23+
find_library(Cairo_LIBRARY
24+
NAMES ${Cairo_LIBRARIES} cairo
25+
)
26+
27+
if((NOT Cairo_LIBRARIES) AND (Cairo_LIBRARY))
28+
set(Cairo_LIBRARIES ${Cairo_LIBRARY})
29+
elseif(Cairo_LIBRARIES AND Cairo_LIBRARY)
30+
list(APPEND Cairo_LIBRARIES ${Cairo_LIBRARY})
31+
endif()
32+
33+
message(VERBOSE "Cairo_INCLUDE_DIRS=${Cairo_INCLUDE_DIRS}")
34+
message(VERBOSE "Cairo_INCLUDE_DIR=${Cairo_INCLUDE_DIR}")
35+
message(VERBOSE "Cairo_LIBRARIES=${Cairo_LIBRARIES}")
36+
message(VERBOSE "Cairo_LIBRARY=${Cairo_LIBRARY}")
37+
38+
if((NOT Cairo_FOUND) AND (Cairo_INCLUDE_DIRS) AND (Cairo_LIBRARIES))
39+
set(Cairo_FOUND True)
40+
endif()
41+
42+
include(FindPackageHandleStandardArgs)
43+
find_package_handle_standard_args(Cairo
44+
FOUND_VAR Cairo_FOUND
45+
REQUIRED_VARS Cairo_FOUND Cairo_INCLUDE_DIRS Cairo_LIBRARIES
46+
VERSION_VAR Cairo_VERSION
47+
)
48+
49+
mark_as_advanced(Cairo_INCLUDE_DIR Cairo_LIBRARY)

cmake/FindGLib.cmake

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# - Find GLib
2+
# Find the GLib includes and libraries.
3+
# This module defines:
4+
# GLib_FOUND
5+
# GLib_INCLUDE_DIRS
6+
# GLib_LIBRARIES
7+
8+
find_package(PkgConfig QUIET)
9+
pkg_check_modules(GLib QUIET glib-2.0)
10+
11+
find_path(GLib_INCLUDE_DIR
12+
NAMES glib.h
13+
PATHS ${GLib_INCLUDE_DIRS}
14+
PATH_SUFFIXES glib-2.0
15+
)
16+
17+
if((NOT GLib_INCLUDE_DIRS) AND (GLib_INCLUDE_DIR))
18+
set(GLib_INCLUDE_DIRS ${GLib_INCLUDE_DIR})
19+
elseif(GLib_INCLUDE_DIRS AND GLib_INCLUDE_DIR)
20+
list(APPEND GLib_INCLUDE_DIRS ${GLib_INCLUDE_DIR})
21+
endif()
22+
23+
find_library(GLib_LIBRARY
24+
NAMES ${GLib_LIBRARIES} glib-2.0
25+
)
26+
27+
if((NOT GLib_LIBRARIES) AND (GLib_LIBRARY))
28+
set(GLib_LIBRARIES ${GLib_LIBRARY})
29+
elseif(GLib_LIBRARIES AND GLib_LIBRARY)
30+
list(APPEND GLib_LIBRARIES ${GLib_LIBRARY})
31+
endif()
32+
33+
message(VERBOSE "GLib_INCLUDE_DIRS=${GLib_INCLUDE_DIRS}")
34+
message(VERBOSE "GLib_INCLUDE_DIR=${GLib_INCLUDE_DIR}")
35+
message(VERBOSE "GLib_LIBRARIES=${GLib_LIBRARIES}")
36+
message(VERBOSE "GLib_LIBRARY=${GLib_LIBRARY}")
37+
38+
if((NOT GLib_FOUND) AND (GLib_INCLUDE_DIRS) AND (GLib_LIBRARIES))
39+
set(GLib_FOUND True)
40+
endif()
41+
42+
include(FindPackageHandleStandardArgs)
43+
find_package_handle_standard_args(GLib
44+
FOUND_VAR GLib_FOUND
45+
REQUIRED_VARS GLib_FOUND GLib_INCLUDE_DIRS GLib_LIBRARIES
46+
VERSION_VAR GLib_VERSION
47+
)
48+
49+
mark_as_advanced(GLib_INCLUDE_DIR GLib_LIBRARY)

cmake/FindHTTPD.cmake

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# - Find HTTPD
2+
# Find the HTTPD includes and libraries.
3+
# This module defines:
4+
# HTTPD_FOUND
5+
# HTTPD_INCLUDE_DIRS
6+
7+
find_package(PkgConfig QUIET)
8+
pkg_check_modules(HTTPD QUIET httpd)
9+
10+
find_path(HTTPD_INCLUDE_DIR
11+
NAMES httpd.h
12+
PATHS ${HTTPD_INCLUDE_DIRS}
13+
PATH_SUFFIXES apache2 apache24 httpd
14+
)
15+
16+
if((NOT HTTPD_INCLUDE_DIRS) AND (HTTPD_INCLUDE_DIR))
17+
set(HTTPD_INCLUDE_DIRS ${HTTPD_INCLUDE_DIR})
18+
elseif(HTTPD_INCLUDE_DIRS AND HTTPD_INCLUDE_DIR)
19+
list(APPEND HTTPD_INCLUDE_DIRS ${HTTPD_INCLUDE_DIR})
20+
endif()
21+
22+
message(VERBOSE "HTTPD_INCLUDE_DIRS=${HTTPD_INCLUDE_DIRS}")
23+
message(VERBOSE "HTTPD_INCLUDE_DIR=${HTTPD_INCLUDE_DIR}")
24+
25+
if((NOT HTTPD_FOUND) AND (HTTPD_INCLUDE_DIRS))
26+
set(HTTPD_FOUND True)
27+
endif()
28+
29+
if((NOT HTTPD_VERSION) AND (HTTPD_FOUND))
30+
file(STRINGS "${HTTPD_INCLUDE_DIR}/ap_release.h" _contents REGEX "#define AP_SERVER_[A-Z]+_NUMBER[ \t]+")
31+
if (_contents)
32+
string(REGEX REPLACE ".*#define AP_SERVER_MAJORVERSION_NUMBER[ \t]+([0-9]+).*" "\\1" HTTPD_MAJOR_VERSION "${_contents}")
33+
string(REGEX REPLACE ".*#define AP_SERVER_MINORVERSION_NUMBER[ \t]+([0-9]+).*" "\\1" HTTPD_MINOR_VERSION "${_contents}")
34+
string(REGEX REPLACE ".*#define AP_SERVER_PATCHLEVEL_NUMBER[ \t]+([0-9]+).*" "\\1" HTTPD_PATCH_VERSION "${_contents}")
35+
36+
set(HTTPD_VERSION ${HTTPD_MAJOR_VERSION}.${HTTPD_MINOR_VERSION}.${HTTPD_PATCH_VERSION})
37+
endif ()
38+
endif ()
39+
40+
include(FindPackageHandleStandardArgs)
41+
find_package_handle_standard_args(HTTPD
42+
FOUND_VAR HTTPD_FOUND
43+
REQUIRED_VARS HTTPD_FOUND HTTPD_INCLUDE_DIRS
44+
VERSION_VAR HTTPD_VERSION
45+
)
46+
47+
mark_as_advanced(HTTPD_INCLUDE_DIR)

0 commit comments

Comments
 (0)