Build mod_tile with cmake

This commit is contained in:
David Hummel
2022-05-16 18:40:59 -07:00
committed by ǝɹʇʇɐʃǝ◖ xıʃǝɟ
parent 6c8a1d9aec
commit f4ee376b35
15 changed files with 1113 additions and 0 deletions

2
.gitignore vendored
View File

@ -7,6 +7,8 @@
*.slo
aclocal.m4
autom4te.cache/
build
!docs/build
compile
config.guess
config.guess~

184
CMakeLists.txt Normal file
View File

@ -0,0 +1,184 @@
#-----------------------------------------------------------------------------
#
# CMake Config
#
#-----------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
#-----------------------------------------------------------------------------
#
# Project version
#
#-----------------------------------------------------------------------------
project(mod_tile VERSION 0.6.1)
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")
#-----------------------------------------------------------------------------
#
# 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(LibMemcached)
find_package(LibRados)
find_package(Mapnik REQUIRED)
# 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 exp_libexecdir
OUTPUT_VARIABLE HTTPD_MODULES_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
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(VERSION ${PROJECT_VERSION})
#-----------------------------------------------------------------------------
#
# config.h
#
#-----------------------------------------------------------------------------
configure_file(
${PROJECT_SOURCE_DIR}/includes/config.h.in
${PROJECT_SOURCE_DIR}/includes/config.h
)
#-----------------------------------------------------------------------------
#
# Build
#
#-----------------------------------------------------------------------------
add_subdirectory(src)
#-----------------------------------------------------------------------------
#
# Install
#
#-----------------------------------------------------------------------------
install(
TARGETS
mod_tile
render_expired
render_list
render_old
render_speedtest
renderd
LIBRARY DESTINATION ${HTTPD_MODULES_DIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
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
)
endif()
#-----------------------------------------------------------------------------
#
# Test
#
#-----------------------------------------------------------------------------
if (ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)
endif()

49
cmake/FindAPR.cmake Normal file
View File

@ -0,0 +1,49 @@
# - Find APR
# Find the APR includes and libraries.
# This module defines:
# APR_FOUND
# APR_INCLUDE_DIRS
# APR_LIBRARIES
find_package(PkgConfig QUIET)
pkg_check_modules(APR QUIET apr-1)
find_path(APR_INCLUDE_DIR
NAMES apr.h
PATHS ${APR_INCLUDE_DIRS}
PATH_SUFFIXES apr-1
)
if((NOT APR_INCLUDE_DIRS) AND (APR_INCLUDE_DIR))
set(APR_INCLUDE_DIRS ${APR_INCLUDE_DIR})
elseif(APR_INCLUDE_DIRS AND APR_INCLUDE_DIR)
list(APPEND APR_INCLUDE_DIRS ${APR_INCLUDE_DIR})
endif()
find_library(APR_LIBRARY
NAMES ${APR_LIBRARIES} apr-1
)
if((NOT APR_LIBRARIES) AND (APR_LIBRARY))
set(APR_LIBRARIES ${APR_LIBRARY})
elseif(APR_LIBRARIES AND APR_LIBRARY)
list(APPEND APR_LIBRARIES ${APR_LIBRARY})
endif()
message(VERBOSE "APR_INCLUDE_DIRS=${APR_INCLUDE_DIRS}")
message(VERBOSE "APR_INCLUDE_DIR=${APR_INCLUDE_DIR}")
message(VERBOSE "APR_LIBRARIES=${APR_LIBRARIES}")
message(VERBOSE "APR_LIBRARY=${APR_LIBRARY}")
if((NOT APR_FOUND) AND (APR_INCLUDE_DIRS) AND (APR_LIBRARIES))
set(APR_FOUND True)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(APR
FOUND_VAR APR_FOUND
REQUIRED_VARS APR_FOUND APR_INCLUDE_DIRS APR_LIBRARIES
VERSION_VAR APR_VERSION
)
mark_as_advanced(APR_INCLUDE_DIR APR_LIBRARY)

49
cmake/FindCairo.cmake Normal file
View File

@ -0,0 +1,49 @@
# - Find Cairo
# Find the Cairo includes and libraries.
# This module defines:
# Cairo_FOUND
# Cairo_INCLUDE_DIRS
# Cairo_LIBRARIES
find_package(PkgConfig QUIET)
pkg_check_modules(Cairo QUIET cairo)
find_path(Cairo_INCLUDE_DIR
NAMES cairo.h
PATHS ${Cairo_INCLUDE_DIRS}
PATH_SUFFIXES cairo
)
if((NOT Cairo_INCLUDE_DIRS) AND (Cairo_INCLUDE_DIR))
set(Cairo_INCLUDE_DIRS ${Cairo_INCLUDE_DIR})
elseif(Cairo_INCLUDE_DIRS AND Cairo_INCLUDE_DIR)
list(APPEND Cairo_INCLUDE_DIRS ${Cairo_INCLUDE_DIR})
endif()
find_library(Cairo_LIBRARY
NAMES ${Cairo_LIBRARIES} cairo
)
if((NOT Cairo_LIBRARIES) AND (Cairo_LIBRARY))
set(Cairo_LIBRARIES ${Cairo_LIBRARY})
elseif(Cairo_LIBRARIES AND Cairo_LIBRARY)
list(APPEND Cairo_LIBRARIES ${Cairo_LIBRARY})
endif()
message(VERBOSE "Cairo_INCLUDE_DIRS=${Cairo_INCLUDE_DIRS}")
message(VERBOSE "Cairo_INCLUDE_DIR=${Cairo_INCLUDE_DIR}")
message(VERBOSE "Cairo_LIBRARIES=${Cairo_LIBRARIES}")
message(VERBOSE "Cairo_LIBRARY=${Cairo_LIBRARY}")
if((NOT Cairo_FOUND) AND (Cairo_INCLUDE_DIRS) AND (Cairo_LIBRARIES))
set(Cairo_FOUND True)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Cairo
FOUND_VAR Cairo_FOUND
REQUIRED_VARS Cairo_FOUND Cairo_INCLUDE_DIRS Cairo_LIBRARIES
VERSION_VAR Cairo_VERSION
)
mark_as_advanced(Cairo_INCLUDE_DIR Cairo_LIBRARY)

