2021-03-17 23:06:49 +01:00
cmake_minimum_required(VERSION 3.15)
# 3.15 is required since the Boost::XXXX targets was first added. https://cmake.org/cmake/help/latest/module/FindBoost.html#imported-targets
# 3.14 is required since SQLite3 Module was first added. https://cmake.org/cmake/help/latest/module/FindSQLite3.html#findsqlite3
2021-02-03 19:43:28 +01:00
include(cmake/GetVersion.cmake)
get_mapnik_version()
2020-11-20 18:20:43 +01:00
project(mapnik
2021-02-03 19:43:28 +01:00
VERSION ${MAPNIK_MAJOR_VERSION}.${MAPNIK_MINOR_VERSION}.${MAPNIK_PATCH_VERSION}
2020-11-20 18:20:43 +01:00
HOMEPAGE_URL "https://mapnik.org/"
DESCRIPTION "Mapnik is an open source toolkit for developing mapping applications"
LANGUAGES CXX
2020-11-20 20:20:28 +01:00
)
2021-02-03 19:43:28 +01:00
message(STATUS "mapnik version: ${PROJECT_VERSION}")
2021-06-30 10:33:20 +02:00
# https://cliutils.gitlab.io/modern-cmake/chapters/features/ides.html
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
2020-11-20 21:15:27 +01:00
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
2021-09-22 15:25:55 +02:00
include(MapnikMinimumVersions)
2021-03-17 22:18:21 +01:00
include(MapnikFindPackage)
2021-04-09 15:50:50 +02:00
include(MapnikCopyDependencies)
2021-04-10 14:36:22 +02:00
include(MapnikInstall)
2020-11-20 21:15:27 +01:00
2021-04-09 15:53:21 +02:00
set(ADDITIONAL_LIBARIES_PATHS "" CACHE STRING "only used on windows. Pass directories containing the dlls that are missing. You can ignore this, if the build (verify_app step) runs successfully")
2021-08-25 16:41:57 +02:00
option(COPY_LIBRARIES_FOR_EXECUTABLES "copies required shared libaries (only windows) to the executable build directory" OFF)
2021-04-09 15:53:21 +02:00
option(COPY_FONTS_AND_PLUGINS_FOR_EXECUTABLES "copies required plugins and fonts into the executable build directory" ON)
2021-04-10 14:36:22 +02:00
option(INSTALL_DEPENDENCIES "if ON, all dependencies (eg. required dlls) will be copied into CMAKE_INSTALL_PREFIX/MAPNIK_BIN_DIR." ON)
2021-01-27 00:41:54 +01:00
2020-11-25 12:16:06 +01:00
option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON)
2020-11-21 13:20:04 +01:00
option(BUILD_TEST "builds the tests" ON)
2020-11-21 10:09:29 +01:00
option(USE_EXTERNAL_MAPBOX_GEOMETRY "Use a external mapnik/geometry.hpp. If off, use the submodule" OFF)
option(USE_EXTERNAL_MAPBOX_POLYLABEL "Use a external mapnik/polylabel. If off, use the submodule" OFF)
option(USE_EXTERNAL_MAPBOX_PROTOZERO "Use a external mapnik/protozero. If off, use the submodule" OFF)
option(USE_EXTERNAL_MAPBOX_VARIANT "Use a external mapnik/variant. If off, use the submodule" OFF)
2020-11-21 17:03:30 +01:00
option(USE_JPEG "adds jpeg support" ON)
option(USE_PNG "adds png support" ON)
option(USE_TIFF "adds tiff support" ON)
option(USE_WEBP "adds webp support" ON)
option(USE_LIBXML2 "adds libxml2 support" ON)
option(USE_CAIRO "adds the cairo renderer" ON)
2021-02-03 19:29:43 +01:00
option(USE_PROJ "adds proj support" ON)
2020-11-21 17:03:30 +01:00
option(USE_GRID_RENDERER "adds grid renderer" ON)
2021-04-01 18:01:43 +02:00
option(USE_SVG_RENDERER "adds svg renderer" ON)
2021-04-01 16:15:32 +02:00
option(USE_BIGINT "uses 64 bit instead of 32" ON)
option(USE_MEMORY_MAPPED_FILE "uses file cache" ON)
2021-07-22 21:45:25 +02:00
option(USE_MULTITHREADED "enables the multithreaded features (threadsafe)" ON)
2021-07-23 13:34:49 +02:00
option(USE_NO_ATEXIT "disable atexit" OFF)
option(USE_NO_DLCLOSE "disable dlclose" OFF)
option(USE_DEBUG_OUTPUT "enables some debug messages for development" OFF)
option(USE_LOG "enables logging output. See log severity level." OFF)
# 0 = debug
# 1 = warn
# 2 = error
# 3 = none
set(USE_LOG_SEVERITY "1" CACHE STRING "sets the logging severity (only applies when USE_LOG is ON")
2021-07-23 16:10:35 +02:00
option(USE_STATS "Enable statistics reporting" OFF)
2020-11-20 20:20:28 +01:00
2020-11-21 11:34:45 +01:00
option(USE_PLUGIN_INPUT_CSV "adds plugin input csv" ON)
option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON)
option(USE_PLUGIN_INPUT_GEOBUF "adds plugin input geobuf" ON)
option(USE_PLUGIN_INPUT_GEOJSON "adds plugin input geojson" ON)
option(USE_PLUGIN_INPUT_OGR "adds plugin input ogr" ON)
option(USE_PLUGIN_INPUT_PGRASTER "adds plugin input pgraster" ON)
option(USE_PLUGIN_INPUT_POSTGIS "adds plugin input postgis" ON)
option(USE_PLUGIN_INPUT_RASTER "adds plugin input raster" ON)
option(USE_PLUGIN_INPUT_SHAPE "adds plugin input shape" ON)
option(USE_PLUGIN_INPUT_SQLITE "adds plugin input sqlite" ON)
option(USE_PLUGIN_INPUT_TOPOJSON "adds plugin input topojson" ON)
2020-11-21 12:24:34 +01:00
option(BUILD_DEMO_VIEWER "builds the demo viewer" ON)
option(BUILD_DEMO_CPP "builds the demo c++ application" ON)
2021-03-25 17:26:29 +01:00
option(BUILD_BENCHMARK "builds benchmark project" ON)
2020-11-21 12:30:34 +01:00
option(BUILD_UTILITY_GEOMETRY_TO_WKB "builds the utility program geometry_to_wkb" ON)
option(BUILD_UTILITY_MAPNIK_INDEX "builds the utility program mapnik_index" ON)
option(BUILD_UTILITY_MAPNIK_RENDER "builds the utility program mapnik_render" ON)
option(BUILD_UTILITY_OGRINDEX "builds the utility program ogrindex" OFF)
option(BUILD_UTILITY_PGSQL2SQLITE "builds the utility program pgsql2sqlite" ON)
option(BUILD_UTILITY_SHAPEINDEX "builds the utility program shapeindex" ON)
option(BUILD_UTILITY_SVG2PNG "builds the utility program svg2png" ON)
2020-11-21 12:24:34 +01:00
2021-03-25 18:46:18 +01:00
option(USE_BOOST_REGEX_ICU_WORKAROUND "if you don't use your system libraries and get double linked icu libraries set this to ON" OFF)
2021-07-23 13:34:49 +02:00
option(USE_GLIBC_WORKAROUND "see https://github.com/mapnik/mapnik/pull/3792 if you building with libstdc++-4.9" OFF)
2021-03-25 18:46:18 +01:00
2021-03-24 15:16:12 +01:00
set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++14 is minimum.")
2020-11-25 15:42:33 +01:00
message(STATUS "Using c++${CMAKE_CXX_STANDARD}")
2021-04-01 16:15:32 +02:00
# https://cmake.org/cmake/help/latest/prop_tgt/CXX_EXTENSIONS.html
set(CXX_EXTENSIONS OFF CACHE STRING "Enables the compiler specific extensions.") # Fallsback to -std=c++<ver> if off
message(STATUS "Using c++ extensions: ${CXX_EXTENSIONS}")
# https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD_REQUIRED.html#prop_tgt:CXX_STANDARD_REQUIRED
set(CXX_STANDARD_REQUIRED ON) # require the specified CMAKE_CXX_STANDARD
2020-11-20 20:20:28 +01:00
2021-07-22 20:34:08 +02:00
# add debug postfix to the libraries
set(MAPNIK_DEBUG_POSTFIX "d" CACHE STRING "sets the debug library postfix on mapnik, wkt and json")
2021-07-22 21:45:25 +02:00
message(STATUS "postfix for debug libraries: ${MAPNIK_DEBUG_POSTFIX}")
2021-07-22 20:34:08 +02:00
2021-09-22 14:41:50 +02:00
include(GNUInstallDirs)
# See for more details: https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html
set(MAPNIK_BIN_DIR ${CMAKE_INSTALL_BINDIR} CACHE STRING "Install directory for binaries")
set(MAPNIK_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Install directory for libraries")
set(MAPNIK_ARCHIVE_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Install directory for archives")
2021-09-22 15:44:34 +02:00
set(MAPNIK_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING "Install directory for the headers")
2021-09-22 14:41:50 +02:00
set(MAPNIK_CMAKE_DIR ${MAPNIK_LIB_DIR}/cmake/mapnik CACHE STRING "Install directory of the cmake targets")
2020-11-25 13:20:07 +01:00
if(WIN32)
set(DEFAULT_PLUGINS_INSTALL_DIR ${MAPNIK_BIN_DIR}/mapnik/input)
else()
set(DEFAULT_PLUGINS_INSTALL_DIR ${MAPNIK_LIB_DIR}/mapnik/input)
endif()
set(PLUGINS_INSTALL_DIR ${DEFAULT_PLUGINS_INSTALL_DIR} CACHE STRING "installs the plugins in the specified directory")
2020-11-25 15:42:33 +01:00
message(STATUS "Installing plugins to ${PLUGINS_INSTALL_DIR}")
2020-11-25 13:20:07 +01:00
set(FONTS_INSTALL_DIR ${MAPNIK_BIN_DIR}/fonts CACHE STRING "installs the fonts in the specified directory")
2020-11-25 15:42:33 +01:00
message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}")
2021-03-17 22:18:21 +01:00
2021-07-06 22:46:07 +02:00
set(MAPNIK_COMPILE_DEFS "")
set(MAPNIK_OPTIONAL_LIBS "")
set(MAPNIK_OPTIONAL_LIBS_INCLUDE "")
2021-03-25 21:28:41 +01:00
# Begin project configuration
2021-07-22 21:45:25 +02:00
# needs to be before the first call of find_boost.
if(USE_MULTITHREADED)
message(STATUS "multithreaded enabled")
set(Boost_USE_MULTITHREADED ON)
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_THREADSAFE)
else()
set(Boost_USE_MULTITHREADED OFF)
message(STATUS "multithreaded disabled")
endif()
find_package(PkgConfig)
2021-03-26 15:45:15 +01:00
mapnik_find_threads()
2021-03-17 22:18:21 +01:00
mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data)
2021-09-22 15:25:55 +02:00
mapnik_find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS filesystem system regex)
2021-03-25 18:46:18 +01:00
if(USE_BOOST_REGEX_ICU_WORKAROUND)
2021-07-23 13:34:49 +02:00
message(STATUS "using boost regex workaround")
2021-03-25 18:46:18 +01:00
set_property(TARGET Boost::regex PROPERTY INTERFACE_LINK_LIBRARIES)
endif()
2021-03-25 21:28:41 +01:00
2021-03-17 22:18:21 +01:00
mapnik_find_package(Freetype REQUIRED)
2021-07-06 22:46:07 +02:00
# try to find harfbuzz with the native configuration and fallback to our "own" FindHarfBuzz
2021-09-22 15:25:55 +02:00
mapnik_find_package(harfbuzz ${HARFBUZZ_MIN_VERSION} CONFIG QUIET)
2021-07-06 22:46:07 +02:00
if(harfbuzz_FOUND)
message(STATUS "Found harfbuzz native cmake")
list(APPEND MAPNIK_OPTIONAL_LIBS harfbuzz::harfbuzz)
else()
# we use our "own" FindHarfBuzz. See https://github.com/mapnik/mapnik/pull/4191#issuecomment-874728157 for more details
message(STATUS "Fallback to FindHarfBuzz")
2021-09-22 15:25:55 +02:00
mapnik_find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION} REQUIRED COMPONENTS ICU)
2021-07-06 22:46:07 +02:00
list(APPEND MAPNIK_OPTIONAL_LIBS HarfBuzz::HarfBuzz HarfBuzz::ICU)
endif()
2020-11-20 20:20:28 +01:00
if(USE_EXTERNAL_MAPBOX_GEOMETRY)
2020-11-22 22:01:33 +01:00
# this is used to provide a way to specify include dirs with CACHE VARIABLES
2020-11-21 11:34:45 +01:00
if(NOT MAPBOX_GEOMETRY_INCLUDE_DIRS)
message(STATUS "Searching for the include dir of mapbox/geometry.hpp")
find_path(MAPBOX_GEOMETRY_INCLUDE_DIRS "mapbox/geometry.hpp" REQUIRED)
endif()
2020-11-20 20:20:28 +01:00
else()
2020-11-21 11:34:45 +01:00
set(MAPBOX_GEOMETRY_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/geometry/include>
2021-07-21 20:20:44 +02:00
$<INSTALL_INTERFACE:include>
2020-11-21 11:34:45 +01:00
)
2020-11-20 20:20:28 +01:00
endif()
if(NOT MAPBOX_GEOMETRY_INCLUDE_DIRS)
2020-11-21 11:34:45 +01:00
message(FATAL_ERROR "Set -DMAPBOX_GEOMETRY_INCLUDE_DIRS to the mapbox/geometry.hpp include dir")
2020-11-20 20:20:28 +01:00
endif()
if(USE_EXTERNAL_MAPBOX_POLYLABEL)
2020-11-21 11:34:45 +01:00
if(NOT MAPBOX_POLYLABEL_INCLUDE_DIRS)
message(STATUS "Searching for the include dir of mapbox/polylabel")
find_path(MAPBOX_POLYLABEL_INCLUDE_DIRS "mapbox/polylabel.hpp")
endif()
2020-11-20 20:20:28 +01:00
else()
2020-11-21 11:34:45 +01:00
set(MAPBOX_POLYLABEL_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/polylabel/include>
2021-07-21 20:20:44 +02:00
$<INSTALL_INTERFACE:include>
2020-11-21 11:34:45 +01:00
)
2020-11-20 20:20:28 +01:00
endif()
if(NOT MAPBOX_POLYLABEL_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_POLYLABEL_INCLUDE_DIRS to the mapbox/geometry include dir")
endif()
if(USE_EXTERNAL_MAPBOX_PROTOZERO)
2020-11-21 11:34:45 +01:00
if(NOT MAPBOX_PROTOZERO_INCLUDE_DIRS)
message(STATUS "Searching for the include dir of mapbox/protozero")
find_path(MAPBOX_PROTOZERO_INCLUDE_DIRS "protozero/pbf_message.hpp")
endif()
2020-11-20 20:20:28 +01:00
else()
2020-11-21 11:34:45 +01:00
set(MAPBOX_PROTOZERO_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/protozero/include>
2021-07-21 20:20:44 +02:00
$<INSTALL_INTERFACE:include>
2020-11-21 11:34:45 +01:00
)
2020-11-20 20:20:28 +01:00
endif()
if(NOT MAPBOX_PROTOZERO_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_PROTOZERO_INCLUDE_DIRS to the mapbox/protozero include dir")
endif()
if(USE_EXTERNAL_MAPBOX_VARIANT)
2020-11-21 11:34:45 +01:00
if(NOT MAPBOX_VARIANT_INCLUDE_DIRS)
message(STATUS "Searching for the include dir of mapbox/variant")
find_path(MAPBOX_VARIANT_INCLUDE_DIRS "mapbox/variant.hpp")
endif()
2020-11-20 20:20:28 +01:00
else()
2020-11-21 11:34:45 +01:00
set(MAPBOX_VARIANT_INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/variant/include>
2021-07-21 20:20:44 +02:00
$<INSTALL_INTERFACE:include>
2020-11-21 11:34:45 +01:00
)
2020-11-20 20:20:28 +01:00
endif()
if(NOT MAPBOX_VARIANT_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_VARIANT_INCLUDE_DIRS to the mapbox/variant include dir")
endif()
2021-04-10 14:36:22 +02:00
# (used by MapnikInstall.cmake. properties are needed since "set(...)" will be out of scope
set_property(GLOBAL PROPERTY TARGETS "")
set_property(GLOBAL PROPERTY PLUGINS "")
2020-11-20 21:15:27 +01:00
2021-07-23 13:34:49 +02:00
if(USE_GLIBC_WORKAROUND)
message("using glibc workaround")
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_ENABLE_GLIBC_WORKAROUND)
endif()
2021-04-01 16:15:32 +02:00
if(USE_BIGINT)
message(STATUS "uses BIGINT")
list(APPEND MAPNIK_COMPILE_DEFS BIGINT)
endif()
2021-07-22 20:45:16 +02:00
2021-04-01 16:15:32 +02:00
if(USE_MEMORY_MAPPED_FILE)
message(STATUS "uses MAPNIK_MEMORY_MAPPED_FILE")
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_MEMORY_MAPPED_FILE)
endif()
2021-07-23 13:34:49 +02:00
if(USE_NO_ATEXIT)
message(STATUS "uses MAPNIK_NO_ATEXIT")
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_NO_ATEXIT)
endif()
if(USE_NO_DLCLOSE)
message(STATUS "uses MAPNIK_NO_DLCLOSE")
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_NO_DLCLOSE)
endif()
if(USE_DEBUG_OUTPUT)
message(STATUS "enabled debug outputs")
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_DEBUG)
endif()
if(USE_LOG)
message(STATUS "logging enabled with level ${USE_LOG_SEVERITY}")
2021-07-23 16:10:35 +02:00
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_LOG MAPNIK_DEFAULT_LOG_SEVERITY=${USE_LOG_SEVERITY})
endif()
if(USE_STATS)
message(STATUS "adding statistics")
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATS)
2021-07-23 13:34:49 +02:00
endif()
2020-11-21 10:09:29 +01:00
if(USE_LIBXML2)
2021-03-17 22:18:21 +01:00
mapnik_find_package(LibXml2 REQUIRED)
2020-11-21 11:34:45 +01:00
list(APPEND MAPNIK_COMPILE_DEFS HAVE_LIBXML2)
list(APPEND MAPNIK_OPTIONAL_LIBS LibXml2::LibXml2)
2020-11-20 21:15:27 +01:00
endif()
2021-07-22 20:45:16 +02:00
2020-11-21 10:09:29 +01:00
if(USE_PNG)
2021-03-17 22:18:21 +01:00
mapnik_find_package(PNG REQUIRED)
2020-11-21 11:34:45 +01:00
list(APPEND MAPNIK_COMPILE_DEFS HAVE_PNG)
list(APPEND MAPNIK_OPTIONAL_LIBS PNG::PNG)
2020-11-20 21:15:27 +01:00
endif()
2021-07-21 18:16:48 +02:00
if(USE_JPEG)
mapnik_find_package(JPEG REQUIRED)
list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG)
list(APPEND MAPNIK_OPTIONAL_LIBS JPEG::JPEG)
endif()
2020-11-20 21:15:27 +01:00
2020-11-21 10:09:29 +01:00
if(USE_TIFF)
2021-03-17 22:18:21 +01:00
mapnik_find_package(TIFF REQUIRED)
2020-11-21 11:34:45 +01:00
list(APPEND MAPNIK_COMPILE_DEFS HAVE_TIFF)
list(APPEND MAPNIK_OPTIONAL_LIBS TIFF::TIFF)
2020-11-20 21:15:27 +01:00
endif()
2020-11-21 10:09:29 +01:00
if(USE_WEBP)
2021-07-21 18:16:48 +02:00
mapnik_find_package(WebP REQUIRED)
2020-11-21 11:34:45 +01:00
list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP)
2021-07-23 15:48:17 +02:00
list(APPEND MAPNIK_OPTIONAL_LIBS WebP::WebP)
2020-11-20 21:15:27 +01:00
endif()
2020-11-21 10:09:29 +01:00
if(USE_CAIRO)
2021-03-17 22:18:21 +01:00
mapnik_find_package(Cairo REQUIRED)
2020-11-21 11:34:45 +01:00
list(APPEND MAPNIK_COMPILE_DEFS HAVE_CAIRO)
list(APPEND MAPNIK_OPTIONAL_LIBS Cairo::Cairo)
2020-11-20 21:15:27 +01:00
endif()
2021-02-03 19:29:43 +01:00
if(USE_PROJ)
2021-01-24 19:34:51 +01:00
#https://proj.org/development/cmake.html
2021-09-22 15:25:55 +02:00
mapnik_find_package(PROJ ${PROJ_MIN_VERSION} QUIET)
2021-07-21 18:16:48 +02:00
# currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config
2021-07-23 18:41:07 +02:00
if(NOT PROJ_FOUND)
2021-07-21 18:16:48 +02:00
message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...")
2021-09-22 15:25:55 +02:00
pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj>=${PROJ_MIN_VERSION})
2021-07-21 18:16:48 +02:00
string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _dummy "${PROJ_VERSION}")
set(PROJ_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}")
set(PROJ_VERSION_PATCH "${CMAKE_MATCH_3}")
endif()
2021-07-23 18:41:07 +02:00
math(EXPR MAPNIK_PROJ_VERSION "${PROJ_VERSION_MAJOR}*10000 + ${PROJ_VERSION_MINOR}*100 + ${PROJ_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL)
2021-03-26 15:45:15 +01:00
message(STATUS "Using mapnik PROJ version: ${MAPNIK_PROJ_VERSION}")
2021-03-25 18:46:18 +01:00
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ MAPNIK_PROJ_VERSION=${MAPNIK_PROJ_VERSION})
2021-07-23 18:41:07 +02:00
list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES})
2021-09-22 15:25:55 +02:00
list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE $<BUILD_INTERFACE:${PROJ_INCLUDE_DIRS}>)
2020-11-21 12:38:29 +01:00
endif()
2020-11-21 17:03:30 +01:00
if(USE_GRID_RENDERER)
message(STATUS "Using grid renderer")
list(APPEND MAPNIK_COMPILE_DEFS GRID_RENDERER)
endif()
if(USE_SVG_RENDERER)
message(STATUS "Using svg renderer")
list(APPEND MAPNIK_COMPILE_DEFS SVG_RENDERER)
endif()
2021-02-03 22:47:15 +01:00
if(NOT WIN32)
2021-02-03 22:48:25 +01:00
message(STATUS "Compiling with -DMAPNIK_HAS_DLCFN")
2021-02-03 22:47:15 +01:00
list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_HAS_DLCFN)
list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS})
endif()
2021-03-19 22:51:50 +01:00
add_library(core INTERFACE)
add_library(mapnik::core ALIAS core)
2020-11-20 20:20:28 +01:00
2021-03-19 22:51:50 +01:00
target_include_directories(core INTERFACE
2020-11-20 20:20:28 +01:00
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
2020-11-22 22:01:33 +01:00
$<BUILD_INTERFACE:${MAPBOX_GEOMETRY_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${MAPBOX_POLYLABEL_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${MAPBOX_VARIANT_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${MAPBOX_PROTOZERO_INCLUDE_DIRS}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/deps>
2020-11-20 20:20:28 +01:00
$<INSTALL_INTERFACE:include>
2021-01-24 19:34:51 +01:00
${MAPNIK_OPTIONAL_LIBS_INCLUDE}
2020-11-20 20:20:28 +01:00
)
2021-03-19 22:51:50 +01:00
target_link_libraries(core INTERFACE
2021-03-26 15:45:15 +01:00
Threads::Threads
2020-11-20 20:20:28 +01:00
ICU::uc
2021-02-03 19:29:43 +01:00
ICU::data
ICU::i18n
2021-03-24 14:57:27 +01:00
Boost::headers
Boost::regex
Boost::filesystem
2020-11-20 21:15:27 +01:00
Freetype::Freetype
${MAPNIK_OPTIONAL_LIBS}
2020-11-20 20:20:28 +01:00
)
2021-03-19 22:51:50 +01:00
target_compile_definitions(core INTERFACE ${MAPNIK_COMPILE_DEFS})
2020-11-20 20:20:28 +01:00
2021-09-22 19:52:39 +02:00
mapnik_install(core)
2020-11-20 21:15:27 +01:00
2020-11-20 20:20:28 +01:00
add_subdirectory(deps)
add_subdirectory(src)
2020-11-21 11:34:45 +01:00
add_subdirectory(plugins)
2020-11-21 12:24:34 +01:00
add_subdirectory(utils)
add_subdirectory(demo)
2021-03-25 17:26:29 +01:00
if(BUILD_BENCHMARK)
add_subdirectory(benchmark)
endif()
2020-11-21 13:20:04 +01:00
if(BUILD_TEST)
enable_testing()
add_subdirectory(test)
endif()
2020-11-21 11:34:45 +01:00
2020-11-22 22:01:33 +01:00
# start package mapnik
2020-11-21 11:34:45 +01:00
include(CMakePackageConfigHelpers)
2020-11-22 22:01:33 +01:00
# set the cmake targets install location
set(INCLUDE_INSTALL_DIR include/)
2020-11-21 11:34:45 +01:00
write_basic_package_version_file(
2021-07-21 20:03:42 +02:00
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake"
2020-11-21 11:34:45 +01:00
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
2021-03-17 22:18:21 +01:00
list(JOIN MAPNIK_DEPENDENCIES "\n" MAPNIK_DEPENDENCIES)
2021-07-21 20:03:42 +02:00
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mapnikConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake"
2021-09-22 14:41:50 +02:00
INSTALL_DESTINATION ${MAPNIK_CMAKE_DIR}
2021-03-17 22:18:21 +01:00
PATH_VARS INCLUDE_INSTALL_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR MAPNIK_DEPENDENCIES
2020-11-21 11:34:45 +01:00
)
2021-07-21 20:03:42 +02:00
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake"
2021-09-22 14:41:50 +02:00
DESTINATION ${MAPNIK_CMAKE_DIR}
2021-07-21 20:03:42 +02:00
)
install(
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindCairo.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindWebP.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindHarfBuzz.cmake"
2021-09-22 14:41:50 +02:00
DESTINATION ${MAPNIK_CMAKE_DIR}/Modules
2020-11-21 11:34:45 +01:00
)
2021-03-17 22:18:21 +01:00
2020-11-21 11:34:45 +01:00
install(EXPORT MapnikTargets
2021-09-22 14:41:50 +02:00
DESTINATION ${MAPNIK_CMAKE_DIR}
FILE mapnikTargets.cmake
NAMESPACE mapnik::
2020-11-21 11:34:45 +01:00
)
2020-11-21 11:40:55 +01:00
2021-09-22 14:41:50 +02:00
install(DIRECTORY include/ DESTINATION ${MAPNIK_INCLUDE_DIR})
install(DIRECTORY deps/agg/include/ DESTINATION ${MAPNIK_INCLUDE_DIR})
install(DIRECTORY deps/mapnik DESTINATION ${MAPNIK_INCLUDE_DIR})
2020-11-22 22:01:33 +01:00
install(DIRECTORY fonts/ DESTINATION ${FONTS_INSTALL_DIR} FILES_MATCHING PATTERN "*.py" EXCLUDE PATTERN "*")
2021-04-10 14:36:22 +02:00
2021-07-21 20:20:44 +02:00
if(NOT USE_EXTERNAL_MAPBOX_GEOMETRY)
2021-09-22 14:41:50 +02:00
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/geometry/include/ DESTINATION ${MAPNIK_INCLUDE_DIR})
2021-07-21 20:20:44 +02:00
endif()
if(NOT USE_EXTERNAL_MAPBOX_POLYLABEL)
2021-09-22 14:41:50 +02:00
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/polylabel/include/ DESTINATION ${MAPNIK_INCLUDE_DIR})
2021-07-21 20:20:44 +02:00
endif()
if(NOT USE_EXTERNAL_MAPBOX_PROTOZERO)
2021-09-22 14:41:50 +02:00
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/protozero/include/ DESTINATION ${MAPNIK_INCLUDE_DIR})
2021-07-21 20:20:44 +02:00
endif()
if(NOT USE_EXTERNAL_MAPBOX_VARIANT)
2021-09-22 14:41:50 +02:00
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/variant/include/ DESTINATION ${MAPNIK_INCLUDE_DIR})
2021-07-21 20:20:44 +02:00
endif()
2021-07-02 22:26:36 +02:00
2021-07-21 20:20:44 +02:00
mapnik_install_targets()
2021-07-02 22:26:36 +02:00
include(pack)