diff --git a/CMakeLists.txt b/CMakeLists.txt index c2b11a3b7..47bbaa15d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,72 +17,77 @@ message(STATUS "mapnik version: ${PROJECT_VERSION}") set_property(GLOBAL PROPERTY USE_FOLDERS ON) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include(FeatureSummary) +include(MapnikOption) include(MapnikMinimumVersions) include(MapnikFindPackage) include(MapnikCopyDependencies) include(MapnikInstall) 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") -option(COPY_LIBRARIES_FOR_EXECUTABLES "copies required shared libaries (only windows) to the executable build directory" OFF) -option(COPY_FONTS_AND_PLUGINS_FOR_EXECUTABLES "copies required plugins and fonts into the executable build directory" ON) -option(INSTALL_DEPENDENCIES "if ON, all dependencies (eg. required dlls) will be copied into CMAKE_INSTALL_PREFIX/MAPNIK_BIN_DIR." ON) +mapnik_option(COPY_LIBRARIES_FOR_EXECUTABLES "copies required shared libaries (only windows) to the executable build directory" OFF) +mapnik_option(COPY_FONTS_AND_PLUGINS_FOR_EXECUTABLES "copies required plugins and fonts into the executable build directory" ON) +mapnik_option(INSTALL_DEPENDENCIES "if ON, all dependencies (eg. required dlls) will be copied into CMAKE_INSTALL_PREFIX/MAPNIK_BIN_DIR." ON) -option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON) -option(BUILD_TEST "builds the tests" ON) -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) -option(USE_PROJ "adds proj support" ON) -option(USE_GRID_RENDERER "adds grid renderer" ON) -option(USE_SVG_RENDERER "adds svg renderer" ON) -option(USE_BIGINT "uses 64 bit instead of 32" ON) -option(USE_MEMORY_MAPPED_FILE "uses file cache" ON) -option(USE_MULTITHREADED "enables the multithreaded features (threadsafe)" ON) -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) +mapnik_option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON) +mapnik_option(BUILD_TEST "builds the tests" ON) +mapnik_option(USE_EXTERNAL_MAPBOX_GEOMETRY "Use a external mapnik/geometry.hpp. If off, use the submodule" OFF) +mapnik_option(USE_EXTERNAL_MAPBOX_POLYLABEL "Use a external mapnik/polylabel. If off, use the submodule" OFF) +mapnik_option(USE_EXTERNAL_MAPBOX_PROTOZERO "Use a external mapnik/protozero. If off, use the submodule" OFF) +mapnik_option(USE_EXTERNAL_MAPBOX_VARIANT "Use a external mapnik/variant. If off, use the submodule" OFF) +mapnik_option(USE_JPEG "adds jpeg support" ON) +mapnik_option(USE_PNG "adds png support" ON) +mapnik_option(USE_TIFF "adds tiff support" ON) +mapnik_option(USE_WEBP "adds webp support" ON) +mapnik_option(USE_LIBXML2 "adds libxml2 support" ON) +mapnik_option(USE_CAIRO "adds the cairo renderer" ON) +mapnik_option(USE_PROJ "adds proj support" ON) +mapnik_option(USE_GRID_RENDERER "adds grid renderer" ON) +mapnik_option(USE_SVG_RENDERER "adds svg renderer" ON) +mapnik_option(USE_BIGINT "uses 64 bit instead of 32" ON) +mapnik_option(USE_MEMORY_MAPPED_FILE "uses file cache" ON) +mapnik_option(USE_MULTITHREADED "enables the multithreaded features (threadsafe)" ON) +mapnik_option(USE_NO_ATEXIT "disable atexit" OFF) +mapnik_option(USE_NO_DLCLOSE "disable dlclose" OFF) +mapnik_option(USE_DEBUG_OUTPUT "enables some debug messages for development" OFF) +mapnik_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") -option(USE_STATS "Enable statistics reporting" OFF) +mapnik_option(USE_STATS "Enable statistics reporting" OFF) -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) +mapnik_option(USE_PLUGIN_INPUT_CSV "adds plugin input csv" ON) +mapnik_option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON) +mapnik_option(USE_PLUGIN_INPUT_GEOBUF "adds plugin input geobuf" ON) +mapnik_option(USE_PLUGIN_INPUT_GEOJSON "adds plugin input geojson" ON) +mapnik_option(USE_PLUGIN_INPUT_OGR "adds plugin input ogr" ON) +mapnik_option(USE_PLUGIN_INPUT_PGRASTER "adds plugin input pgraster" ON) +mapnik_option(USE_PLUGIN_INPUT_POSTGIS "adds plugin input postgis" ON) +mapnik_option(USE_PLUGIN_INPUT_RASTER "adds plugin input raster" ON) +mapnik_option(USE_PLUGIN_INPUT_SHAPE "adds plugin input shape" ON) +mapnik_option(USE_PLUGIN_INPUT_SQLITE "adds plugin input sqlite" ON) +mapnik_option(USE_PLUGIN_INPUT_TOPOJSON "adds plugin input topojson" ON) -option(BUILD_DEMO_VIEWER "builds the demo viewer" ON) -option(BUILD_DEMO_CPP "builds the demo c++ application" ON) +mapnik_option(BUILD_DEMO_VIEWER "builds the demo viewer" ON) +mapnik_option(BUILD_DEMO_CPP "builds the demo c++ application" ON) -option(BUILD_BENCHMARK "builds benchmark project" ON) +mapnik_option(BUILD_BENCHMARK "builds benchmark project" ON) -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) +mapnik_option(BUILD_UTILITY_GEOMETRY_TO_WKB "builds the utility program geometry_to_wkb" ON) +mapnik_option(BUILD_UTILITY_MAPNIK_INDEX "builds the utility program mapnik_index" ON) +mapnik_option(BUILD_UTILITY_MAPNIK_RENDER "builds the utility program mapnik_render" ON) +mapnik_option(BUILD_UTILITY_OGRINDEX "builds the utility program ogrindex" OFF) +mapnik_option(BUILD_UTILITY_PGSQL2SQLITE "builds the utility program pgsql2sqlite" ON) +mapnik_option(BUILD_UTILITY_SHAPEINDEX "builds the utility program shapeindex" ON) +mapnik_option(BUILD_UTILITY_SVG2PNG "builds the utility program svg2png" ON) -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) -option(USE_GLIBC_WORKAROUND "see https://github.com/mapnik/mapnik/pull/3792 if you building with libstdc++-4.9" OFF) +mapnik_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) +mapnik_option(USE_GLIBC_WORKAROUND "see https://github.com/mapnik/mapnik/pull/3792 if you building with libstdc++-4.9" OFF) + +feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES) +feature_summary(FILENAME "${CMAKE_CURRENT_BINARY_DIR}/features.log" WHAT ENABLED_FEATURES DISABLED_FEATURES) set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++14 is minimum.") message(STATUS "Using c++${CMAKE_CXX_STANDARD}") @@ -124,27 +129,34 @@ set(MAPNIK_OPTIONAL_LIBS_INCLUDE "") # 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) mapnik_find_threads() mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) + mapnik_find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS filesystem system regex) +list(APPEND MAPNIK_COMPILE_DEFS BOOST_REGEX_HAS_ICU) if(USE_BOOST_REGEX_ICU_WORKAROUND) message(STATUS "using boost regex workaround") set_property(TARGET Boost::regex PROPERTY INTERFACE_LINK_LIBRARIES) endif() +include(CheckBoostRegexIcu) +check_boost_regex() +if(BOOST_REGEX_HAS_ICU) + message(STATUS "boost regex has icu support") + list(APPEND MAPNIK_COMPILE_DEFS BOOST_REGEX_HAS_ICU) +endif() mapnik_find_package(Freetype REQUIRED) # try to find harfbuzz with the native configuration and fallback to our "own" FindHarfBuzz -mapnik_find_package(harfbuzz ${HARFBUZZ_MIN_VERSION} CONFIG QUIET) +mapnik_find_package(harfbuzz CONFIG QUIET) if(harfbuzz_FOUND) message(STATUS "Found harfbuzz native cmake") list(APPEND MAPNIK_OPTIONAL_LIBS harfbuzz::harfbuzz) @@ -222,42 +234,34 @@ set_property(GLOBAL PROPERTY PLUGINS "") set_property(GLOBAL PROPERTY MAPNIK_UTILITIES "") if(USE_GLIBC_WORKAROUND) - message("using glibc workaround") list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_ENABLE_GLIBC_WORKAROUND) endif() if(USE_BIGINT) - message(STATUS "uses BIGINT") list(APPEND MAPNIK_COMPILE_DEFS BIGINT) endif() if(USE_MEMORY_MAPPED_FILE) - message(STATUS "uses MAPNIK_MEMORY_MAPPED_FILE") list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_MEMORY_MAPPED_FILE) endif() 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}") 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) endif() @@ -308,21 +312,21 @@ if(USE_PROJ) set(PROJ_VERSION_MAJOR "${CMAKE_MATCH_1}") set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}") set(PROJ_VERSION_PATCH "${CMAKE_MATCH_3}") + list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::PROJ) + else() + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE $) endif() math(EXPR MAPNIK_PROJ_VERSION "${PROJ_VERSION_MAJOR}*10000 + ${PROJ_VERSION_MINOR}*100 + ${PROJ_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) message(STATUS "Using mapnik PROJ version: ${MAPNIK_PROJ_VERSION}") list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ MAPNIK_PROJ_VERSION=${MAPNIK_PROJ_VERSION}) - list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES}) - list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE $) endif() 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() @@ -373,6 +377,8 @@ if(BUILD_TEST) add_subdirectory(test) endif() +feature_summary(FILENAME "${CMAKE_CURRENT_BINARY_DIR}/packages.log" WHAT PACKAGES_FOUND PACKAGES_NOT_FOUND INCLUDE_QUIET_PACKAGES) + # start package mapnik include(MapnikExport) include(MapnikExportPkgConfig) diff --git a/cmake/CheckBoostRegexIcu.cmake b/cmake/CheckBoostRegexIcu.cmake new file mode 100644 index 000000000..b2e7b9430 --- /dev/null +++ b/cmake/CheckBoostRegexIcu.cmake @@ -0,0 +1,23 @@ +include(CheckCXXSourceRuns) + +function(check_boost_regex) + set(CMAKE_REQUIRED_LIBRARIES ICU::uc ICU::data ICU::i18n Boost::headers Boost::regex) + check_cxx_source_runs([[ + #include + #include + int main() + { + U_NAMESPACE_QUALIFIER UnicodeString ustr; + try { + boost::u32regex pattern = boost::make_u32regex(ustr); + } + // an exception is fine, still indicates support is + // likely compiled into regex + catch (...) { + return 0; + } + return 0; + } + ]] BOOST_REGEX_HAS_ICU) + set(BOOST_REGEX_HAS_ICU ${BOOST_REGEX_HAS_ICU} PARENT_SCOPE) +endfunction(check_boost_regex) diff --git a/cmake/MapnikOption.cmake b/cmake/MapnikOption.cmake new file mode 100644 index 000000000..f9cef90b5 --- /dev/null +++ b/cmake/MapnikOption.cmake @@ -0,0 +1,4 @@ +macro(mapnik_option _name) + option(${ARGN}) + add_feature_info("${ARGV0}" ${ARGV0} "${ARGV1}") +endmacro() diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt index f69a8f697..c26ddf699 100644 --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -1,9 +1,7 @@ if(BUILD_DEMO_VIEWER) - message(STATUS "Building demo viewer") add_subdirectory(viewer) endif() if(BUILD_DEMO_CPP) - message(STATUS "Building c++ demo app") add_subdirectory(c++) endif() diff --git a/demo/viewer/layerdelegate.cpp b/demo/viewer/layerdelegate.cpp index b41ad1864..d441e1e11 100644 --- a/demo/viewer/layerdelegate.cpp +++ b/demo/viewer/layerdelegate.cpp @@ -38,7 +38,7 @@ void LayerDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, painter->setBrush(QBrush(QColor(255, 0, 0, 64))); - painter->drawRoundRect(option.rect,4,4); + painter->drawRoundedRect(option.rect,4,4); if (option.state & QStyle::State_Selected) painter->setBrush(option.palette.highlightedText()); diff --git a/demo/viewer/mapwidget.cpp b/demo/viewer/mapwidget.cpp index b1ea939b0..81579e373 100644 --- a/demo/viewer/mapwidget.cpp +++ b/demo/viewer/mapwidget.cpp @@ -293,7 +293,23 @@ void MapWidget::wheelEvent(QWheelEvent* e) { return; } - +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + QPointF corner(map_->width(), map_->height()); + QPointF zoomCoords; + double zoom; + if (e->angleDelta().y() > 0) + { + zoom = 0.5; + QPointF center = corner / 2; + QPointF delta = e->position() - center; + zoomCoords = zoom * delta + center; + } + else + { + zoom = 2.0; + zoomCoords = corner - e->position(); + } +#else QPoint corner(map_->width(), map_->height()); QPoint zoomCoords; double zoom; @@ -309,6 +325,7 @@ void MapWidget::wheelEvent(QWheelEvent* e) zoom = 2.0; zoomCoords = corner - e->pos(); } +#endif map_->pan_and_zoom(zoomCoords.x(), zoomCoords.y(), zoom); updateMap(); diff --git a/include/mapnik/sql_utils.hpp b/include/mapnik/sql_utils.hpp index 52899997d..72d120a1b 100644 --- a/include/mapnik/sql_utils.hpp +++ b/include/mapnik/sql_utils.hpp @@ -37,6 +37,7 @@ MAPNIK_DISABLE_WARNING_POP #include #include #include +#include namespace mapnik { namespace sql_utils { diff --git a/plugins/input/CMakeLists.txt b/plugins/input/CMakeLists.txt index be5d0b11a..598f77f91 100644 --- a/plugins/input/CMakeLists.txt +++ b/plugins/input/CMakeLists.txt @@ -2,46 +2,35 @@ set(_plugin_prefix "") set(_plugin_suffix ".input") if(USE_PLUGIN_INPUT_CSV) - message(STATUS "using input plugin csv") add_subdirectory(csv) endif() if(USE_PLUGIN_INPUT_GDAL) - message(STATUS "using input plugin gdal") add_subdirectory(gdal) endif() if(USE_PLUGIN_INPUT_GEOBUF) - message(STATUS "using input plugin geobuf") add_subdirectory(geobuf) endif() if(USE_PLUGIN_INPUT_GEOJSON) - message(STATUS "using input plugin geojson") add_subdirectory(geojson) endif() if(USE_PLUGIN_INPUT_OGR) - message(STATUS "using input plugin ogr") add_subdirectory(ogr) endif() if(USE_PLUGIN_INPUT_PGRASTER) - message(STATUS "using input plugin pgraster") add_subdirectory(pgraster) endif() if(USE_PLUGIN_INPUT_POSTGIS) - message(STATUS "using input plugin postgis") add_subdirectory(postgis) endif() if(USE_PLUGIN_INPUT_RASTER) - message(STATUS "using input plugin raster") add_subdirectory(raster) endif() if(USE_PLUGIN_INPUT_SHAPE) - message(STATUS "using input plugin shape") add_subdirectory(shape) endif() if(USE_PLUGIN_INPUT_SQLITE) - message(STATUS "using input plugin sqlite") add_subdirectory(sqlite) endif() if(USE_PLUGIN_INPUT_TOPOJSON) - message(STATUS "using input plugin topojson") add_subdirectory(topojson) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5017206ff..343a6d540 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,35 @@ add_subdirectory(json) add_subdirectory(wkt) -set(MAPNIK_SOURCES +add_library(mapnik "") +add_library(mapnik::mapnik ALIAS mapnik) + +if(BUILD_SHARED_LIBS) + target_compile_definitions(mapnik PRIVATE MAPNIK_EXPORTS) +endif() + +target_link_libraries(mapnik PUBLIC mapnik::core) +target_link_libraries(mapnik PRIVATE mapnik::agg) + +set_target_properties(mapnik PROPERTIES + DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}" + OUTPUT_NAME "mapnik" + PREFIX "lib" + IMPORT_PREFIX "lib" # for the archive on dll platforms + VERSION ${MAPNIK_VERSION} + # see https://github.com/mapnik/mapnik/pull/4248#issuecomment-925596509 => ABI compability only with the full version + SOVERSION ${MAPNIK_VERSION} +) + +if(MSVC) + # disable some msvc warnings and enable bigobj + # 4068 will warn about unknown definitions. Would not be needed if https://github.com/mapbox/geometry.hpp/pull/69 is merged. + # 4661 warns about enum definitions. should be investigated at some point + # 4910 warns about extern and dllexport at the same time. should be investigated at some point + target_compile_options(mapnik PUBLIC "/bigobj" "/wd4068" "/wd4661" "/wd4910") +endif() + +target_sources(mapnik PRIVATE cairo_io.cpp color_factory.cpp color.cpp @@ -79,19 +107,7 @@ set(MAPNIK_SOURCES wkb.cpp xml_tree.cpp ) -set(COMPILE_SRC ${MAPNIK_SOURCES}) - -if(USE_JPEG) - list(APPEND COMPILE_SRC jpeg_reader.cpp) -endif() -if(USE_PNG) - list(APPEND COMPILE_SRC png_reader.cpp) -endif() -if(USE_TIFF) - list(APPEND COMPILE_SRC tiff_reader.cpp) -endif() - -set(AGG_COMPILE_SRC +target_sources(mapnik PRIVATE ../deps/agg/src/agg_arc.cpp ../deps/agg/src/agg_arrowhead.cpp ../deps/agg/src/agg_bezier_arc.cpp @@ -118,7 +134,7 @@ set(AGG_COMPILE_SRC ../deps/agg/src/agg_vpgen_clip_polyline.cpp ../deps/agg/src/agg_vpgen_segmentator.cpp ) -set(AGG_SRC +target_sources(mapnik PRIVATE agg/agg_renderer.cpp agg/process_building_symbolizer.cpp agg/process_debug_symbolizer.cpp @@ -133,38 +149,14 @@ set(AGG_SRC agg/process_raster_symbolizer.cpp agg/process_shield_symbolizer.cpp agg/process_text_symbolizer.cpp - ${AGG_COMPILE_SRC} ) -list(APPEND COMPILE_SRC ${AGG_SRC}) -if(USE_CAIRO) - message(STATUS "adding cairo renderer to compilation") - 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 - ) - list(APPEND COMPILE_SRC ${CAIRO_SRC}) -endif() - -set(CSS_SRC +target_sources(mapnik PRIVATE css/css_color_grammar_x3.cpp css/css_grammar_x3.cpp ) -list(APPEND COMPILE_SRC ${CSS_SRC}) -set(GEOMETRY_SRC +target_sources(mapnik PRIVATE geometry/box2d.cpp geometry/closest_point.cpp geometry/envelope.cpp @@ -172,67 +164,30 @@ set(GEOMETRY_SRC geometry/polylabel.cpp geometry/reprojection.cpp ) -list(APPEND COMPILE_SRC ${GEOMETRY_SRC}) -if(USE_GRID_RENDERER) - message(STATUS "adding grid renderer to compilation") - set(GRID_SRC - grid/grid_renderer.cpp - grid/grid.cpp - grid/process_building_symbolizer.cpp - grid/process_group_symbolizer.cpp - grid/process_line_pattern_symbolizer.cpp - grid/process_line_symbolizer.cpp - grid/process_markers_symbolizer.cpp - grid/process_point_symbolizer.cpp - grid/process_polygon_pattern_symbolizer.cpp - grid/process_polygon_symbolizer.cpp - grid/process_raster_symbolizer.cpp - grid/process_shield_symbolizer.cpp - grid/process_text_symbolizer.cpp - ) - list(APPEND COMPILE_SRC ${GRID_SRC}) -endif() - -set(GROUP_SRC - group/group_layout_manager.cpp - group/group_rule.cpp - group/group_symbolizer_helper.cpp -) -list(APPEND COMPILE_SRC ${GROUP_SRC}) - -set(RENDERER_COMMON_SRC +target_sources(mapnik PRIVATE renderer_common/pattern_alignment.cpp renderer_common/render_group_symbolizer.cpp renderer_common/render_markers_symbolizer.cpp renderer_common/render_pattern.cpp renderer_common/render_thunk_extractor.cpp ) -list(APPEND COMPILE_SRC ${RENDERER_COMMON_SRC}) -set(SVG_SRC +target_sources(mapnik PRIVATE svg/svg_parser.cpp svg/svg_path_grammar_x3.cpp svg/svg_path_parser.cpp svg/svg_points_parser.cpp svg/svg_transform_parser.cpp ) -if(USE_SVG_RENDERER) - message(STATUS "adding svg renderer to compilation") - set(SVG_RENDERER_SRC - svg/output/process_line_symbolizer.cpp - svg/output/process_polygon_symbolizer.cpp - svg/output/process_symbolizers.cpp - svg/output/svg_generator.cpp - svg/output/svg_output_attributes.cpp - svg/output/svg_output_grammars.cpp - svg/output/svg_renderer.cpp - ) - list(APPEND SVG_SRC ${SVG_RENDERER_SRC}) -endif() -list(APPEND COMPILE_SRC ${SVG_SRC}) -set(TEXT_SRC +target_sources(mapnik PRIVATE + group/group_layout_manager.cpp + group/group_rule.cpp + group/group_symbolizer_helper.cpp +) + +target_sources(mapnik PRIVATE text/color_font_renderer.cpp text/face.cpp text/font_feature_settings.cpp @@ -261,50 +216,83 @@ set(TEXT_SRC text/placements/registry.cpp text/placements/simple.cpp ) -list(APPEND COMPILE_SRC ${TEXT_SRC}) -set(UTIL_SRC +target_sources(mapnik PRIVATE util/math.cpp util/utf_conv_win.cpp ) -list(APPEND COMPILE_SRC ${UTIL_SRC}) + +if(USE_CAIRO) + target_sources(mapnik PRIVATE + 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() + +if(USE_JPEG) + target_sources(mapnik PRIVATE jpeg_reader.cpp) +endif() + +if(USE_PNG) + target_sources(mapnik PRIVATE png_reader.cpp) +endif() + +if(USE_TIFF) + target_sources(mapnik PRIVATE tiff_reader.cpp) +endif() + +if(USE_WEBP) + target_sources(mapnik PRIVATE webp_reader.cpp) +endif() + +if(USE_GRID_RENDERER) + target_sources(mapnik PRIVATE + grid/grid_renderer.cpp + grid/grid.cpp + grid/process_building_symbolizer.cpp + grid/process_group_symbolizer.cpp + grid/process_line_pattern_symbolizer.cpp + grid/process_line_symbolizer.cpp + grid/process_markers_symbolizer.cpp + grid/process_point_symbolizer.cpp + grid/process_polygon_pattern_symbolizer.cpp + grid/process_polygon_symbolizer.cpp + grid/process_raster_symbolizer.cpp + grid/process_shield_symbolizer.cpp + grid/process_text_symbolizer.cpp + ) +endif() + +if(USE_SVG_RENDERER) + target_sources(mapnik PRIVATE + svg/output/process_line_symbolizer.cpp + svg/output/process_polygon_symbolizer.cpp + svg/output/process_symbolizers.cpp + svg/output/svg_generator.cpp + svg/output/svg_output_attributes.cpp + svg/output/svg_output_grammars.cpp + svg/output/svg_renderer.cpp + ) +endif() if(USE_LIBXML2) message(STATUS "adding libxml2_loader to compilation") - list(APPEND COMPILE_SRC libxml2_loader.cpp) + target_sources(mapnik PRIVATE libxml2_loader.cpp) else() message(STATUS "adding rapidxml_loader to compilation") - list(APPEND COMPILE_SRC rapidxml_loader.cpp) -endif() - -add_library(mapnik ${COMPILE_SRC}) -add_library(mapnik::mapnik ALIAS mapnik) - -set(COMPILE_DEFS "") -if(BUILD_SHARED_LIBS) - list(APPEND COMPILE_DEFS MAPNIK_EXPORTS) -endif() - -target_compile_definitions(mapnik PRIVATE ${COMPILE_DEFS}) -target_link_libraries(mapnik PUBLIC mapnik::core) -target_link_libraries(mapnik PRIVATE mapnik::agg) - -set_target_properties(mapnik PROPERTIES - DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}" - OUTPUT_NAME "mapnik" - PREFIX "lib" - IMPORT_PREFIX "lib" # for the archive on dll platforms - VERSION ${MAPNIK_VERSION} - # see https://github.com/mapnik/mapnik/pull/4248#issuecomment-925596509 => ABI compability only with the full version - SOVERSION ${MAPNIK_VERSION} -) - -if(MSVC) - # disable some msvc warnings and enable bigobj - # 4068 will warn about unknown definitions. Would not be needed if https://github.com/mapbox/geometry.hpp/pull/69 is merged. - # 4661 warns about enum definitions. should be investigated at some point - # 4910 warns about extern and dllexport at the same time. should be investigated at some point - target_compile_options(mapnik PUBLIC "/bigobj" "/wd4068" "/wd4661" "/wd4910") + target_sources(mapnik PRIVATE rapidxml_loader.cpp) endif() mapnik_install(mapnik) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bea2742c0..0705ddce1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,7 +4,6 @@ find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options) find_package(PostgreSQL REQUIRED) include(FetchContent) -include(CopyDllsForDebug) FetchContent_Declare( Catch2 @@ -12,18 +11,12 @@ FetchContent_Declare( GIT_TAG v2.13.7) FetchContent_MakeAvailable(Catch2) -# Prepare "Catch" library for other executables -set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -add_library(Catch INTERFACE) -target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}) - if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19.0") # for cmake 3.19+ https://cmake.org/cmake/help/git-stage/policy/CMP0110.html # might not be needed if catch updates its cmakes cmake_policy(SET CMP0110 OLD) endif() - add_executable(mapnik-test-unit unit/run.cpp unit/color/css_color.cpp @@ -108,45 +101,53 @@ add_executable(mapnik-test-unit unit/vertex_adapter/vertex_adapter.cpp ) target_link_libraries(mapnik-test-unit PUBLIC - Catch + Catch2::Catch2 mapnik::agg mapnik::mapnik mapnik::json mapnik::wkt PostgreSQL::PostgreSQL ) +# workaround since the "offical" include dir would be +file(COPY catch_ext.hpp DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") +file(COPY cleanup.hpp DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") +target_include_directories(mapnik-test-unit PRIVATE "${catch2_SOURCE_DIR}/single_include/catch2" ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) add_executable(agg_rasterizer_integer_overflow_test standalone/agg_rasterizer_integer_overflow_test.cpp) target_link_libraries(agg_rasterizer_integer_overflow_test PUBLIC - Catch + Catch2::Catch2 mapnik::mapnik mapnik::agg mapnik::json ) +target_include_directories(agg_rasterizer_integer_overflow_test PRIVATE "${catch2_SOURCE_DIR}/single_include/catch2" ${CMAKE_CURRENT_BINARY_DIR}) add_executable(datasource_registration_test standalone/datasource_registration_test.cpp) target_link_libraries(datasource_registration_test PUBLIC - Catch + Catch2::Catch2 mapnik::mapnik mapnik::agg ) +target_include_directories(datasource_registration_test PRIVATE "${catch2_SOURCE_DIR}/single_include/catch2" ${CMAKE_CURRENT_BINARY_DIR}) add_executable(font_registration_test standalone/font_registration_test.cpp) target_link_libraries(font_registration_test PUBLIC - Catch + Catch2::Catch2 mapnik::mapnik mapnik::agg mapnik::json ) +target_include_directories(font_registration_test PRIVATE "${catch2_SOURCE_DIR}/single_include/catch2" ${CMAKE_CURRENT_BINARY_DIR}) #not workable since boost::filesystem native returns a wstring and the function taskes a std::string add_executable(map_xml_test standalone/map_xml_test.cpp) target_link_libraries(map_xml_test PUBLIC - Catch + Catch2::Catch2 mapnik::mapnik mapnik::agg mapnik::json ) +target_include_directories(map_xml_test PRIVATE "${catch2_SOURCE_DIR}/single_include/catch2" ${CMAKE_CURRENT_BINARY_DIR}) add_executable(mapnik-test-visual visual/parse_map_sizes.cpp @@ -154,18 +155,18 @@ add_executable(mapnik-test-visual visual/runner.cpp visual/run.cpp ) -target_link_libraries( - mapnik-test-visual PRIVATE - Catch +target_link_libraries(mapnik-test-visual PRIVATE + Catch2::Catch2 Boost::program_options Boost::filesystem mapnik::mapnik mapnik::agg ) +target_include_directories(mapnik-test-visual PRIVATE "${catch2_SOURCE_DIR}/single_include/catch2" ${CMAKE_CURRENT_BINARY_DIR}) include(CTest) -include(${catch2_SOURCE_DIR}/contrib/Catch.cmake) -include(${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake) +include("${catch2_SOURCE_DIR}/contrib/Catch.cmake") +include("${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake") # use only mapnik-test-unit since it has the same build path mapnik_copy_plugins( @@ -184,10 +185,22 @@ mapnik_copy_dependencies( ) -file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test) -file(COPY data-visual DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test) +file(COPY data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/test") +file(COPY data-visual DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/test") +file(COPY unit/data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/test/unit") +file(COPY "${mapnik_SOURCE_DIR}/demo/data" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/demo") +add_dependencies(mapnik-test-unit mapnik-index shapeindex) +if(WIN32) + catch_discover_tests(mapnik-test-unit PROPERTIES + ENVIRONMENT "PATH=\$;$;$ENV{PATH}>,\\\\\\\\\;>" + ) +else() + catch_discover_tests(mapnik-test-unit PROPERTIES + ENVIRONMENT "PATH=$;$;$ENV{PATH}>" + ) +endif() + -catch_discover_tests(mapnik-test-unit) catch_discover_tests(agg_rasterizer_integer_overflow_test) catch_discover_tests(datasource_registration_test) catch_discover_tests(font_registration_test) diff --git a/test/unit/datasource/ds_test_util.hpp b/test/unit/datasource/ds_test_util.hpp index b6c45e554..09237b067 100644 --- a/test/unit/datasource/ds_test_util.hpp +++ b/test/unit/datasource/ds_test_util.hpp @@ -199,7 +199,11 @@ inline int create_disk_index(std::string const& filename, bool silent = true) { cmd += std::string("DYLD_LIBRARY_PATH=") + std::getenv("DYLD_LIBRARY_PATH") + " "; } - cmd += "mapnik-index " + filename; + cmd += "mapnik-index"; +#ifdef _WINDOWS + cmd += ".exe"; +#endif + cmd += " " + filename; if (silent) { #ifndef _WINDOWS diff --git a/test/unit/datasource/shapeindex.cpp b/test/unit/datasource/shapeindex.cpp index 61b421e72..6ebd253a0 100644 --- a/test/unit/datasource/shapeindex.cpp +++ b/test/unit/datasource/shapeindex.cpp @@ -74,8 +74,11 @@ int create_shapefile_index(std::string const& filename, bool index_parts, bool s { cmd += std::string("DYLD_LIBRARY_PATH=") + std::getenv("DYLD_LIBRARY_PATH") + " "; } - - cmd += "shapeindex "; + cmd += "shapeindex"; +#ifdef _WINDOWS + cmd += ".exe"; +#endif + cmd += " "; if (index_parts) cmd+= "--index-parts "; cmd += filename; if (silent) diff --git a/test/unit/datasource/spatial_index.cpp b/test/unit/datasource/spatial_index.cpp index 65d62c17f..2ae435603 100644 --- a/test/unit/datasource/spatial_index.cpp +++ b/test/unit/datasource/spatial_index.cpp @@ -22,6 +22,8 @@ #include "catch.hpp" +#include + #include #include diff --git a/test/unit/imaging/webp_io.cpp b/test/unit/imaging/webp_io.cpp index 8f6d23be6..7e3d2e0fb 100644 --- a/test/unit/imaging/webp_io.cpp +++ b/test/unit/imaging/webp_io.cpp @@ -3,6 +3,8 @@ #include "catch.hpp" +#include + #include #include diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 7aca5c8e4..6b533898b 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,29 +1,22 @@ if(BUILD_UTILITY_GEOMETRY_TO_WKB) - message(STATUS "building utility geometry_to_wkb") add_subdirectory(geometry_to_wkb) endif() if(BUILD_UTILITY_MAPNIK_INDEX) - message(STATUS "building utility mapnik-index") add_subdirectory(mapnik-index) endif() if(BUILD_UTILITY_MAPNIK_RENDER) - message(STATUS "building utility mapnik-render") add_subdirectory(mapnik-render) endif() if(BUILD_UTILITY_OGRINDEX) - message(STATUS "building utility ogrindex") message(WARNING "can't build ogrindex currently due to some bugs") #add_subdirectory(ogrindex) # missing include file shapeindex/quadtree.hpp endif() if(BUILD_UTILITY_PGSQL2SQLITE) - message(STATUS "building utility pgsql2sqlite") add_subdirectory(pgsql2sqlite) endif() if(BUILD_UTILITY_SHAPEINDEX) - message(STATUS "building utility shapeindex") add_subdirectory(shapeindex) endif() if(BUILD_UTILITY_SVG2PNG) - message(STATUS "building utility svg2png") add_subdirectory(svg2png) endif()