49
cmake/FindGLib.cmake Normal file
View File

@ -0,0 +1,49 @@
# - Find GLib
# Find the GLib includes and libraries.
# This module defines:
# GLib_FOUND
# GLib_INCLUDE_DIRS
# GLib_LIBRARIES
find_package(PkgConfig QUIET)
pkg_check_modules(GLib QUIET glib-2.0)
find_path(GLib_INCLUDE_DIR
NAMES glib.h
PATHS ${GLib_INCLUDE_DIRS}
PATH_SUFFIXES glib-2.0
)
if((NOT GLib_INCLUDE_DIRS) AND (GLib_INCLUDE_DIR))
set(GLib_INCLUDE_DIRS ${GLib_INCLUDE_DIR})
elseif(GLib_INCLUDE_DIRS AND GLib_INCLUDE_DIR)
list(APPEND GLib_INCLUDE_DIRS ${GLib_INCLUDE_DIR})
endif()
find_library(GLib_LIBRARY
NAMES ${GLib_LIBRARIES} glib-2.0
)
if((NOT GLib_LIBRARIES) AND (GLib_LIBRARY))
set(GLib_LIBRARIES ${GLib_LIBRARY})
elseif(GLib_LIBRARIES AND GLib_LIBRARY)
list(APPEND GLib_LIBRARIES ${GLib_LIBRARY})
endif()
message(VERBOSE "GLib_INCLUDE_DIRS=${GLib_INCLUDE_DIRS}")
message(VERBOSE "GLib_INCLUDE_DIR=${GLib_INCLUDE_DIR}")
message(VERBOSE "GLib_LIBRARIES=${GLib_LIBRARIES}")
message(VERBOSE "GLib_LIBRARY=${GLib_LIBRARY}")
if((NOT GLib_FOUND) AND (GLib_INCLUDE_DIRS) AND (GLib_LIBRARIES))
set(GLib_FOUND True)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLib
FOUND_VAR GLib_FOUND
REQUIRED_VARS GLib_FOUND GLib_INCLUDE_DIRS GLib_LIBRARIES
VERSION_VAR GLib_VERSION
)
mark_as_advanced(GLib_INCLUDE_DIR GLib_LIBRARY)

47
cmake/FindHTTPD.cmake Normal file
View File

@ -0,0 +1,47 @@
# - Find HTTPD
# Find the HTTPD includes and libraries.
# This module defines:
# HTTPD_FOUND
# HTTPD_INCLUDE_DIRS
find_package(PkgConfig QUIET)
pkg_check_modules(HTTPD QUIET httpd)
find_path(HTTPD_INCLUDE_DIR
NAMES httpd.h
PATHS ${HTTPD_INCLUDE_DIRS}
PATH_SUFFIXES apache2 apache24 httpd
)
if((NOT HTTPD_INCLUDE_DIRS) AND (HTTPD_INCLUDE_DIR))
set(HTTPD_INCLUDE_DIRS ${HTTPD_INCLUDE_DIR})
elseif(HTTPD_INCLUDE_DIRS AND HTTPD_INCLUDE_DIR)
list(APPEND HTTPD_INCLUDE_DIRS ${HTTPD_INCLUDE_DIR})
endif()
message(VERBOSE "HTTPD_INCLUDE_DIRS=${HTTPD_INCLUDE_DIRS}")
message(VERBOSE "HTTPD_INCLUDE_DIR=${HTTPD_INCLUDE_DIR}")
if((NOT HTTPD_FOUND) AND (HTTPD_INCLUDE_DIRS))
set(HTTPD_FOUND True)
endif()
if((NOT HTTPD_VERSION) AND (HTTPD_FOUND))
file(STRINGS "${HTTPD_INCLUDE_DIR}/ap_release.h" _contents REGEX "#define AP_SERVER_[A-Z]+_NUMBER[ \t]+")
if (_contents)
string(REGEX REPLACE ".*#define AP_SERVER_MAJORVERSION_NUMBER[ \t]+([0-9]+).*" "\\1" HTTPD_MAJOR_VERSION "${_contents}")
string(REGEX REPLACE ".*#define AP_SERVER_MINORVERSION_NUMBER[ \t]+([0-9]+).*" "\\1" HTTPD_MINOR_VERSION "${_contents}")
string(REGEX REPLACE ".*#define AP_SERVER_PATCHLEVEL_NUMBER[ \t]+([0-9]+).*" "\\1" HTTPD_PATCH_VERSION "${_contents}")
set(HTTPD_VERSION ${HTTPD_MAJOR_VERSION}.${HTTPD_MINOR_VERSION}.${HTTPD_PATCH_VERSION})
endif ()
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HTTPD
FOUND_VAR HTTPD_FOUND
REQUIRED_VARS HTTPD_FOUND HTTPD_INCLUDE_DIRS
VERSION_VAR HTTPD_VERSION
)
mark_as_advanced(HTTPD_INCLUDE_DIR)

