more cmake

This commit is contained in:
Mathis Logemann 2020-11-20 21:15:27 +01:00
parent e6f6d0f133
commit d86a90a10a
12 changed files with 256 additions and 27 deletions

View file

@ -6,7 +6,9 @@ project(mapnik
LANGUAGES CXX
)
option(BUILD_SHARED_LIBS ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(BUILD_SHARED_LIBS ON)
option(USE_EXTERNAL_MAPBOX_GEOMETRY OFF)
option(USE_EXTERNAL_MAPBOX_POLYLABEL OFF)
option(USE_EXTERNAL_MAPBOX_PROTOZERO OFF)
@ -16,6 +18,13 @@ set(CXX_STANDARD 17)
find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex program_options)
find_package(ICU REQUIRED COMPONENTS uc)
find_package(Freetype REQUIRED)
find_package(PNG REQUIRED)
find_package(JPEG REQUIRED)
find_package(TIFF REQUIRED)
find_package(WebP CONFIG REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(Cairo)
if(USE_EXTERNAL_MAPBOX_GEOMETRY)
find_path(MAPBOX_GEOMETRY_INCLUDE_DIRS "mapbox/geometry.hpp")
@ -53,6 +62,41 @@ if(NOT MAPBOX_VARIANT_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_VARIANT_INCLUDE_DIRS to the mapbox/variant include dir")
endif()
set(MAPNIK_COMPILE_DEFS "")
set(MAPNIK_OPTIONAL_LIBS "")
if(LibXml2_FOUND)
set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_LIBXML2)
set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} LibXml2::LibXml2)
message(STATUS "Using LibXml2")
endif()
if(PNG_FOUND)
set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_PNG)
message(STATUS "Using PNG")
endif()
if(JPEG_FOUND)
set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_JPEG)
message(STATUS "Using JPEG")
endif()
if(TIFF_FOUND)
set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_TIFF)
message(STATUS "Using TIFF")
endif()
if(WebP_FOUND)
set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_WEBP)
message(STATUS "Using WEBP")
endif()
if(Cairo_FOUND)
set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_CAIRO)
set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} Cairo::Cairo)
message(STATUS "Using Cairo")
endif()
add_library(mapnik-headers INTERFACE)
add_library(mapnik::headers ALIAS mapnik-headers)
@ -67,7 +111,14 @@ target_include_directories(mapnik-headers INTERFACE
)
target_link_libraries(mapnik-headers INTERFACE
Boost::boost
Boost::regex
Boost::filesystem
ICU::uc
Freetype::Freetype
PNG::PNG
TIFF::TIFF
JPEG::JPEG
${MAPNIK_OPTIONAL_LIBS}
)
if(BUILD_SHARED_LIBS)
target_compile_definitions(mapnik-headers INTERFACE MAPNIK_EXPORTS)
@ -81,7 +132,9 @@ install(TARGETS mapnik-headers
INCLUDES DESTINATION include/
PUBLIC_HEADER DESTINATION include/
)
add_subdirectory(deps)
add_subdirectory(src)
add_subdirectory(utils)
#add_subdirectory(utils)
#add_subdirectory(plugins)

109
cmake/FindCairo.cmake Normal file
View file

