mapnik/CMakeLists.txt

149 lines
4.8 KiB
Text
Raw Normal View History

2020-11-20 18:20:43 +01:00
cmake_minimum_required(VERSION 3.15.0)
project(mapnik
VERSION 3.0.24
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
)
2020-11-20 21:15:27 +01:00
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(BUILD_SHARED_LIBS 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)
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)
2020-11-20 20:20:28 +01:00
set(CXX_STANDARD 17)
find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex program_options)
find_package(ICU REQUIRED COMPONENTS uc)
2020-11-20 21:15:27 +01:00
find_package(Freetype REQUIRED)
2020-11-21 09:46:54 +01:00
find_package(harfbuzz CONFIG REQUIRED)
2020-11-20 20:20:28 +01:00
if(USE_EXTERNAL_MAPBOX_GEOMETRY)
find_path(MAPBOX_GEOMETRY_INCLUDE_DIRS "mapbox/geometry.hpp")
else()
set(MAPBOX_GEOMETRY_INCLUDE_DIRS deps/mapbox/geometry/include)
endif()
if(NOT MAPBOX_GEOMETRY_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_GEOMETRY_INCLUDE_DIRS to the mapbox/geometry.hpp include dir")
endif()
if(USE_EXTERNAL_MAPBOX_POLYLABEL)
find_path(MAPBOX_POLYLABEL_INCLUDE_DIRS "mapbox/polylabel.hpp")
else()
set(MAPBOX_POLYLABEL_INCLUDE_DIRS deps/mapbox/polylabel/include)
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)
find_path(MAPBOX_PROTOZERO_INCLUDE_DIRS "protozero/pbf_message.hpp")
else()
set(MAPBOX_PROTOZERO_INCLUDE_DIRS deps/mapbox/protozero/include)
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)
find_path(MAPBOX_VARIANT_INCLUDE_DIRS "mapbox/variant.hpp")
else()
set(MAPBOX_VARIANT_INCLUDE_DIRS deps/mapbox/variant/include)
endif()
if(NOT MAPBOX_VARIANT_INCLUDE_DIRS)
message(FATAL_ERROR "Set MAPBOX_VARIANT_INCLUDE_DIRS to the mapbox/variant include dir")
endif()
2020-11-20 21:15:27 +01:00
set(MAPNIK_COMPILE_DEFS "")
set(MAPNIK_OPTIONAL_LIBS "")
2020-11-21 10:09:29 +01:00
if(USE_LIBXML2)
message(STATUS "Using LibXml2")
find_package(LibXml2 REQUIRED)
2020-11-20 21:15:27 +01:00
set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_LIBXML2)
set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} LibXml2::LibXml2)
endif()
2020-11-21 10:09:29 +01:00
if(USE_PNG)
message(STATUS "Using PNG")
find_package(PNG REQUIRED)
2020-11-20 21:15:27 +01:00
set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_PNG)
2020-11-21 09:46:54 +01:00
set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} PNG::PNG)
2020-11-20 21:15:27 +01:00
endif()
2020-11-21 10:09:29 +01:00
if(USE_JPEG)
message(STATUS "Using JPEG")
find_package(JPEG REQUIRED)
2020-11-20 21:15:27 +01:00
set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_JPEG)
2020-11-21 09:46:54 +01:00
set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} JPEG::JPEG)
2020-11-20 21:15:27 +01:00
endif()
2020-11-21 10:09:29 +01:00
if(USE_TIFF)
find_package(TIFF REQUIRED)
message(STATUS "Using TIFF")
2020-11-20 21:15:27 +01:00
set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_TIFF)
2020-11-21 09:46:54 +01:00
set(MAPNIK_OPTIONAL_LIBS ${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)
message(STATUS "Using WEBP")
find_package(WebP CONFIG REQUIRED)
2020-11-20 21:15:27 +01:00
set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_WEBP)
2020-11-21 09:46:54 +01:00
set(MAPNIK_OPTIONAL_LIBS ${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)
message(STATUS "Using Cairo renderer")
find_package(Cairo REQUIRED)
2020-11-20 21:15:27 +01:00
set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_CAIRO)
set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} Cairo::Cairo)
endif()
2020-11-20 20:20:28 +01:00
add_library(mapnik-headers INTERFACE)
add_library(mapnik::headers ALIAS mapnik-headers)
target_include_directories(mapnik-headers INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
${MAPBOX_GEOMETRY_INCLUDE_DIRS}
${MAPBOX_POLYLABEL_INCLUDE_DIRS}
${MAPBOX_VARIANT_INCLUDE_DIRS}
${MAPBOX_PROTOZERO_INCLUDE_DIRS}
deps
)
target_link_libraries(mapnik-headers INTERFACE
Boost::boost
2020-11-20 21:15:27 +01:00
Boost::regex
Boost::filesystem
2020-11-20 20:20:28 +01:00
ICU::uc
2020-11-20 21:15:27 +01:00
Freetype::Freetype
2020-11-21 09:46:54 +01:00
harfbuzz::harfbuzz
2020-11-20 21:15:27 +01:00
${MAPNIK_OPTIONAL_LIBS}
2020-11-20 20:20:28 +01:00
)
if(BUILD_SHARED_LIBS)
target_compile_definitions(mapnik-headers INTERFACE MAPNIK_EXPORTS)
endif()
install(TARGETS mapnik-headers
EXPORT MapnikTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include/
PUBLIC_HEADER DESTINATION include/
)
2020-11-20 21:15:27 +01:00
2020-11-20 20:20:28 +01:00
add_subdirectory(deps)
add_subdirectory(src)
2020-11-20 21:15:27 +01:00
add_subdirectory(utils)
2020-11-20 20:20:28 +01:00
#add_subdirectory(utils)
#add_subdirectory(plugins)