48
cmake/FindIniParser.cmake Normal file
View File

@ -0,0 +1,48 @@
# - Find IniParser
# Find the IniParser includes and libraries.
# This module defines:
# IniParser_FOUND
# IniParser_INCLUDE_DIRS
# IniParser_LIBRARIES
find_package(PkgConfig QUIET)
pkg_check_modules(IniParser QUIET iniparser)
find_path(IniParser_INCLUDE_DIR
NAMES iniparser.h
PATHS ${IniParser_INCLUDE_DIRS}
PATH_SUFFIXES iniparser
)
if((NOT IniParser_INCLUDE_DIRS) AND (IniParser_INCLUDE_DIR))
set(IniParser_INCLUDE_DIRS ${IniParser_INCLUDE_DIR})
elseif(IniParser_INCLUDE_DIRS AND IniParser_INCLUDE_DIR)
list(APPEND IniParser_INCLUDE_DIRS ${IniParser_INCLUDE_DIR})
endif()
find_library(IniParser_LIBRARY
NAMES ${IniParser_LIBRARIES} iniparser
)
if((NOT IniParser_LIBRARIES) AND (IniParser_LIBRARY))
set(IniParser_LIBRARIES ${IniParser_LIBRARY})
elseif(IniParser_LIBRARIES AND IniParser_LIBRARY)
list(APPEND IniParser_LIBRARIES ${IniParser_LIBRARY})
endif()
message(VERBOSE "IniParser_INCLUDE_DIRS=${IniParser_INCLUDE_DIRS}")
message(VERBOSE "IniParser_INCLUDE_DIR=${IniParser_INCLUDE_DIR}")
message(VERBOSE "IniParser_LIBRARIES=${IniParser_LIBRARIES}")
message(VERBOSE "IniParser_LIBRARY=${IniParser_LIBRARY}")
if((NOT IniParser_FOUND) AND (IniParser_INCLUDE_DIRS) AND (IniParser_LIBRARIES))
set(IniParser_FOUND True)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(IniParser
FOUND_VAR IniParser_FOUND
REQUIRED_VARS IniParser_FOUND IniParser_INCLUDE_DIRS IniParser_LIBRARIES
)
mark_as_advanced(IniParser_INCLUDE_DIR IniParser_LIBRARY)

View File

@ -0,0 +1,49 @@
# - Find LibMemcached
# Find the LibMemcached includes and libraries.
# This module defines:
# LibMemcached_FOUND
# LibMemcached_INCLUDE_DIRS
# LibMemcached_LIBRARIES
find_package(PkgConfig QUIET)
pkg_check_modules(LibMemcached QUIET libmemcached)
find_path(LibMemcached_INCLUDE_DIR
NAMES memcached.h
PATHS ${LibMemcached_INCLUDE_DIRS}
PATH_SUFFIXES libmemcached
)
if((NOT LibMemcached_INCLUDE_DIRS) AND (LibMemcached_INCLUDE_DIR))
set(LibMemcached_INCLUDE_DIRS ${LibMemcached_INCLUDE_DIR})
elseif(LibMemcached_INCLUDE_DIRS AND LibMemcached_INCLUDE_DIR)
list(APPEND LibMemcached_INCLUDE_DIRS ${LibMemcached_INCLUDE_DIR})
endif()
find_library(LibMemcached_LIBRARY
NAMES ${LibMemcached_LIBRARIES} memcached
)
if((NOT LibMemcached_LIBRARIES) AND (LibMemcached_LIBRARY))
set(LibMemcached_LIBRARIES ${LibMemcached_LIBRARY})
elseif(LibMemcached_LIBRARIES AND LibMemcached_LIBRARY)
list(APPEND LibMemcached_LIBRARIES ${LibMemcached_LIBRARY})
endif()
message(VERBOSE "LibMemcached_INCLUDE_DIRS=${LibMemcached_INCLUDE_DIRS}")
message(VERBOSE "LibMemcached_INCLUDE_DIR=${LibMemcached_INCLUDE_DIR}")
message(VERBOSE "LibMemcached_LIBRARIES=${LibMemcached_LIBRARIES}")
message(VERBOSE "LibMemcached_LIBRARY=${LibMemcached_LIBRARY}")
if((NOT LibMemcached_FOUND) AND (LibMemcached_INCLUDE_DIRS) AND (LibMemcached_LIBRARIES))
set(LibMemcached_FOUND True)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibMemcached
FOUND_VAR LibMemcached_FOUND
REQUIRED_VARS LibMemcached_FOUND LibMemcached_INCLUDE_DIRS LibMemcached_LIBRARIES
VERSION_VAR LibMemcached_VERSION
)
mark_as_advanced(LibMemcached_INCLUDE_DIR LibMemcached_LIBRARY)

