11cmake_minimum_required (VERSION 2.6)
22
3- project (MapCache)
3+ project (MapCache C )
44
55include (CheckFunctionExists)
66include (CheckIncludeFile)
77include (CheckCSourceCompiles)
88
9- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall" )
109if ("${CMAKE_BUILD_TYPE} " STREQUAL "Debug" )
1110 add_definitions (-DDEBUG)
1211endif ()
1312
1413
1514set (MAPCACHE_VERSION_MAJOR 1)
16- set (MAPCACHE_VERSION_MINOR 3 )
15+ set (MAPCACHE_VERSION_MINOR 11 )
1716set (MAPCACHE_VERSION_REVISION 0)
1817
19-
2018if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
2119 set (CMAKE_INSTALL_LIBDIR lib)
2220endif (NOT DEFINED CMAKE_INSTALL_LIBDIR)
@@ -58,22 +56,37 @@ endmacro()
5856
5957check_function_exists("strncasecmp" HAVE_STRNCASECMP)
6058check_function_exists("symlink" HAVE_SYMLINK)
61-
59+ check_function_exists ("timegm" HAVE_TIMEGM)
60+ check_function_exists ("strptime" HAVE_STRPTIME)
6261
6362set (CMAKE_SKIP_BUILD_RPATH FALSE )
63+ if (APPLE )
64+ set (CMAKE_MACOSX_RPATH ON )
65+ endif ()
6466set (CMAKE_LINK_INTERFACE_LIBRARY "" )
6567
6668file (GLOB mapcache_SOURCES lib/*.c )
69+ file (GLOB mapcache_HEADERS include /*.h)
6770
68- add_library (mapcache SHARED ${mapcache_SOURCES} )
71+ add_library (mapcache SHARED ${mapcache_SOURCES} ${mapcache_HEADERS} )
6972set_target_properties (mapcache PROPERTIES
7073 VERSION ${MAPCACHE_VERSION_STRING}
7174 SOVERSION 1
7275)
7376
77+ # Add compiler flags for warnings
78+ if (CMAKE_COMPILER_IS_GNUCC)
79+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror=declaration-after-statement" )
80+ endif ()
81+
82+ if (CMAKE_C_COMPILER_ID MATCHES "Clang" )
83+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror=declaration-after-statement -std=c89 -Wno-comment" )
84+ endif ()
85+
7486#options suported by the cmake builder
7587option (WITH_PIXMAN "Use pixman for SSE optimized image manipulations" ON )
76- option (WITH_SQLITE "Use sqlite as a cache backend" ON )
88+ option (WITH_SQLITE "Use sqlite as a cache/dimension backend" ON )
89+ option (WITH_POSTGRESQL "Use PostgreSQL as a dimension backend" OFF )
7790option (WITH_BERKELEY_DB "Use Berkeley DB as a cache backend" OFF )
7891option (WITH_MEMCACHE "Use memcache as a cache backend (requires recent apr-util)" OFF )
7992option (WITH_REDIS "Use redis as a cache backend (requires hiredis library)" OFF )
@@ -82,11 +95,14 @@ option(WITH_TIFF_WRITE_SUPPORT "Enable (experimental) support for writable TIFF
8295option (WITH_GEOTIFF "Allow GeoTIFF metadata creation for TIFF cache backends" OFF )
8396option (WITH_PCRE "Use PCRE for regex tests" OFF )
8497option (WITH_MAPSERVER "Enable (experimental) support for the mapserver library" OFF )
98+ option (WITH_RIAK "Use Riak as a cache backend" OFF )
99+ option (WITH_GDAL "Choose if GDAL raster support should be built in" ON )
100+ option (WITH_MAPCACHE_DETAIL "Build coverage analysis tool for SQLite caches" ON )
85101
86102find_package (PNG)
87103if (PNG_FOUND)
88104 include_directories (${PNG_INCLUDE_DIR} )
89- target_link_libraries (mapcache ${PNG_LIBRARY } )
105+ target_link_libraries (mapcache ${PNG_LIBRARIES } )
90106else (PNG_FOUND)
91107 report_mandatory_not_found(PNG)
92108endif (PNG_FOUND)
@@ -162,12 +178,24 @@ if(WITH_PIXMAN)
162178 endif (PIXMAN_FOUND)
163179endif (WITH_PIXMAN)
164180
181+ if (WITH_GDAL)
182+ find_package (GDAL)
183+ if (GDAL_FOUND)
184+ include_directories (${GDAL_INCLUDE_DIR} )
185+ target_link_libraries (mapcache ${GDAL_LIBRARY} )
186+ set (USE_GDAL 1)
187+ else (GDAL_FOUND)
188+ report_optional_not_found(GDAL)
189+ endif (GDAL_FOUND)
190+ endif (WITH_GDAL)
191+
165192if (WITH_PCRE)
166193 find_package (PCRE)
167194 if (PCRE_FOUND)
168195 include_directories (${PCRE_INCLUDE_DIR} )
169196 target_link_libraries (mapcache ${PCRE_LIBRARY} )
170197 set (USE_PCRE 1)
198+ add_definitions (-DPCRE_STATIC)
171199 else (PCRE_FOUND)
172200 report_optional_not_found(PCRE)
173201 endif (PCRE_FOUND)
@@ -184,6 +212,17 @@ if(WITH_SQLITE)
184212 endif (SQLITE_FOUND)
185213endif (WITH_SQLITE)
186214
215+ if (WITH_POSTGRESQL)
216+ find_package (PostgreSQL)
217+ if (PostgreSQL_FOUND)
218+ include_directories (${PostgreSQL_INCLUDE_DIR} )
219+ target_link_libraries (mapcache ${PostgreSQL_LIBRARY} )
220+ set (USE_POSTGRESQL 1)
221+ else (POSTGRESQL_FOUND)
222+ report_optional_not_found(POSTGRESQL)
223+ endif (PostgreSQL_FOUND)
224+ endif (WITH_POSTGRESQL)
225+
187226if (WITH_BERKELEY_DB)
188227 if (NOT BERKELEYDB_FIND_VERSION)
189228 set (BERKELEYDB_FIND_VERSION "4.6" )
@@ -240,6 +279,16 @@ if(WITH_MAPSERVER)
240279 endif (MAPSERVER_FOUND)
241280endif (WITH_MAPSERVER)
242281
282+ if (WITH_RIAK)
283+ find_package (RIAK)
284+ if (RIAK_FOUND)
285+ include_directories (${RIAK_INCLUDE_DIR} )
286+ target_link_libraries (mapcache ${RIAK_LIBRARY} )
287+ set (USE_RIAK 1)
288+ else (RIAK_FOUND)
289+ report_optional_not_found(RIAK)
290+ endif (RIAK_FOUND)
291+ endif (WITH_RIAK)
243292
244293if (UNIX )
245294target_link_libraries (mapcache ${CMAKE_DL_LIBS} m )
@@ -265,7 +314,7 @@ macro(status_optional_component component enabled libpath)
265314 endif ()
266315endmacro ()
267316macro (status_optional_feature feature enabled)
268- if ("${enabled} " EQUAL "1" )
317+ if ("${enabled} " EQUAL "1" OR " ${enabled} " STREQUAL "ON" )
269318 message (STATUS " * ${feature} : ENABLED" )
270319 else ()
271320 message (STATUS " * ${feature} : disabled" )
@@ -281,6 +330,7 @@ message(STATUS " * Apr: ${APR_LIBRARY}")
281330message (STATUS " * Optional components" )
282331status_optional_component("PIXMAN" "${USE_PIXMAN} " "${PIXMAN_LIBRARY} " )
283332status_optional_component("SQLITE" "${USE_SQLITE} " "${SQLITE_LIBRARY} " )
333+ status_optional_component("POSTGRESQL" "${USE_POSTGRESQL} " "${PostgreSQL_LIBRARY} " )
284334status_optional_component("Berkeley DB" "${USE_BDB} " "${BERKELEYDB_LIBRARY} " )
285335status_optional_component("Memcache" "${USE_MEMCACHE} " "${APU_LIBRARY} " )
286336status_optional_component("Redis" "${USE_REDIS} " "${HIREDIS_LIBRARIES} ${HIREDIS_INCLUDE_DIR} " )
@@ -289,10 +339,18 @@ status_optional_component("GeoTIFF" "${USE_GEOTIFF}" "${GEOTIFF_LIBRARY}")
289339status_optional_component("Experimental TIFF write support" "${USE_TIFF_WRITE} " "${TIFF_LIBRARY} " )
290340status_optional_component("PCRE" "${USE_PCRE} " "${PCRE_LIBRARY} " )
291341status_optional_component("Experimental mapserver support" "${USE_MAPSERVER} " "${MAPSERVER_LIBRARY} " )
342+ status_optional_component("RIAK" "${USE_RIAK} " "${RIAK_LIBRARY} " )
343+ status_optional_component("GDAL" "${USE_GDAL} " "${GDAL_LIBRARY} " )
344+ message (STATUS " * Optional features" )
345+ status_optional_feature("MAPCACHE_DETAIL" "${WITH_MAPCACHE_DETAIL} " )
292346
293347INSTALL (TARGETS mapcache DESTINATION ${CMAKE_INSTALL_LIBDIR} )
294348
295349add_subdirectory (util)
296350add_subdirectory (cgi)
297351add_subdirectory (apache)
298352add_subdirectory (nginx)
353+
354+ if (WITH_MAPCACHE_DETAIL)
355+ add_subdirectory (contrib/mapcache_detail)
356+ endif (WITH_MAPCACHE_DETAIL)
0 commit comments