@ -0,0 +1,109 @@
# Copyright (C) 2020 Sony Interactive Entertainment Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#[=======================================================================[.rst:
FindCairo
--------------
Find Cairo headers and libraries.
Imported Targets
^^^^^^^^^^^^^^^^
``Cairo::Cairo``
The Cairo library, if found.
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables in your project:
``Cairo_FOUND``
true if (the requested version of) Cairo is available.
``Cairo_VERSION``
the version of Cairo.
``Cairo_LIBRARIES``
the libraries to link against to use Cairo.
``Cairo_INCLUDE_DIRS``
where to find the Cairo headers.
``Cairo_COMPILE_OPTIONS``
this should be passed to target_compile_options(), if the
target is not used for linking
#]=======================================================================]
find_package(PkgConfig QUIET)
pkg_check_modules(PC_CAIRO QUIET cairo)
set(Cairo_COMPILE_OPTIONS ${PC_CAIRO_CFLAGS_OTHER})
set(Cairo_VERSION ${PC_CAIRO_VERSION})
find_path(Cairo_INCLUDE_DIR
NAMES cairo.h
HINTS ${PC_CAIRO_INCLUDEDIR} ${PC_CAIRO_INCLUDE_DIR}
PATH_SUFFIXES cairo
)
find_library(Cairo_LIBRARY
NAMES ${Cairo_NAMES} cairo
HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS}
)
if (Cairo_INCLUDE_DIR AND NOT Cairo_VERSION)
if (EXISTS "${Cairo_INCLUDE_DIR}/cairo-version.h")
file(READ "${Cairo_INCLUDE_DIR}/cairo-version.h" Cairo_VERSION_CONTENT)
string(REGEX MATCH "#define +CAIRO_VERSION_MAJOR +([0-9]+)" _dummy "${Cairo_VERSION_CONTENT}")
set(Cairo_VERSION_MAJOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define +CAIRO_VERSION_MINOR +([0-9]+)" _dummy "${Cairo_VERSION_CONTENT}")
set(Cairo_VERSION_MINOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define +CAIRO_VERSION_MICRO +([0-9]+)" _dummy "${Cairo_VERSION_CONTENT}")
set(Cairo_VERSION_PATCH "${CMAKE_MATCH_1}")
set(Cairo_VERSION "${Cairo_VERSION_MAJOR}.${Cairo_VERSION_MINOR}.${Cairo_VERSION_PATCH}")
endif ()
endif ()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Cairo
FOUND_VAR Cairo_FOUND
REQUIRED_VARS Cairo_LIBRARY Cairo_INCLUDE_DIR
VERSION_VAR Cairo_VERSION
)
if (Cairo_LIBRARY AND NOT TARGET Cairo::Cairo)
add_library(Cairo::Cairo UNKNOWN IMPORTED GLOBAL)
set_target_properties(Cairo::Cairo PROPERTIES
IMPORTED_LOCATION "${Cairo_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${Cairo_COMPILE_OPTIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${Cairo_INCLUDE_DIR}"
)
endif ()
mark_as_advanced(Cairo_INCLUDE_DIR Cairo_LIBRARIES)
if (Cairo_FOUND)
set(Cairo_LIBRARIES ${Cairo_LIBRARY})
set(Cairo_INCLUDE_DIRS ${Cairo_INCLUDE_DIR})
endif ()

View file

@ -49,7 +49,6 @@ set(MAPNIK_SOURCES
image.cpp
jpeg_reader.cpp
layer.cpp
libxml2_loader.cpp
load_map.cpp
map.cpp
mapped_memory_cache.cpp
@ -66,7 +65,6 @@ set(MAPNIK_SOURCES
png_reader.cpp
proj_transform.cpp
projection.cpp
rapidxml_loader.cpp
raster_colorizer.cpp
renderer_common.cpp
request.cpp
@ -137,23 +135,24 @@ set(AGG_SRC
${AGG_COMPILE_SRC}
)
set(CAIRO_SRC
cairo/cairo_context.cpp
cairo/cairo_render_vector.cpp
cairo/cairo_renderer.cpp
cairo/process_building_symbolizer.cpp
cairo/process_debug_symbolizer.cpp
cairo/process_group_symbolizer.cpp
cairo/process_line_pattern_symbolizer.cpp
cairo/process_line_symbolizer.cpp
cairo/process_markers_symbolizer.cpp
cairo/process_point_symbolizer.cpp
cairo/process_polygon_pattern_symbolizer.cpp
cairo/process_polygon_symbolizer.cpp
cairo/process_raster_symbolizer.cpp
cairo/process_text_symbolizer.cpp
)
if(Cairo_FOUND)
set(CAIRO_SRC
cairo/cairo_context.cpp
cairo/cairo_render_vector.cpp
cairo/cairo_renderer.cpp
cairo/process_building_symbolizer.cpp
cairo/process_debug_symbolizer.cpp
cairo/process_group_symbolizer.cpp
cairo/process_line_pattern_symbolizer.cpp
cairo/process_line_symbolizer.cpp
cairo/process_markers_symbolizer.cpp
cairo/process_point_symbolizer.cpp
cairo/process_polygon_pattern_symbolizer.cpp
cairo/process_polygon_symbolizer.cpp
cairo/process_raster_symbolizer.cpp
cairo/process_text_symbolizer.cpp
)
endif()
set(CSS_SRC
css/css_color_grammar_x3.cpp
@ -250,6 +249,14 @@ set(UTIL_SRC
util/utf_conv_win.cpp
)
if(LibXml2_FOUND)
set(COMPILE_SRC ${COMPILE_SRC} libxml2_loader.cpp)
else()
set(COMPILE_SRC ${COMPILE_SRC} rapidxml_loader.cpp)
endif()
set(COMPILE_SRC
${MAPNIK_SOURCES}
${AGG_SRC}
@ -264,11 +271,11 @@ set(COMPILE_SRC
${UTIL_SRC}
)
add_library(mapnik
${COMPILE_SRC}
)
add_library(mapnik ${COMPILE_SRC})
add_library(mapnik::mapnik ALIAS mapnik)
target_compile_definitions(mapnik PRIVATE MAPNIK_EXPORTS)
target_compile_definitions(mapnik PRIVATE ${MAPNIK_EXPORTS} ${MAPNIK_COMPILE_DEFS})
target_link_libraries(mapnik PRIVATE
mapnik::headers
mapnik::agg
@ -281,4 +288,4 @@ install(TARGETS mapnik
RUNTIME DESTINATION bin
INCLUDES DESTINATION include/
PUBLIC_HEADER DESTINATION include/
)
)

View file

@ -31,4 +31,4 @@ install(TARGETS json
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)
)

View file

@ -24,4 +24,4 @@ install(TARGETS wkt
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
)
)

View file

@ -0,0 +1,8 @@
add_executable(geometry_to_wkb main.cpp)
target_link_libraries(geometry_to_wkb PRIVATE mapnik::mapnik)
install(TARGETS geometry_to_wkb
EXPORT MapnikTargets
RUNTIME DESTINATION bin
)

View file

@ -0,0 +1,10 @@
add_executable(mapnik-index
mapnik-index.cpp
process_csv_file.cpp
process_geojson_file_x3.cpp
)
target_link_libraries(mapnik-index PRIVATE mapnik::mapnik)
install(TARGETS mapnik-index
EXPORT MapnikTargets
RUNTIME DESTINATION bin
)

View file

@ -0,0 +1,7 @@
add_executable(mapnik-render mapnik-render.cpp)
target_link_libraries(mapnik-render PRIVATE mapnik::mapnik)
install(TARGETS mapnik-render
EXPORT MapnikTargets
RUNTIME DESTINATION bin
)

View file

@ -0,0 +1,7 @@
add_executable(ogrindex ogrindex.cpp)
target_link_libraries(ogrindex PRIVATE mapnik::mapnik)
install(TARGETS ogrindex
EXPORT MapnikTargets
RUNTIME DESTINATION bin
)

View file

@ -0,0 +1,10 @@
add_executable(pgsql2sqlite
main.cpp
sqlite.cpp
)
target_link_libraries(pgsql2sqlite PRIVATE mapnik::mapnik)
install(TARGETS pgsql2sqlite
EXPORT MapnikTargets
RUNTIME DESTINATION bin
)

View file

@ -0,0 +1,9 @@
add_executable(shapeindex
shapeindex.cpp
)
target_link_libraries(shapeindex PRIVATE mapnik::mapnik)
install(TARGETS shapeindex
EXPORT MapnikTargets
RUNTIME DESTINATION bin
)

View file

@ -0,0 +1,9 @@
add_executable(svg2png
svg2png.cpp
)
target_link_libraries(svg2png PRIVATE mapnik::mapnik)
install(TARGETS svg2png
EXPORT MapnikTargets
RUNTIME DESTINATION bin
)