60
cmake/FindLibRados.cmake Normal file
View File

@ -0,0 +1,60 @@
# - Find LibRados
# Find the LibRados includes and libraries.
# This module defines:
# LibRados_FOUND
# LibRados_INCLUDE_DIRS
# LibRados_LIBRARIES
find_package(PkgConfig QUIET)
pkg_check_modules(LibRados QUIET rados)
find_path(LibRados_INCLUDE_DIR
NAMES librados.h
PATHS ${LibRados_INCLUDE_DIRS}
PATH_SUFFIXES rados
)
if((NOT LibRados_INCLUDE_DIRS) AND (LibRados_INCLUDE_DIR))
set(LibRados_INCLUDE_DIRS ${LibRados_INCLUDE_DIR})
elseif(LibRados_INCLUDE_DIRS AND LibRados_INCLUDE_DIR)
list(APPEND LibRados_INCLUDE_DIRS ${LibRados_INCLUDE_DIR})
endif()
find_library(LibRados_LIBRARY
NAMES ${LibRados_LIBRARIES} rados
)
if((NOT LibRados_LIBRARIES) AND (LibRados_LIBRARY))
set(LibRados_LIBRARIES ${LibRados_LIBRARY})
elseif(LibRados_LIBRARIES AND LibRados_LIBRARY)
list(APPEND LibRados_LIBRARIES ${LibRados_LIBRARY})
endif()
message(VERBOSE "LibRados_INCLUDE_DIRS=${LibRados_INCLUDE_DIRS}")
message(VERBOSE "LibRados_INCLUDE_DIR=${LibRados_INCLUDE_DIR}")
message(VERBOSE "LibRados_LIBRARIES=${LibRados_LIBRARIES}")
message(VERBOSE "LibRados_LIBRARY=${LibRados_LIBRARY}")
if((NOT LibRados_FOUND) AND (LibRados_INCLUDE_DIRS) AND (LibRados_LIBRARIES))
set(LibRados_FOUND True)
endif()
if((NOT LibRados_VERSION) AND (LibRados_FOUND))
file(STRINGS "${LibRados_INCLUDE_DIR}/librados.h" _contents REGEX "#define LIBRADOS_VER_[A-Z]+[ \t]+")
if (_contents)
string(REGEX REPLACE ".*#define LIBRADOS_VER_MAJOR[ \t]+([0-9]+).*" "\\1" LibRados_MAJOR_VERSION "${_contents}")
string(REGEX REPLACE ".*#define LIBRADOS_VER_MINOR[ \t]+([0-9]+).*" "\\1" LibRados_MINOR_VERSION "${_contents}")
string(REGEX REPLACE ".*#define LIBRADOS_VER_EXTRA[ \t]+([0-9]+).*" "\\1" LibRados_EXTRA_VERSION "${_contents}")
set(LibRados_VERSION ${LibRados_MAJOR_VERSION}.${LibRados_MINOR_VERSION}.${LibRados_EXTRA_VERSION})
endif ()
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibRados
FOUND_VAR LibRados_FOUND
REQUIRED_VARS LibRados_FOUND LibRados_INCLUDE_DIRS LibRados_LIBRARIES
VERSION_VAR LibRados_VERSION
)
mark_as_advanced(LibRados_INCLUDE_DIR LibRados_LIBRARY)

60
cmake/FindMapnik.cmake Normal file
View File

