|
| 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() |
0 commit comments