@ -0,0 +1,60 @@
# - Find Mapnik
# Find the Mapnik includes and libraries.
# This module defines:
# Mapnik_FOUND
# Mapnik_INCLUDE_DIRS
# Mapnik_LIBRARIES
find_package(PkgConfig QUIET)
pkg_check_modules(Mapnik QUIET mapnik)
find_path(Mapnik_INCLUDE_DIR
NAMES version.hpp
PATHS ${Mapnik_INCLUDE_DIRS}
PATH_SUFFIXES mapnik
)
if((NOT Mapnik_INCLUDE_DIRS) AND (Mapnik_INCLUDE_DIR))
set(Mapnik_INCLUDE_DIRS ${Mapnik_INCLUDE_DIR})
elseif(Mapnik_INCLUDE_DIRS AND Mapnik_INCLUDE_DIR)
list(APPEND Mapnik_INCLUDE_DIRS ${Mapnik_INCLUDE_DIR})
endif()
find_library(Mapnik_LIBRARY
NAMES ${Mapnik_LIBRARIES} mapnik
)
if((NOT Mapnik_LIBRARIES) AND (Mapnik_LIBRARY))
set(Mapnik_LIBRARIES ${Mapnik_LIBRARY})
elseif(Mapnik_LIBRARIES AND Mapnik_LIBRARY)
list(APPEND Mapnik_LIBRARIES ${Mapnik_LIBRARY})
endif()
message(VERBOSE "Mapnik_INCLUDE_DIRS=${Mapnik_INCLUDE_DIRS}")
message(VERBOSE "Mapnik_INCLUDE_DIR=${Mapnik_INCLUDE_DIR}")
message(VERBOSE "Mapnik_LIBRARIES=${Mapnik_LIBRARIES}")
message(VERBOSE "Mapnik_LIBRARY=${Mapnik_LIBRARY}")
if((NOT Mapnik_FOUND) AND (Mapnik_INCLUDE_DIRS) AND (Mapnik_LIBRARIES))
set(Mapnik_FOUND True)
endif()
if((NOT Mapnik_VERSION) AND (Mapnik_FOUND))
file(STRINGS "${Mapnik_INCLUDE_DIR}/version.hpp" _contents REGEX "#define MAPNIK_[A-Z]+_VERSION[ \t]+")
if (_contents)
string(REGEX REPLACE ".*#define MAPNIK_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" Mapnik_MAJOR_VERSION "${_contents}")
string(REGEX REPLACE ".*#define MAPNIK_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" Mapnik_MINOR_VERSION "${_contents}")
string(REGEX REPLACE ".*#define MAPNIK_PATCH_VERSION[ \t]+([0-9]+).*" "\\1" Mapnik_PATCH_VERSION "${_contents}")
set(Mapnik_VERSION ${Mapnik_MAJOR_VERSION}.${Mapnik_MINOR_VERSION}.${Mapnik_PATCH_VERSION})
endif ()
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Mapnik
FOUND_VAR Mapnik_FOUND
REQUIRED_VARS Mapnik_FOUND Mapnik_INCLUDE_DIRS Mapnik_LIBRARIES
VERSION_VAR Mapnik_VERSION
)
mark_as_advanced(Mapnik_INCLUDE_DIR Mapnik_LIBRARY)

18
includes/config.h.in Normal file
View File

@ -0,0 +1,18 @@
/* Define to 1 if you have the functions. */
#cmakedefine HAVE_DAEMON @HAVE_DAEMON@
#cmakedefine HAVE_GETLOADAVG @HAVE_GETLOADAVG@
/* Define to 1 if you have the header files. */
#cmakedefine HAVE_PATHS_H @HAVE_PATHS_H@
#cmakedefine HAVE_PTHREAD @HAVE_PTHREAD@
#cmakedefine HAVE_SYS_CDEFS_H @HAVE_SYS_CDEFS_H@
#cmakedefine HAVE_SYS_LOADAVG_H @HAVE_SYS_LOADAVG_H@
/* Define to 1 if you have the libraries. */
#cmakedefine HAVE_CAIRO @HAVE_CAIRO@
#cmakedefine HAVE_LIBCURL @HAVE_LIBCURL@
#cmakedefine HAVE_LIBMEMCACHED @HAVE_LIBMEMCACHED@
#cmakedefine HAVE_LIBRADOS @HAVE_LIBRADOS@
/* Version number of project */
#cmakedefine VERSION "@VERSION@"

194
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,194 @@
#-----------------------------------------------------------------------------
#
# CMake Config
#
#-----------------------------------------------------------------------------
include_directories(${PROJECT_SOURCE_DIR}/includes)
include_directories(SYSTEM ${APR_INCLUDE_DIRS} ${Cairo_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS} ${GLib_INCLUDE_DIRS} ${HTTPD_INCLUDE_DIRS})
include_directories(SYSTEM ${ICU_INCLUDE_DIRS} ${IniParser_INCLUDE_DIRS} ${LibMemcached_INCLUDE_DIRS} ${LibRados_INCLUDE_DIRS} ${Mapnik_INCLUDE_DIRS})
link_directories(${CMAKE_LIBRARY_PATH})
set(COMMON_SRCS
g_logger.c
sys_utils.c
)
set(COMMON_LIBRARIES
${GLib_LIBRARIES}
Threads::Threads
)
set(STORE_SRCS
store_file_utils.c
store_file.c
store_memcached.c
store_null.c
store_rados.c
store_ro_composite.c
store_ro_http_proxy.c
store.c
)
set(STORE_LIBRARIES
${Cairo_LIBRARIES}
${CURL_LIBRARIES}
${LibMemcached_LIBRARIES}
${LibRados_LIBRARIES}
)
#-----------------------------------------------------------------------------
#
# Installed targets
#
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#
# mod_tile.so
#
#-----------------------------------------------------------------------------
set(mod_tile_SRCS
${COMMON_SRCS}
${STORE_SRCS}
mod_tile.c
)
set(mod_tile_LIBS
${APR_LIBRARIES}
${COMMON_LIBRARIES}
${STORE_LIBRARIES}
)
add_library(mod_tile SHARED ${mod_tile_SRCS})
target_link_libraries(mod_tile ${mod_tile_LIBS})
set_target_properties(mod_tile PROPERTIES PREFIX "" SUFFIX ".so")
#-----------------------------------------------------------------------------
#
# render_expired
#
#-----------------------------------------------------------------------------
set(render_expired_SRCS
${COMMON_SRCS}
${STORE_SRCS}
protocol_helper.c
render_expired.c
render_submit_queue.c
)
set(render_expired_LIBS
${COMMON_LIBRARIES}
${STORE_LIBRARIES}
)
add_executable(render_expired ${render_expired_SRCS})
target_link_libraries(render_expired ${render_expired_LIBS})
#-----------------------------------------------------------------------------
#
# render_list
#
#-----------------------------------------------------------------------------
set(render_list_SRCS
${COMMON_SRCS}
${STORE_SRCS}
protocol_helper.c
render_list.c
render_submit_queue.c
)
set(render_list_LIBS
${COMMON_LIBRARIES}
${STORE_LIBRARIES}
)
add_executable(render_list ${render_list_SRCS})
target_link_libraries(render_list ${render_list_LIBS})
#-----------------------------------------------------------------------------
#
# render_old
#
#-----------------------------------------------------------------------------
set(render_old_SRCS
${COMMON_SRCS}
protocol_helper.c
render_old.c
render_submit_queue.c
store_file_utils.c
)
set(render_old_LIBS
${COMMON_LIBRARIES}
)
add_executable(render_old ${render_old_SRCS})
target_link_libraries(render_old ${render_old_LIBS})
#-----------------------------------------------------------------------------
#
# render_speedtest
#
#-----------------------------------------------------------------------------
set(render_speedtest_SRCS
${COMMON_SRCS}
protocol_helper.c
render_submit_queue.c
speedtest.cpp
)
set(render_speedtest_LIBS
${COMMON_LIBRARIES}
)
add_executable(render_speedtest ${render_speedtest_SRCS})
target_link_libraries(render_speedtest ${render_speedtest_LIBS})
#-----------------------------------------------------------------------------
#
# renderd
#
#-----------------------------------------------------------------------------
set(renderd_SRCS
${COMMON_SRCS}
${STORE_SRCS}
cache_expire.c
daemon_compat.c
daemon.c
gen_tile.cpp
metatile.cpp
parameterize_style.cpp
protocol_helper.c
request_queue.c
)
set(renderd_LIBS
${COMMON_LIBRARIES}
${ICU_LIBRARIES}
${IniParser_LIBRARIES}
${Mapnik_LIBRARIES}
${STORE_LIBRARIES}
)
add_executable(renderd ${renderd_SRCS})
target_link_libraries(renderd ${renderd_LIBS})
#-----------------------------------------------------------------------------
#
# Test targets
#
#-----------------------------------------------------------------------------
if (ENABLE_TESTS)
#-----------------------------------------------------------------------------
#
# gen_tile_test
#
#-----------------------------------------------------------------------------
set(gen_tile_test_SRCS
${renderd_SRCS}
gen_tile_test.cpp
)
set(gen_tile_test_LIBS
${renderd_LIBS}
)
add_executable(gen_tile_test ${gen_tile_test_SRCS})
target_link_libraries(gen_tile_test ${gen_tile_test_LIBS})
target_compile_options(gen_tile_test PRIVATE -DMAIN_ALREADY_DEFINED)
endif()

220
tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,220 @@
#-----------------------------------------------------------------------------
#
# CMake Config
#
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
#
# Find external dependencies
#
#-----------------------------------------------------------------------------
include(Dart)
execute_process(COMMAND ${APXS_EXECUTABLE} -q progname
OUTPUT_VARIABLE APXS_PROGNAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
find_package(UnixCommands REQUIRED)
find_program(CAT_EXECUTABLE NAMES cat REQUIRED)
find_program(CURL_EXECUTABLE NAMES curl REQUIRED)
find_program(HTTPD_EXECUTABLE NAMES ${APXS_PROGNAME} REQUIRED)
find_program(ID_EXECUTABLE NAMES id REQUIRED)
find_program(KILL_EXECUTABLE NAMES kill REQUIRED)
find_program(MAPNIK_CONFIG_EXECUTABLE NAMES mapnik-config REQUIRED)
find_program(MKDIR_EXECUTABLE NAMES mkdir REQUIRED)
find_program(SHA256SUM_EXECUTABLE NAMES gsha256sum sha256sum 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_INPUT_DIR
)
execute_process(COMMAND ${ID_EXECUTABLE} -gn nobody
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE NOGROUP_NAME
)
#-----------------------------------------------------------------------------
#
# Test configurations
#
#-----------------------------------------------------------------------------
set(MAP_NAME "default")
set(TILE_SHA256SUM "dbf26531286e844a3a9735cdd193598dca78d22f77cafe5824bcaf17f88cbb08")
set(TILE_URL "http://localhost:8081/tiles/renderd-example/9/297/191.png")
set(TILE_CMD "${CURL_EXECUTABLE} --fail --silent ${TILE_URL}")
configure_file(
renderd.conf.in
conf/renderd.conf
)
configure_file(
httpd.conf.in
conf/httpd.conf
)
configure_file(
../utils/example-map/index.html
www/index.html
COPYONLY
)
configure_file(
../utils/example-map/mapnik.xml
www/mapnik.xml
COPYONLY
)
configure_file(
../utils/example-map/very_simplified_land_polygons.gpkg
www/very_simplified_land_polygons.gpkg
COPYONLY
)
#-----------------------------------------------------------------------------
#
# Tests
#
#-----------------------------------------------------------------------------
add_test(
NAME gen_tile_test
COMMAND gen_tile_test
WORKING_DIRECTORY src
)
add_test(
NAME create_dirs
COMMAND ${MKDIR_EXECUTABLE} -p -v logs run tiles
)
add_test(
NAME start_renderd
COMMAND ${BASH} -c "
echo '${PROJECT_BINARY_DIR}/src/renderd --config ${PROJECT_BINARY_DIR}/tests/conf/renderd.conf --foreground > ${PROJECT_BINARY_DIR}/tests/logs/renderd.log 2>&1 &' > ${PROJECT_BINARY_DIR}/tests/renderd_start.sh
echo 'printf \${!} > ${PROJECT_BINARY_DIR}/tests/run/renderd.pid' >> ${PROJECT_BINARY_DIR}/tests/renderd_start.sh
echo 'exit 0' >> ${PROJECT_BINARY_DIR}/tests/renderd_start.sh
${BASH} ${PROJECT_BINARY_DIR}/tests/renderd_start.sh
"
)
add_test(
NAME start_httpd
COMMAND ${HTTPD_EXECUTABLE} -e debug -f ${PROJECT_BINARY_DIR}/tests/conf/httpd.conf -k start
)
add_test(
NAME render_speedtest
COMMAND render_speedtest --map ${MAP_NAME} --max-zoom 10 --socket ${PROJECT_BINARY_DIR}/tests/run/renderd.sock
)
add_test(
NAME download_tile
COMMAND ${BASH} -c "
until $(${TILE_CMD} --output tile.png); do
echo 'Sleeping 1s';
sleep 1;
done
"
)
add_test(
NAME check_tile
COMMAND ${BASH} -c "
echo '${TILE_SHA256SUM} tile.png' | ${SHA256SUM_EXECUTABLE} -c
"
)
add_test(
NAME dirty_tile
COMMAND ${BASH} -c "
TILE_STATUS_CMD=\"${TILE_CMD}/status | cut -d. -f2\"
TILE_STATUS_OUTPUT_OLD=$(\${TILE_STATUS_CMD})
sleep 5;
TILE_DIRTY_OUTPUT=$(${TILE_CMD}/dirty)
if [ \"\${TILE_DIRTY_OUTPUT}\" != \"Tile submitted for rendering\" ]; then
exit 1;
fi
until [ \"\${TILE_STATUS_OUTPUT_OLD}\" != \"$(\${TILE_STATUS_CMD})\" ]; do
echo 'Sleeping 1s';
sleep 1;
done
"
)
add_test(
NAME remove_tile
COMMAND ${RM} -v tile.png
)
add_test(
NAME stop_renderd
COMMAND ${BASH} -c "
${KILL_EXECUTABLE} $(${CAT_EXECUTABLE} run/renderd.pid) && ${RM} run/renderd.pid
"
)
add_test(
NAME stop_httpd
COMMAND ${BASH} -c "
${KILL_EXECUTABLE} $(${CAT_EXECUTABLE} run/httpd.pid) && ${RM} run/httpd.pid
"
)
add_test(
NAME clear_dirs
COMMAND ${BASH} -c "
${RM} -f -r -v logs/* run/* tiles/*
"
)
set_tests_properties(create_dirs PROPERTIES
FIXTURES_SETUP httpd_started
)
set_tests_properties(start_renderd PROPERTIES
DEPENDS create_dirs
FIXTURES_SETUP httpd_started
)
set_tests_properties(start_httpd PROPERTIES
DEPENDS create_dirs
FIXTURES_SETUP httpd_started
)
set_tests_properties(stop_renderd PROPERTIES
FIXTURES_CLEANUP httpd_started
REQUIRED_FILES run/renderd.pid
)
set_tests_properties(stop_httpd PROPERTIES
FIXTURES_CLEANUP httpd_started
REQUIRED_FILES run/httpd.pid
)
set_tests_properties(clear_dirs PROPERTIES
DEPENDS "stop_renderd;stop_httpd"
FIXTURES_CLEANUP httpd_started
REQUIRED_FILES "logs;run;tiles"
)
set_tests_properties(render_speedtest PROPERTIES
FIXTURES_REQUIRED httpd_started
TIMEOUT 60
)
set_tests_properties(download_tile PROPERTIES
FIXTURES_REQUIRED httpd_started
FIXTURES_SETUP tile_downloaded
TIMEOUT 10
)
set_tests_properties(check_tile PROPERTIES
DEPENDS download_tile
FIXTURES_REQUIRED "httpd_started;tile_downloaded"
REQUIRED_FILES tile.png
)
set_tests_properties(dirty_tile PROPERTIES
DEPENDS download_tile
FIXTURES_REQUIRED "httpd_started;tile_downloaded"
REQUIRED_FILES tile.png
TIMEOUT 20
)
set_tests_properties(remove_tile PROPERTIES
DEPENDS download_tile
FIXTURES_CLEANUP tile_downloaded
REQUIRED_FILES tile.png
)

69
tests/httpd.conf.in Normal file
View File

@ -0,0 +1,69 @@
Alias /renderd-example-map @PROJECT_BINARY_DIR@/tests/www
Redirect /renderd-example-map/leaflet/leaflet.css https://unpkg.com/leaflet/dist/leaflet.css
Redirect /renderd-example-map/leaflet/leaflet.min.js https://unpkg.com/leaflet/dist/leaflet.js
<Directory @PROJECT_BINARY_DIR@/tests/www>
Allow from all
AllowOverride All
DirectoryIndex index.html
Options +FollowSymLinks
Order Allow,Deny
</Directory>
<IfModule !tile_module>
LoadModule tile_module @PROJECT_BINARY_DIR@/src/mod_tile.so
</IfModule>
<VirtualHost *:8081>
LoadTileConfigFile @PROJECT_BINARY_DIR@/tests/conf/renderd.conf
ModTileBulkMode Off
ModTileCacheDurationDirty 900
ModTileCacheDurationLowZoom 9 518400
ModTileCacheDurationMax 604800
ModTileCacheDurationMediumZoom 13 86400
ModTileCacheDurationMinimum 10800
ModTileCacheLastModifiedFactor 0.20
ModTileEnableStats On
ModTileEnableTileThrottling Off
ModTileEnableTileThrottlingXForward 0
ModTileMaxLoadMissing 5
ModTileMaxLoadOld 2
ModTileMissingRequestTimeout 10
ModTileRenderdSocketName @PROJECT_BINARY_DIR@/tests/run/renderd.sock
ModTileRequestTimeout 3
ModTileThrottlingRenders 128 0.2
ModTileThrottlingTiles 10000 1
ModTileTileDir @PROJECT_BINARY_DIR@/tests/tiles
</VirtualHost>
CustomLog logs/access_log "%h %l %u %t \"%r\" %>s %b"
ErrorLog logs/error_log
Group @NOGROUP_NAME@
Listen 8081
LogLevel debug
PidFile run/httpd.pid
ServerName localhost
ServerRoot @PROJECT_BINARY_DIR@/tests
User nobody
<IfModule !access_compat_module>
LoadModule access_compat_module @HTTPD_MODULES_DIR@/mod_access_compat.so
</IfModule>
<IfModule !alias_module>
LoadModule alias_module @HTTPD_MODULES_DIR@/mod_alias.so
</IfModule>
<IfModule !authz_core_module>
LoadModule authz_core_module @HTTPD_MODULES_DIR@/mod_authz_core.so
</IfModule>
<IfModule !dir_module>
LoadModule dir_module @HTTPD_MODULES_DIR@/mod_dir.so
</IfModule>
<IfModule !log_config_module>
LoadModule log_config_module @HTTPD_MODULES_DIR@/mod_log_config.so
</IfModule>
<IfModule !mpm_event_module>
LoadModule mpm_event_module @HTTPD_MODULES_DIR@/mod_mpm_event.so
</IfModule>
<IfModule !unixd_module>
LoadModule unixd_module @HTTPD_MODULES_DIR@/mod_unixd.so
</IfModule>

15
tests/renderd.conf.in Normal file
View File

@ -0,0 +1,15 @@
[renderd]
pid_file=@PROJECT_BINARY_DIR@/tests/run/renderd.pid
socketname=@PROJECT_BINARY_DIR@/tests/run/renderd.sock
stats_file=@PROJECT_BINARY_DIR@/tests/run/renderd.stats
tile_dir=@PROJECT_BINARY_DIR@/tests/tiles
[mapnik]
font_dir_recurse=true
font_dir=@MAPNIK_FONTS_DIR@
plugins_dir=@MAPNIK_INPUT_DIR@
[@MAP_NAME@]
TILEDIR=@PROJECT_BINARY_DIR@/tests/tiles
URI=/tiles/renderd-example
XML=@PROJECT_BINARY_DIR@/tests/www/mapnik.xml