From a4643c3bd1c548f8263116cd5620d572db481f5e Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 20 Nov 2020 18:20:43 +0100 Subject: [PATCH 001/141] initial cmake scripts --- .gitignore | 3 +++ CMakeLists.txt | 7 +++++++ plugins/CMakeLists.txt | 2 ++ plugins/input/CMakeLists.txt | 12 ++++++++++++ utils/CMakeLists.txt | 8 ++++++++ 5 files changed, 32 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 plugins/CMakeLists.txt create mode 100644 plugins/input/CMakeLists.txt create mode 100644 utils/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 2ecdd4b32c..922bdcf218 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +.vscode *.gcov *.gcda *.gcno @@ -56,3 +57,5 @@ demo/viewer/ui_layer_info.h test/standalone/*-bin test/unit/run test/visual/run +# cmake +build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..ecad3a171c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,7 @@ +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 +) \ No newline at end of file diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt new file mode 100644 index 0000000000..17e4ecbd76 --- /dev/null +++ b/plugins/CMakeLists.txt @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.15.0) +add_subdirectory(input) \ No newline at end of file diff --git a/plugins/input/CMakeLists.txt b/plugins/input/CMakeLists.txt new file mode 100644 index 0000000000..edbb7c5e3b --- /dev/null +++ b/plugins/input/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.15.0) +add_subdirectory(csv) +add_subdirectory(gdal) +add_subdirectory(geobuf) +add_subdirectory(geojson) +add_subdirectory(ogr) +add_subdirectory(pgraster) +add_subdirectory(postgis) +add_subdirectory(raster) +add_subdirectory(shape) +add_subdirectory(sqlite) +add_subdirectory(topojson) \ No newline at end of file diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt new file mode 100644 index 0000000000..e2f28bb111 --- /dev/null +++ b/utils/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15.0) +add_subdirectory(geometry_to_wkb) +add_subdirectory(mapnik-index) +add_subdirectory(mapnik-render) +add_subdirectory(ogrindex) +add_subdirectory(pgsql2sqlite) +add_subdirectory(shapeindex) +add_subdirectory(svg2png) \ No newline at end of file From e9a4828fd39fc2da5113711118806419f737f88d Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 20 Nov 2020 19:04:30 +0100 Subject: [PATCH 002/141] add string to box2d which is required by msvc --- include/mapnik/geometry/box2d.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/mapnik/geometry/box2d.hpp b/include/mapnik/geometry/box2d.hpp index dc5fd4666e..b858a9aa9c 100644 --- a/include/mapnik/geometry/box2d.hpp +++ b/include/mapnik/geometry/box2d.hpp @@ -33,6 +33,9 @@ MAPNIK_DISABLE_WARNING_PUSH #include MAPNIK_DISABLE_WARNING_POP +// stl +#include + // agg // forward declare so that apps using mapnik do not need agg headers namespace agg { From a014254e31a1ab5e368bc2c74b3c0d85c2313d3f Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 20 Nov 2020 20:02:40 +0100 Subject: [PATCH 003/141] fix mscv compiler errors --- include/mapnik/config.hpp | 11 +++++++++++ include/mapnik/geometry.hpp | 3 ++- include/mapnik/json/geojson_grammar_x3.hpp | 3 ++- include/mapnik/json/json_value.hpp | 3 ++- 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/include/mapnik/config.hpp b/include/mapnik/config.hpp index ac48546f2c..65b370784a 100644 --- a/include/mapnik/config.hpp +++ b/include/mapnik/config.hpp @@ -50,6 +50,17 @@ # endif #endif +#if defined(__clang__) +#if __has_feature(cxx_inheriting_constructors) +#define MAPNIK_USE_INHERITING_CONSTRUCTORS 1 +#endif +#elif (defined(__GNUC__) && \ + (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 8)) || \ + (__cpp_inheriting_constructors >= 200802) || \ + (defined(_MSC_VER) && _MSC_VER >= 1910) +#define MAPNIK_USE_INHERITING_CONSTRUCTORS 1 +#endif + #define PROJ_ENVELOPE_POINTS 20 #endif // MAPNIK_CONFIG_HPP diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index f6e795de97..dccd25371a 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -24,6 +24,7 @@ #define MAPNIK_GEOMETRY_HPP // mapnik +#include #include #include #include @@ -59,7 +60,7 @@ struct geometry : geometry_base { using coordinate_type = T; -#if __cpp_inheriting_constructors >= 200802 +#if MAPNIK_USE_INHERITING_CONSTRUCTORS using geometry_base::geometry_base; diff --git a/include/mapnik/json/geojson_grammar_x3.hpp b/include/mapnik/json/geojson_grammar_x3.hpp index 3f44d10669..e840c34367 100644 --- a/include/mapnik/json/geojson_grammar_x3.hpp +++ b/include/mapnik/json/geojson_grammar_x3.hpp @@ -23,6 +23,7 @@ #ifndef MAPNIK_JSON_GEOJSON_GRAMMAR_X3_HPP #define MAPNIK_JSON_GEOJSON_GRAMMAR_X3_HPP +#include #include #include #include @@ -54,7 +55,7 @@ using geojson_value_base = mapnik::util::variant; struct geojson_value : geojson_value_base { -#if __cpp_inheriting_constructors >= 200802 +#if MAPNIK_USE_INHERITING_CONSTRUCTORS using geojson_value_base::geojson_value_base; diff --git a/include/mapnik/json/json_value.hpp b/include/mapnik/json/json_value.hpp index c5ed036048..2157ce5956 100644 --- a/include/mapnik/json/json_value.hpp +++ b/include/mapnik/json/json_value.hpp @@ -24,6 +24,7 @@ #define MAPNIK_JSON_JSON_VALUE_HPP // mapnik +#include #include #include // stl @@ -46,7 +47,7 @@ using json_value_base = mapnik::util::variant; struct json_value : json_value_base { -#if __cpp_inheriting_constructors >= 200802 +#if MAPNIK_USE_INHERITING_CONSTRUCTORS using json_value_base::json_value_base; From 1f69d2ec621390676150f390022505348318764e Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 20 Nov 2020 20:11:42 +0100 Subject: [PATCH 004/141] Revert "fix mscv compiler errors" This reverts commit fe3160ca996922e122f2aa629280f51ad9445ae3. --- include/mapnik/config.hpp | 11 ----------- include/mapnik/geometry.hpp | 3 +-- include/mapnik/json/geojson_grammar_x3.hpp | 3 +-- include/mapnik/json/json_value.hpp | 3 +-- 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/include/mapnik/config.hpp b/include/mapnik/config.hpp index 65b370784a..ac48546f2c 100644 --- a/include/mapnik/config.hpp +++ b/include/mapnik/config.hpp @@ -50,17 +50,6 @@ # endif #endif -#if defined(__clang__) -#if __has_feature(cxx_inheriting_constructors) -#define MAPNIK_USE_INHERITING_CONSTRUCTORS 1 -#endif -#elif (defined(__GNUC__) && \ - (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 8)) || \ - (__cpp_inheriting_constructors >= 200802) || \ - (defined(_MSC_VER) && _MSC_VER >= 1910) -#define MAPNIK_USE_INHERITING_CONSTRUCTORS 1 -#endif - #define PROJ_ENVELOPE_POINTS 20 #endif // MAPNIK_CONFIG_HPP diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index dccd25371a..f6e795de97 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -24,7 +24,6 @@ #define MAPNIK_GEOMETRY_HPP // mapnik -#include #include #include #include @@ -60,7 +59,7 @@ struct geometry : geometry_base { using coordinate_type = T; -#if MAPNIK_USE_INHERITING_CONSTRUCTORS +#if __cpp_inheriting_constructors >= 200802 using geometry_base::geometry_base; diff --git a/include/mapnik/json/geojson_grammar_x3.hpp b/include/mapnik/json/geojson_grammar_x3.hpp index e840c34367..3f44d10669 100644 --- a/include/mapnik/json/geojson_grammar_x3.hpp +++ b/include/mapnik/json/geojson_grammar_x3.hpp @@ -23,7 +23,6 @@ #ifndef MAPNIK_JSON_GEOJSON_GRAMMAR_X3_HPP #define MAPNIK_JSON_GEOJSON_GRAMMAR_X3_HPP -#include #include #include #include @@ -55,7 +54,7 @@ using geojson_value_base = mapnik::util::variant; struct geojson_value : geojson_value_base { -#if MAPNIK_USE_INHERITING_CONSTRUCTORS +#if __cpp_inheriting_constructors >= 200802 using geojson_value_base::geojson_value_base; diff --git a/include/mapnik/json/json_value.hpp b/include/mapnik/json/json_value.hpp index 2157ce5956..c5ed036048 100644 --- a/include/mapnik/json/json_value.hpp +++ b/include/mapnik/json/json_value.hpp @@ -24,7 +24,6 @@ #define MAPNIK_JSON_JSON_VALUE_HPP // mapnik -#include #include #include // stl @@ -47,7 +46,7 @@ using json_value_base = mapnik::util::variant; struct json_value : json_value_base { -#if MAPNIK_USE_INHERITING_CONSTRUCTORS +#if __cpp_inheriting_constructors >= 200802 using json_value_base::json_value_base; From 0ef443def601c9c16117728ee2f3c47866f7c2e6 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 20 Nov 2020 20:16:27 +0100 Subject: [PATCH 005/141] now fix msvc compiler error. Why does msvc complain? --- include/mapnik/geometry.hpp | 2 +- include/mapnik/json/geojson_grammar_x3.hpp | 2 +- include/mapnik/json/json_value.hpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index f6e795de97..44b9931b46 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -59,7 +59,7 @@ struct geometry : geometry_base { using coordinate_type = T; -#if __cpp_inheriting_constructors >= 200802 +#if __cpp_inheriting_constructors >= 200802 && !defined (_MSC_VER) using geometry_base::geometry_base; diff --git a/include/mapnik/json/geojson_grammar_x3.hpp b/include/mapnik/json/geojson_grammar_x3.hpp index 3f44d10669..a4f7136374 100644 --- a/include/mapnik/json/geojson_grammar_x3.hpp +++ b/include/mapnik/json/geojson_grammar_x3.hpp @@ -54,7 +54,7 @@ using geojson_value_base = mapnik::util::variant; struct geojson_value : geojson_value_base { -#if __cpp_inheriting_constructors >= 200802 +#if __cpp_inheriting_constructors >= 200802 && !defined (_MSC_VER) using geojson_value_base::geojson_value_base; diff --git a/include/mapnik/json/json_value.hpp b/include/mapnik/json/json_value.hpp index c5ed036048..150a80f213 100644 --- a/include/mapnik/json/json_value.hpp +++ b/include/mapnik/json/json_value.hpp @@ -46,7 +46,7 @@ using json_value_base = mapnik::util::variant; struct json_value : json_value_base { -#if __cpp_inheriting_constructors >= 200802 +#if __cpp_inheriting_constructors >= 200802 && !defined (_MSC_VER) using json_value_base::json_value_base; From 597f023740f338cd17f35fae24e7aec6e64d9a45 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 20 Nov 2020 20:20:28 +0100 Subject: [PATCH 006/141] more cmake --- CMakeLists.txt | 82 +++++++++- deps/CMakeLists.txt | 2 + deps/agg/CMakeLists.txt | 20 +++ plugins/CMakeLists.txt | 2 +- plugins/input/CMakeLists.txt | 2 +- src/CMakeLists.txt | 284 +++++++++++++++++++++++++++++++++++ src/json/CMakeLists.txt | 34 +++++ src/wkt/CMakeLists.txt | 27 ++++ utils/CMakeLists.txt | 2 +- 9 files changed, 451 insertions(+), 4 deletions(-) create mode 100644 deps/CMakeLists.txt create mode 100644 deps/agg/CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 src/json/CMakeLists.txt create mode 100644 src/wkt/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index ecad3a171c..f369512877 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,4 +4,84 @@ project(mapnik HOMEPAGE_URL "https://mapnik.org/" DESCRIPTION "Mapnik is an open source toolkit for developing mapping applications" LANGUAGES CXX -) \ No newline at end of file +) + +option(BUILD_SHARED_LIBS ON) +option(USE_EXTERNAL_MAPBOX_GEOMETRY OFF) +option(USE_EXTERNAL_MAPBOX_POLYLABEL OFF) +option(USE_EXTERNAL_MAPBOX_PROTOZERO OFF) +option(USE_EXTERNAL_MAPBOX_VARIANT OFF) + +set(CXX_STANDARD 17) + +find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex program_options) +find_package(ICU REQUIRED COMPONENTS uc) + +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() + +add_library(mapnik-headers INTERFACE) +add_library(mapnik::headers ALIAS mapnik-headers) + +target_include_directories(mapnik-headers INTERFACE + $ + $ + ${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 + ICU::uc +) +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/ +) +add_subdirectory(deps) +add_subdirectory(src) +#add_subdirectory(utils) +#add_subdirectory(plugins) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt new file mode 100644 index 0000000000..69527cdfeb --- /dev/null +++ b/deps/CMakeLists.txt @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.15.0) +add_subdirectory(agg) \ No newline at end of file diff --git a/deps/agg/CMakeLists.txt b/deps/agg/CMakeLists.txt new file mode 100644 index 0000000000..ef505cdfac --- /dev/null +++ b/deps/agg/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.15.0) +project(agg) + +add_library(agg INTERFACE) +add_library(mapnik::agg ALIAS agg) + +target_include_directories(agg INTERFACE + $ + $ +) +target_link_libraries(agg INTERFACE mapnik::headers) + +install(TARGETS agg + EXPORT MapnikTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin + PUBLIC_HEADER DESTINATION include +) +# todo install headers diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 17e4ecbd76..f53de93d36 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,2 +1,2 @@ cmake_minimum_required(VERSION 3.15.0) -add_subdirectory(input) \ No newline at end of file +add_subdirectory(input) diff --git a/plugins/input/CMakeLists.txt b/plugins/input/CMakeLists.txt index edbb7c5e3b..8ad1e3986d 100644 --- a/plugins/input/CMakeLists.txt +++ b/plugins/input/CMakeLists.txt @@ -9,4 +9,4 @@ add_subdirectory(postgis) add_subdirectory(raster) add_subdirectory(shape) add_subdirectory(sqlite) -add_subdirectory(topojson) \ No newline at end of file +add_subdirectory(topojson) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000000..3c8e738e2f --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,284 @@ +cmake_minimum_required(VERSION 3.15.0) + + +add_subdirectory(json) +add_subdirectory(wkt) + +if(MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") +endif() + +set(MAPNIK_SOURCES + cairo_io.cpp + color_factory.cpp + color.cpp + config_error.cpp + conversions_numeric.cpp + conversions_string.cpp + dasharray_parser.cpp + datasource_cache_static.cpp + datasource_cache.cpp + debug.cpp + expression_grammar_x3.cpp + expression_node.cpp + expression_string.cpp + expression.cpp + feature_kv_iterator.cpp + feature_style_processor.cpp + feature_type_style.cpp + font_engine_freetype.cpp + font_set.cpp + fs.cpp + function_call.cpp + generate_image_filters.cpp + gradient.cpp + image_any.cpp + image_compositing.cpp + image_copy.cpp + image_filter_grammar_x3.cpp + image_options.cpp + image_reader.cpp + image_scaling.cpp + image_util_jpeg.cpp + image_util_png.cpp + image_util_tiff.cpp + image_util_webp.cpp + image_util.cpp + image_view_any.cpp + image_view.cpp + image.cpp + jpeg_reader.cpp + layer.cpp + libxml2_loader.cpp + load_map.cpp + map.cpp + mapped_memory_cache.cpp + marker_cache.cpp + marker_helpers.cpp + memory_datasource.cpp + palette.cpp + params.cpp + parse_image_filters.cpp + parse_path.cpp + parse_transform.cpp + path_expression_grammar_x3.cpp + plugin.cpp + png_reader.cpp + proj_transform.cpp + projection.cpp + rapidxml_loader.cpp + raster_colorizer.cpp + renderer_common.cpp + request.cpp + rule.cpp + save_map.cpp + scale_denominator.cpp + simplify.cpp + symbolizer_enumerations.cpp + symbolizer_keys.cpp + symbolizer.cpp + tiff_reader.cpp + transform_expression_grammar_x3.cpp + transform_expression.cpp + twkb.cpp + unicode.cpp + value.cpp + vertex_adapters.cpp + vertex_cache.cpp + warp.cpp + well_known_srs.cpp + wkb.cpp + xml_tree.cpp +) + +set(AGG_COMPILE_SRC + ../deps/agg/src/agg_arc.cpp + ../deps/agg/src/agg_arrowhead.cpp + ../deps/agg/src/agg_bezier_arc.cpp + ../deps/agg/src/agg_bspline.cpp + ../deps/agg/src/agg_curves.cpp + ../deps/agg/src/agg_embedded_raster_fonts.cpp + ../deps/agg/src/agg_gsv_text.cpp + ../deps/agg/src/agg_image_filters.cpp + ../deps/agg/src/agg_line_aa_basics.cpp + ../deps/agg/src/agg_line_profile_aa.cpp + ../deps/agg/src/agg_pixfmt_rgba.cpp + ../deps/agg/src/agg_rounded_rect.cpp + ../deps/agg/src/agg_sqrt_tables.cpp + ../deps/agg/src/agg_trans_affine.cpp + ../deps/agg/src/agg_trans_double_path.cpp + ../deps/agg/src/agg_trans_single_path.cpp + ../deps/agg/src/agg_trans_warp_magnifier.cpp + ../deps/agg/src/agg_vcgen_bspline.cpp + ../deps/agg/src/agg_vcgen_contour.cpp + ../deps/agg/src/agg_vcgen_dash.cpp + ../deps/agg/src/agg_vcgen_markers_term.cpp + ../deps/agg/src/agg_vcgen_stroke.cpp + ../deps/agg/src/agg_vpgen_clip_polygon.cpp + ../deps/agg/src/agg_vpgen_clip_polyline.cpp + ../deps/agg/src/agg_vpgen_segmentator.cpp +) + +set(AGG_SRC + agg/agg_renderer.cpp + agg/process_building_symbolizer.cpp + agg/process_debug_symbolizer.cpp + agg/process_dot_symbolizer.cpp + agg/process_group_symbolizer.cpp + agg/process_line_pattern_symbolizer.cpp + agg/process_line_symbolizer.cpp + agg/process_markers_symbolizer.cpp + agg/process_point_symbolizer.cpp + agg/process_polygon_pattern_symbolizer.cpp + agg/process_polygon_symbolizer.cpp + agg/process_raster_symbolizer.cpp + agg/process_shield_symbolizer.cpp + agg/process_text_symbolizer.cpp + ${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 +) + +set(CSS_SRC + css/css_color_grammar_x3.cpp + css/css_grammar_x3.cpp +) + +set(GEOMETRY_SRC + geometry/box2d.cpp + geometry/closest_point.cpp + geometry/envelope.cpp + geometry/interior.cpp + geometry/polylabel.cpp + geometry/reprojection.cpp +) + +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 +) + +set(GROUP_SRC + group/group_layout_manager.cpp + group/group_rule.cpp + group/group_symbolizer_helper.cpp +) + +set(RENDERER_COMMON_SRC + 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 +) + +set(SVG_SRC + 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 + + 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 +) + +set(TEXT_SRC + text/color_font_renderer.cpp + text/face.cpp + text/font_feature_settings.cpp + text/font_library.cpp + text/glyph_positions.cpp + text/itemizer.cpp + text/placement_finder.cpp + text/properties_util.cpp + text/renderer.cpp + text/scrptrun.cpp + text/symbolizer_helpers.cpp + text/text_layout.cpp + text/text_line.cpp + text/text_properties.cpp + + text/formatting/base.cpp + text/formatting/format.cpp + text/formatting/layout.cpp + text/formatting/list.cpp + text/formatting/registry.cpp + text/formatting/text.cpp + + text/placements/base.cpp + text/placements/dummy.cpp + text/placements/list.cpp + text/placements/registry.cpp + text/placements/simple.cpp +) + +set(UTIL_SRC + util/math.cpp + util/utf_conv_win.cpp +) + +set(COMPILE_SRC + ${MAPNIK_SOURCES} + ${AGG_SRC} + ${CAIRO_SRC} + ${CSS_SRC} + ${GEOMETRY_SRC} + ${GRID_SRC} + ${GROUP_SRC} + ${RENDERER_COMMON_SRC} + ${SVG_SRC} + ${TEXT_SRC} + ${UTIL_SRC} +) + +add_library(mapnik + ${COMPILE_SRC} +) + +target_compile_definitions(mapnik PRIVATE MAPNIK_EXPORTS) +target_link_libraries(mapnik PRIVATE + mapnik::headers + mapnik::agg +) + +install(TARGETS mapnik + EXPORT MapnikTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include/ + PUBLIC_HEADER DESTINATION include/ +) \ No newline at end of file diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt new file mode 100644 index 0000000000..f5cea0f774 --- /dev/null +++ b/src/json/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 3.15.0) + +add_library(json STATIC + extract_bounding_boxes_x3.cpp + feature_from_geojson.cpp + feature_grammar_x3.cpp + generic_json_grammar_x3.cpp + geojson_grammar_x3.cpp + geometry_from_geojson.cpp + mapnik_feature_to_geojson.cpp + mapnik_geometry_to_geojson.cpp + mapnik_json_generator_grammar.cpp + parse_feature.cpp + positions_grammar_x3.cpp + topojson_grammar_x3.cpp + unicode_string_grammar_x3.cpp +) +add_library(mapnik::json ALIAS json) + +target_include_directories(json PRIVATE + ${JPEG_INCLUDE_DIR} + ${LIBXML2_INCLUDE_DIR} + ${MAPBOX_POLYLABEL_INCLUDE_DIRS} + ${MAPBOX_GEOMETRY_INCLUDE_DIRS} + ${MAPBOX_VARIANT_INCLUDE_DIRS} +) +target_link_libraries(json PRIVATE mapnik::headers ${ICUU_LIB}) + +install(TARGETS json + EXPORT MapnikTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin +) \ No newline at end of file diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt new file mode 100644 index 0000000000..3725724f8b --- /dev/null +++ b/src/wkt/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.15.0) + + +add_library(wkt STATIC + geometry_to_wkt.cpp + mapnik_wkt_generator_grammar.cpp + wkt_factory.cpp + wkt_grammar_x3.cpp +) +add_library(mapnik::wkt ALIAS wkt) + +target_include_directories(wkt PRIVATE + ${MAPNIK_INCLUDE_PATH} + ${JPEG_INCLUDE_DIR} + ${LIBXML2_INCLUDE_DIR} + ${MAPBOX_POLYLABEL_INCLUDE_DIRS} + ${MAPBOX_GEOMETRY_INCLUDE_DIRS} + ${MAPBOX_VARIANT_INCLUDE_DIRS} +) +target_link_libraries(wkt PRIVATE mapnik::headers) + +install(TARGETS wkt + EXPORT MapnikTargets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin +) \ No newline at end of file diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index e2f28bb111..8ad98aeb5f 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -5,4 +5,4 @@ add_subdirectory(mapnik-render) add_subdirectory(ogrindex) add_subdirectory(pgsql2sqlite) add_subdirectory(shapeindex) -add_subdirectory(svg2png) \ No newline at end of file +add_subdirectory(svg2png) From 284507184ba2fc337f2d9a31d5a7c46300202328 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 20 Nov 2020 21:15:27 +0100 Subject: [PATCH 007/141] more cmake --- CMakeLists.txt | 55 +++++++++++++- cmake/FindCairo.cmake | 109 +++++++++++++++++++++++++++ src/CMakeLists.txt | 55 ++++++++------ src/json/CMakeLists.txt | 2 +- src/wkt/CMakeLists.txt | 2 +- utils/geometry_to_wkb/CMakeLists.txt | 8 ++ utils/mapnik-index/CMakeLists.txt | 10 +++ utils/mapnik-render/CMakeLists.txt | 7 ++ utils/ogrindex/CMakeLists.txt | 7 ++ utils/pgsql2sqlite/CMakeLists.txt | 10 +++ utils/shapeindex/CMakeLists.txt | 9 +++ utils/svg2png/CMakeLists.txt | 9 +++ 12 files changed, 256 insertions(+), 27 deletions(-) create mode 100644 cmake/FindCairo.cmake create mode 100644 utils/geometry_to_wkb/CMakeLists.txt create mode 100644 utils/mapnik-index/CMakeLists.txt create mode 100644 utils/mapnik-render/CMakeLists.txt create mode 100644 utils/ogrindex/CMakeLists.txt create mode 100644 utils/pgsql2sqlite/CMakeLists.txt create mode 100644 utils/shapeindex/CMakeLists.txt create mode 100644 utils/svg2png/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index f369512877..afb787b2de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/FindCairo.cmake b/cmake/FindCairo.cmake new file mode 100644 index 0000000000..5bf2d339dc --- /dev/null +++ b/cmake/FindCairo.cmake @@ -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 () \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3c8e738e2f..9918873590 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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/ -) \ No newline at end of file +) diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index f5cea0f774..c3b818387d 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -31,4 +31,4 @@ install(TARGETS json LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin -) \ No newline at end of file +) diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index 3725724f8b..82de6f9cff 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -24,4 +24,4 @@ install(TARGETS wkt LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin -) \ No newline at end of file +) diff --git a/utils/geometry_to_wkb/CMakeLists.txt b/utils/geometry_to_wkb/CMakeLists.txt new file mode 100644 index 0000000000..b721708bf5 --- /dev/null +++ b/utils/geometry_to_wkb/CMakeLists.txt @@ -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 +) \ No newline at end of file diff --git a/utils/mapnik-index/CMakeLists.txt b/utils/mapnik-index/CMakeLists.txt new file mode 100644 index 0000000000..1fe9717f51 --- /dev/null +++ b/utils/mapnik-index/CMakeLists.txt @@ -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 +) \ No newline at end of file diff --git a/utils/mapnik-render/CMakeLists.txt b/utils/mapnik-render/CMakeLists.txt new file mode 100644 index 0000000000..74f09aa1d8 --- /dev/null +++ b/utils/mapnik-render/CMakeLists.txt @@ -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 +) \ No newline at end of file diff --git a/utils/ogrindex/CMakeLists.txt b/utils/ogrindex/CMakeLists.txt new file mode 100644 index 0000000000..86edc72a7e --- /dev/null +++ b/utils/ogrindex/CMakeLists.txt @@ -0,0 +1,7 @@ +add_executable(ogrindex ogrindex.cpp) + +target_link_libraries(ogrindex PRIVATE mapnik::mapnik) +install(TARGETS ogrindex + EXPORT MapnikTargets + RUNTIME DESTINATION bin +) \ No newline at end of file diff --git a/utils/pgsql2sqlite/CMakeLists.txt b/utils/pgsql2sqlite/CMakeLists.txt new file mode 100644 index 0000000000..90db76f4f5 --- /dev/null +++ b/utils/pgsql2sqlite/CMakeLists.txt @@ -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 +) \ No newline at end of file diff --git a/utils/shapeindex/CMakeLists.txt b/utils/shapeindex/CMakeLists.txt new file mode 100644 index 0000000000..5a2f72ad75 --- /dev/null +++ b/utils/shapeindex/CMakeLists.txt @@ -0,0 +1,9 @@ +add_executable(shapeindex + shapeindex.cpp +) + +target_link_libraries(shapeindex PRIVATE mapnik::mapnik) +install(TARGETS shapeindex + EXPORT MapnikTargets + RUNTIME DESTINATION bin +) \ No newline at end of file diff --git a/utils/svg2png/CMakeLists.txt b/utils/svg2png/CMakeLists.txt new file mode 100644 index 0000000000..abf3de3ba7 --- /dev/null +++ b/utils/svg2png/CMakeLists.txt @@ -0,0 +1,9 @@ +add_executable(svg2png + svg2png.cpp +) + +target_link_libraries(svg2png PRIVATE mapnik::mapnik) +install(TARGETS svg2png + EXPORT MapnikTargets + RUNTIME DESTINATION bin +) \ No newline at end of file From fbce5dbe7bf73b1632edb6ca69e4d49df157526c Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 09:46:54 +0100 Subject: [PATCH 008/141] optional libraries --- CMakeLists.txt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index afb787b2de..fe01dcafc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,11 +19,12 @@ 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(harfbuzz CONFIG REQUIRED) +find_package(PNG) +find_package(JPEG) +find_package(TIFF) +find_package(WebP CONFIG) +find_package(LibXml2) find_package(Cairo) if(USE_EXTERNAL_MAPBOX_GEOMETRY) @@ -73,21 +74,25 @@ endif() if(PNG_FOUND) set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_PNG) + set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} PNG::PNG) message(STATUS "Using PNG") endif() if(JPEG_FOUND) set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_JPEG) + set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} JPEG::JPEG) message(STATUS "Using JPEG") endif() if(TIFF_FOUND) set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_TIFF) + set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} TIFF::TIFF) message(STATUS "Using TIFF") endif() if(WebP_FOUND) set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_WEBP) + set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} WebP::webp) message(STATUS "Using WEBP") endif() @@ -115,9 +120,7 @@ target_link_libraries(mapnik-headers INTERFACE Boost::filesystem ICU::uc Freetype::Freetype - PNG::PNG - TIFF::TIFF - JPEG::JPEG + harfbuzz::harfbuzz ${MAPNIK_OPTIONAL_LIBS} ) if(BUILD_SHARED_LIBS) From 99171ce419fde952f08cce20f010ddaf51d69a39 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 10:09:29 +0100 Subject: [PATCH 009/141] more options --- CMakeLists.txt | 51 +++++++++++++++++++++++++--------------------- src/CMakeLists.txt | 39 ++++++++++++++++------------------- 2 files changed, 46 insertions(+), 44 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fe01dcafc1..1a51415e7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,10 +9,16 @@ project(mapnik 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) -option(USE_EXTERNAL_MAPBOX_VARIANT OFF) +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) set(CXX_STANDARD 17) @@ -20,12 +26,6 @@ find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex program_opti find_package(ICU REQUIRED COMPONENTS uc) find_package(Freetype REQUIRED) find_package(harfbuzz CONFIG REQUIRED) -find_package(PNG) -find_package(JPEG) -find_package(TIFF) -find_package(WebP CONFIG) -find_package(LibXml2) -find_package(Cairo) if(USE_EXTERNAL_MAPBOX_GEOMETRY) find_path(MAPBOX_GEOMETRY_INCLUDE_DIRS "mapbox/geometry.hpp") @@ -66,40 +66,45 @@ endif() set(MAPNIK_COMPILE_DEFS "") set(MAPNIK_OPTIONAL_LIBS "") -if(LibXml2_FOUND) +if(USE_LIBXML2) + message(STATUS "Using LibXml2") + find_package(LibXml2 REQUIRED) 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) +if(USE_PNG) + message(STATUS "Using PNG") + find_package(PNG REQUIRED) set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_PNG) set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} PNG::PNG) - message(STATUS "Using PNG") endif() -if(JPEG_FOUND) +if(USE_JPEG) + message(STATUS "Using JPEG") + find_package(JPEG REQUIRED) set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_JPEG) set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} JPEG::JPEG) - message(STATUS "Using JPEG") endif() -if(TIFF_FOUND) +if(USE_TIFF) + find_package(TIFF REQUIRED) + message(STATUS "Using TIFF") set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_TIFF) set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} TIFF::TIFF) - message(STATUS "Using TIFF") endif() -if(WebP_FOUND) +if(USE_WEBP) + message(STATUS "Using WEBP") + find_package(WebP CONFIG REQUIRED) set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_WEBP) set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} WebP::webp) - message(STATUS "Using WEBP") endif() -if(Cairo_FOUND) +if(USE_CAIRO) + message(STATUS "Using Cairo renderer") + find_package(Cairo REQUIRED) 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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9918873590..a947f0cd51 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -88,6 +88,7 @@ set(MAPNIK_SOURCES wkb.cpp xml_tree.cpp ) +set(COMPILE_SRC ${MAPNIK_SOURCES}) set(AGG_COMPILE_SRC ../deps/agg/src/agg_arc.cpp @@ -116,7 +117,6 @@ set(AGG_COMPILE_SRC ../deps/agg/src/agg_vpgen_clip_polyline.cpp ../deps/agg/src/agg_vpgen_segmentator.cpp ) - set(AGG_SRC agg/agg_renderer.cpp agg/process_building_symbolizer.cpp @@ -134,8 +134,10 @@ set(AGG_SRC agg/process_text_symbolizer.cpp ${AGG_COMPILE_SRC} ) +list(APPEND COMPILE_SRC ${AGG_SRC}) -if(Cairo_FOUND) +if(USE_CAIRO) + message(STATUS "adding cairo renderer to compilation") set(CAIRO_SRC cairo/cairo_context.cpp cairo/cairo_render_vector.cpp @@ -152,12 +154,14 @@ if(Cairo_FOUND) cairo/process_raster_symbolizer.cpp cairo/process_text_symbolizer.cpp ) + list(APPEND COMPILE_SRC ${CAIRO_SRC}) endif() set(CSS_SRC css/css_color_grammar_x3.cpp css/css_grammar_x3.cpp ) +list(APPEND COMPILE_SRC ${CSS_SRC}) set(GEOMETRY_SRC geometry/box2d.cpp @@ -167,6 +171,7 @@ set(GEOMETRY_SRC geometry/polylabel.cpp geometry/reprojection.cpp ) +list(APPEND COMPILE_SRC ${GEOMETRY_SRC}) set(GRID_SRC grid/grid_renderer.cpp @@ -183,12 +188,14 @@ set(GRID_SRC grid/process_shield_symbolizer.cpp grid/process_text_symbolizer.cpp ) +list(APPEND COMPILE_SRC ${GRID_SRC}) 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 renderer_common/pattern_alignment.cpp @@ -197,6 +204,7 @@ set(RENDERER_COMMON_SRC renderer_common/render_pattern.cpp renderer_common/render_thunk_extractor.cpp ) +list(APPEND COMPILE_SRC ${RENDERER_COMMON_SRC}) set(SVG_SRC svg/svg_parser.cpp @@ -213,6 +221,7 @@ set(SVG_SRC svg/output/svg_output_grammars.cpp svg/output/svg_renderer.cpp ) +list(APPEND COMPILE_SRC ${SVG_SRC}) set(TEXT_SRC text/color_font_renderer.cpp @@ -243,34 +252,22 @@ set(TEXT_SRC text/placements/registry.cpp text/placements/simple.cpp ) +list(APPEND COMPILE_SRC ${TEXT_SRC}) set(UTIL_SRC util/math.cpp util/utf_conv_win.cpp ) +list(APPEND COMPILE_SRC ${UTIL_SRC}) -if(LibXml2_FOUND) - set(COMPILE_SRC ${COMPILE_SRC} libxml2_loader.cpp) +if(USE_LIBXML2) + message(STATUS "adding libxml2_loader to compilation") + list(APPEND COMPILE_SRC libxml2_loader.cpp) else() - set(COMPILE_SRC ${COMPILE_SRC} rapidxml_loader.cpp) + message(STATUS "adding rapidxml_loader to compilation") + list(APPEND COMPILE_SRC rapidxml_loader.cpp) endif() - - -set(COMPILE_SRC - ${MAPNIK_SOURCES} - ${AGG_SRC} - ${CAIRO_SRC} - ${CSS_SRC} - ${GEOMETRY_SRC} - ${GRID_SRC} - ${GROUP_SRC} - ${RENDERER_COMMON_SRC} - ${SVG_SRC} - ${TEXT_SRC} - ${UTIL_SRC} -) - add_library(mapnik ${COMPILE_SRC}) add_library(mapnik::mapnik ALIAS mapnik) From 2d9046878d4732bd1ccb9fc99399b5c732ba731b Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 11:34:45 +0100 Subject: [PATCH 010/141] more cmake --- CMakeLists.txt | 114 ++++++++++++++++++++------ cmake/MapnikConfig.cmake.in | 5 ++ plugins/input/CMakeLists.txt | 55 ++++++++++--- plugins/input/csv/CMakeLists.txt | 31 +++++++ plugins/input/gdal/CMakeLists.txt | 29 +++++++ plugins/input/geobuf/CMakeLists.txt | 25 ++++++ plugins/input/geojson/CMakeLists.txt | 29 +++++++ plugins/input/ogr/CMakeLists.txt | 31 +++++++ plugins/input/pgraster/CMakeLists.txt | 30 +++++++ plugins/input/postgis/CMakeLists.txt | 29 +++++++ plugins/input/raster/CMakeLists.txt | 27 ++++++ plugins/input/shape/CMakeLists.txt | 30 +++++++ plugins/input/sqlite/CMakeLists.txt | 29 +++++++ plugins/input/topojson/CMakeLists.txt | 27 ++++++ src/CMakeLists.txt | 2 +- utils/geometry_to_wkb/CMakeLists.txt | 2 +- utils/mapnik-index/CMakeLists.txt | 9 +- utils/mapnik-render/CMakeLists.txt | 6 +- utils/ogrindex/CMakeLists.txt | 2 +- utils/pgsql2sqlite/CMakeLists.txt | 2 +- utils/shapeindex/CMakeLists.txt | 2 +- utils/svg2png/CMakeLists.txt | 2 +- 22 files changed, 473 insertions(+), 45 deletions(-) create mode 100644 cmake/MapnikConfig.cmake.in create mode 100644 plugins/input/csv/CMakeLists.txt create mode 100644 plugins/input/gdal/CMakeLists.txt create mode 100644 plugins/input/geobuf/CMakeLists.txt create mode 100644 plugins/input/geojson/CMakeLists.txt create mode 100644 plugins/input/ogr/CMakeLists.txt create mode 100644 plugins/input/pgraster/CMakeLists.txt create mode 100644 plugins/input/postgis/CMakeLists.txt create mode 100644 plugins/input/raster/CMakeLists.txt create mode 100644 plugins/input/shape/CMakeLists.txt create mode 100644 plugins/input/sqlite/CMakeLists.txt create mode 100644 plugins/input/topojson/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a51415e7e..e275491b51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,18 @@ option(USE_WEBP "Adds webp support" ON) option(USE_LIBXML2 "Adds libxml2 support" ON) option(USE_CAIRO "Adds the cairo renderer" ON) +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) + set(CXX_STANDARD 17) find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex program_options) @@ -28,36 +40,61 @@ find_package(Freetype REQUIRED) find_package(harfbuzz CONFIG REQUIRED) if(USE_EXTERNAL_MAPBOX_GEOMETRY) - find_path(MAPBOX_GEOMETRY_INCLUDE_DIRS "mapbox/geometry.hpp") + # provide a way to specify the include dirs with the CACHE VARIABLES + 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() else() - set(MAPBOX_GEOMETRY_INCLUDE_DIRS deps/mapbox/geometry/include) + set(MAPBOX_GEOMETRY_INCLUDE_DIRS + $ + $ + ) endif() if(NOT MAPBOX_GEOMETRY_INCLUDE_DIRS) - message(FATAL_ERROR "Set MAPBOX_GEOMETRY_INCLUDE_DIRS to the mapbox/geometry.hpp include dir") + message(FATAL_ERROR "Set -DMAPBOX_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") + 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() else() - set(MAPBOX_POLYLABEL_INCLUDE_DIRS deps/mapbox/polylabel/include) + set(MAPBOX_POLYLABEL_INCLUDE_DIRS + $ + $ + ) 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") + 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() else() - set(MAPBOX_PROTOZERO_INCLUDE_DIRS deps/mapbox/protozero/include) + set(MAPBOX_PROTOZERO_INCLUDE_DIRS + $ + $ + ) 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") + 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() else() - set(MAPBOX_VARIANT_INCLUDE_DIRS deps/mapbox/variant/include) + set(MAPBOX_VARIANT_INCLUDE_DIRS + $ + $ + ) endif() if(NOT MAPBOX_VARIANT_INCLUDE_DIRS) message(FATAL_ERROR "Set MAPBOX_VARIANT_INCLUDE_DIRS to the mapbox/variant include dir") @@ -69,47 +106,48 @@ set(MAPNIK_OPTIONAL_LIBS "") if(USE_LIBXML2) message(STATUS "Using LibXml2") find_package(LibXml2 REQUIRED) - set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_LIBXML2) - set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} LibXml2::LibXml2) + list(APPEND MAPNIK_COMPILE_DEFS HAVE_LIBXML2) + list(APPEND MAPNIK_OPTIONAL_LIBS LibXml2::LibXml2) endif() if(USE_PNG) message(STATUS "Using PNG") find_package(PNG REQUIRED) - set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_PNG) - set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} PNG::PNG) + list(APPEND MAPNIK_COMPILE_DEFS HAVE_PNG) + list(APPEND MAPNIK_OPTIONAL_LIBS PNG::PNG) endif() if(USE_JPEG) message(STATUS "Using JPEG") find_package(JPEG REQUIRED) - set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_JPEG) - set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} JPEG::JPEG) + list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG) + list(APPEND MAPNIK_OPTIONAL_LIBS JPEG::JPEG) endif() if(USE_TIFF) find_package(TIFF REQUIRED) message(STATUS "Using TIFF") - set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_TIFF) - set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} TIFF::TIFF) + list(APPEND MAPNIK_COMPILE_DEFS HAVE_TIFF) + list(APPEND MAPNIK_OPTIONAL_LIBS TIFF::TIFF) endif() if(USE_WEBP) message(STATUS "Using WEBP") find_package(WebP CONFIG REQUIRED) - set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_WEBP) - set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} WebP::webp) + list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP) + list(APPEND MAPNIK_OPTIONAL_LIBS WebP::webp) endif() if(USE_CAIRO) message(STATUS "Using Cairo renderer") find_package(Cairo REQUIRED) - set(MAPNIK_COMPILE_DEFS ${MAPNIK_COMPILE_DEFS} HAVE_CAIRO) - set(MAPNIK_OPTIONAL_LIBS ${MAPNIK_OPTIONAL_LIBS} Cairo::Cairo) + list(APPEND MAPNIK_COMPILE_DEFS HAVE_CAIRO) + list(APPEND MAPNIK_OPTIONAL_LIBS Cairo::Cairo) endif() add_library(mapnik-headers INTERFACE) add_library(mapnik::headers ALIAS mapnik-headers) +# todo: mapbox includes need to included private. target_include_directories(mapnik-headers INTERFACE $ $ @@ -117,7 +155,8 @@ target_include_directories(mapnik-headers INTERFACE ${MAPBOX_POLYLABEL_INCLUDE_DIRS} ${MAPBOX_VARIANT_INCLUDE_DIRS} ${MAPBOX_PROTOZERO_INCLUDE_DIRS} - deps + $ + $ ) target_link_libraries(mapnik-headers INTERFACE Boost::boost @@ -128,9 +167,7 @@ target_link_libraries(mapnik-headers INTERFACE harfbuzz::harfbuzz ${MAPNIK_OPTIONAL_LIBS} ) -if(BUILD_SHARED_LIBS) - target_compile_definitions(mapnik-headers INTERFACE MAPNIK_EXPORTS) -endif() +target_compile_definitions(mapnik-headers INTERFACE ${MAPNIK_COMPILE_DEFS}) install(TARGETS mapnik-headers EXPORT MapnikTargets @@ -143,6 +180,31 @@ install(TARGETS mapnik-headers add_subdirectory(deps) add_subdirectory(src) -add_subdirectory(utils) +add_subdirectory(plugins) +#add_subdirectory(utils) #add_subdirectory(utils) #add_subdirectory(plugins) + + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfigVersion.cmake" + VERSION ${PROJECT_VERSION} + COMPATIBILITY SameMajorVersion +) + +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/MapnikConfig.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfig.cmake" + INSTALL_DESTINATION lib/cmake/mapnik +) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfigVersion.cmake" + DESTINATION lib/cmake/mapnik +) +install(EXPORT MapnikTargets + FILE MapnikTargets.cmake + NAMESPACE mapnik:: + DESTINATION lib/cmake/mapnik +) diff --git a/cmake/MapnikConfig.cmake.in b/cmake/MapnikConfig.cmake.in new file mode 100644 index 0000000000..db991109b6 --- /dev/null +++ b/cmake/MapnikConfig.cmake.in @@ -0,0 +1,5 @@ +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/MapnikTargets.cmake") + +check_required_components(mapnik) \ No newline at end of file diff --git a/plugins/input/CMakeLists.txt b/plugins/input/CMakeLists.txt index 8ad1e3986d..78250545b4 100644 --- a/plugins/input/CMakeLists.txt +++ b/plugins/input/CMakeLists.txt @@ -1,12 +1,45 @@ cmake_minimum_required(VERSION 3.15.0) -add_subdirectory(csv) -add_subdirectory(gdal) -add_subdirectory(geobuf) -add_subdirectory(geojson) -add_subdirectory(ogr) -add_subdirectory(pgraster) -add_subdirectory(postgis) -add_subdirectory(raster) -add_subdirectory(shape) -add_subdirectory(sqlite) -add_subdirectory(topojson) +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/plugins/input/csv/CMakeLists.txt b/plugins/input/csv/CMakeLists.txt new file mode 100644 index 0000000000..6d3ffe272d --- /dev/null +++ b/plugins/input/csv/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.15.0) +project(input-csv) + +add_library(input-csv SHARED + csv_datasource.cpp + csv_featureset.cpp + csv_index_featureset.cpp + csv_inline_featureset.cpp + csv_utils.cpp +) +add_library(mapnik::plugin::input::csv ALIAS input-csv) + +target_link_libraries(input-csv PRIVATE + mapnik::headers + mapnik::mapnik + mapnik::wkt + mapnik::json +) +set_target_properties(input-csv PROPERTIES PREFIX "") +set_target_properties(input-csv PROPERTIES OUTPUT_NAME "csv") +set_target_properties(input-csv PROPERTIES SUFFIX ".input") +#install(TARGETS input-csv DESTINATION bin/plugins/input) + +install(TARGETS input-csv + EXPORT MapnikTargets + LIBRARY DESTINATION lib/plugins/input + ARCHIVE DESTINATION lib/plugins/input + RUNTIME DESTINATION bin/plugins/input + INCLUDES DESTINATION . + PUBLIC_HEADER DESTINATION . +) \ No newline at end of file diff --git a/plugins/input/gdal/CMakeLists.txt b/plugins/input/gdal/CMakeLists.txt new file mode 100644 index 0000000000..90758ec4e0 --- /dev/null +++ b/plugins/input/gdal/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.15.0) +project(input-gdal) + +find_package(GDAL REQUIRED) + +add_library(input-gdal SHARED + gdal_datasource.cpp + gdal_featureset.cpp +) +add_library(mapnik::plugin::input::gdal ALIAS input-gdal) + +target_include_directories(input-gdal PRIVATE ${GDAL_INCLUDE_DIR}) +target_link_libraries(input-gdal PRIVATE + mapnik::headers + mapnik::mapnik + ${GDAL_LIBRARY} +) +set_target_properties(input-gdal PROPERTIES PREFIX "") +set_target_properties(input-gdal PROPERTIES OUTPUT_NAME "gdal") +set_target_properties(input-gdal PROPERTIES SUFFIX ".input") + +install(TARGETS input-gdal + EXPORT MapnikTargets + LIBRARY DESTINATION lib/plugins/input + ARCHIVE DESTINATION lib/plugins/input + RUNTIME DESTINATION bin/plugins/input + INCLUDES DESTINATION . + PUBLIC_HEADER DESTINATION . +) diff --git a/plugins/input/geobuf/CMakeLists.txt b/plugins/input/geobuf/CMakeLists.txt new file mode 100644 index 0000000000..c325e6109f --- /dev/null +++ b/plugins/input/geobuf/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.15.0) +project(input-geobuf) + +add_library(input-geobuf SHARED + geobuf_datasource.cpp + geobuf_featureset.cpp +) +add_library(mapnik::plugin::input::geobuf ALIAS input-geobuf) + +target_link_libraries(input-geobuf PRIVATE + mapnik::headers + mapnik::mapnik +) +set_target_properties(input-geobuf PROPERTIES PREFIX "") +set_target_properties(input-geobuf PROPERTIES OUTPUT_NAME "geobuf") +set_target_properties(input-geobuf PROPERTIES SUFFIX ".input") + +install(TARGETS input-geobuf + EXPORT MapnikTargets + LIBRARY DESTINATION lib/plugins/input + ARCHIVE DESTINATION lib/plugins/input + RUNTIME DESTINATION bin/plugins/input + INCLUDES DESTINATION . + PUBLIC_HEADER DESTINATION . +) diff --git a/plugins/input/geojson/CMakeLists.txt b/plugins/input/geojson/CMakeLists.txt new file mode 100644 index 0000000000..7243eb7239 --- /dev/null +++ b/plugins/input/geojson/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.15.0) +project(input-geojson) + +add_library(input-geojson SHARED + geojson_datasource.cpp + geojson_featureset.cpp + geojson_index_featureset.cpp + geojson_memory_index_featureset.cpp +) +add_library(mapnik::plugin::input::geojson ALIAS input-geojson) + +target_link_libraries(input-geojson PRIVATE + mapnik::headers + mapnik::mapnik + mapnik::json +) + +set_target_properties(input-geojson PROPERTIES PREFIX "") +set_target_properties(input-geojson PROPERTIES OUTPUT_NAME "geojson") +set_target_properties(input-geojson PROPERTIES SUFFIX ".input") + +install(TARGETS input-geojson + EXPORT MapnikTargets + LIBRARY DESTINATION lib/plugins/input + ARCHIVE DESTINATION lib/plugins/input + RUNTIME DESTINATION bin/plugins/input + INCLUDES DESTINATION . + PUBLIC_HEADER DESTINATION . +) diff --git a/plugins/input/ogr/CMakeLists.txt b/plugins/input/ogr/CMakeLists.txt new file mode 100644 index 0000000000..8311175faa --- /dev/null +++ b/plugins/input/ogr/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required(VERSION 3.15.0) +project(input-ogr) + +find_package(GDAL REQUIRED) + +add_library(input-ogr SHARED + ogr_converter.cpp + ogr_datasource.cpp + ogr_featureset.cpp + ogr_index_featureset.cpp +) +add_library(mapnik::plugin::input::ogr ALIAS input-ogr) + +target_include_directories(input-ogr PRIVATE ${GDAL_INCLUDE_DIR}) +target_link_libraries(input-ogr PRIVATE + mapnik::headers + mapnik::mapnik + ${GDAL_LIBRARY} +) +set_target_properties(input-ogr PROPERTIES PREFIX "") +set_target_properties(input-ogr PROPERTIES OUTPUT_NAME "ogr") +set_target_properties(input-ogr PROPERTIES SUFFIX ".input") + +install(TARGETS input-ogr + EXPORT MapnikTargets + LIBRARY DESTINATION lib/plugins/input + ARCHIVE DESTINATION lib/plugins/input + RUNTIME DESTINATION bin/plugins/input + INCLUDES DESTINATION . + PUBLIC_HEADER DESTINATION . +) diff --git a/plugins/input/pgraster/CMakeLists.txt b/plugins/input/pgraster/CMakeLists.txt new file mode 100644 index 0000000000..40b35fd6f3 --- /dev/null +++ b/plugins/input/pgraster/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.15.0) +project(input-pgraster) + +find_package(PostgreSQL REQUIRED) + +add_library(input-pgraster SHARED + pgraster_datasource.cpp + pgraster_featureset.cpp + pgraster_wkb_reader.cpp +) +add_library(mapnik::plugin::input::pgraster ALIAS input-pgraster) + + +target_link_libraries(input-pgraster PRIVATE + mapnik::headers + mapnik::mapnik + PostgreSQL::PostgreSQL +) +set_target_properties(input-pgraster PROPERTIES PREFIX "") +set_target_properties(input-pgraster PROPERTIES OUTPUT_NAME "pgraster") +set_target_properties(input-pgraster PROPERTIES SUFFIX ".input") + +install(TARGETS input-pgraster + EXPORT MapnikTargets + LIBRARY DESTINATION lib/plugins/input + ARCHIVE DESTINATION lib/plugins/input + RUNTIME DESTINATION bin/plugins/input + INCLUDES DESTINATION . + PUBLIC_HEADER DESTINATION . +) diff --git a/plugins/input/postgis/CMakeLists.txt b/plugins/input/postgis/CMakeLists.txt new file mode 100644 index 0000000000..2c4cc37d70 --- /dev/null +++ b/plugins/input/postgis/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.15.0) +project(input-postgis) + +find_package(PostgreSQL REQUIRED) + +add_library(input-postgis SHARED + postgis_datasource.cpp + postgis_featureset.cpp +) +add_library(mapnik::plugin::input::postgis ALIAS input-postgis) + +target_link_libraries(input-postgis PRIVATE + mapnik::headers + mapnik::mapnik + PostgreSQL::PostgreSQL +) + +set_target_properties(input-postgis PROPERTIES PREFIX "") +set_target_properties(input-postgis PROPERTIES OUTPUT_NAME "postgis") +set_target_properties(input-postgis PROPERTIES SUFFIX ".input") + +install(TARGETS input-postgis + EXPORT MapnikTargets + LIBRARY DESTINATION lib/plugins/input + ARCHIVE DESTINATION lib/plugins/input + RUNTIME DESTINATION bin/plugins/input + INCLUDES DESTINATION . + PUBLIC_HEADER DESTINATION . +) diff --git a/plugins/input/raster/CMakeLists.txt b/plugins/input/raster/CMakeLists.txt new file mode 100644 index 0000000000..22c5d203df --- /dev/null +++ b/plugins/input/raster/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.15.0) +project(input-raster) + +add_library(input-raster SHARED + raster_datasource.cpp + raster_featureset.cpp + raster_info.cpp +) +add_library(mapnik::plugin::input::raster ALIAS input-raster) + +target_link_libraries(input-raster PRIVATE + mapnik::headers + mapnik::mapnik +) + +set_target_properties(input-raster PROPERTIES PREFIX "") +set_target_properties(input-raster PROPERTIES OUTPUT_NAME "raster") +set_target_properties(input-raster PROPERTIES SUFFIX ".input") + +install(TARGETS input-raster + EXPORT MapnikTargets + LIBRARY DESTINATION lib/plugins/input + ARCHIVE DESTINATION lib/plugins/input + RUNTIME DESTINATION bin/plugins/input + INCLUDES DESTINATION . + PUBLIC_HEADER DESTINATION . +) diff --git a/plugins/input/shape/CMakeLists.txt b/plugins/input/shape/CMakeLists.txt new file mode 100644 index 0000000000..8b73af6c81 --- /dev/null +++ b/plugins/input/shape/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.15.0) +project(input-shape) + +add_library(input-shape SHARED + dbfile.cpp + dbf_test.cpp + shape_datasource.cpp + shape_featureset.cpp + shape_index_featureset.cpp + shape_io.cpp shape_utils.cpp +) +add_library(mapnik::plugin::input::shape ALIAS input-shape) + +target_link_libraries(input-shape PRIVATE + mapnik::headers + mapnik::mapnik +) + +set_target_properties(input-shape PROPERTIES PREFIX "") +set_target_properties(input-shape PROPERTIES OUTPUT_NAME "shape") +set_target_properties(input-shape PROPERTIES SUFFIX ".input") + +install(TARGETS input-shape + EXPORT MapnikTargets + LIBRARY DESTINATION lib/plugins/input + ARCHIVE DESTINATION lib/plugins/input + RUNTIME DESTINATION bin/plugins/input + INCLUDES DESTINATION . + PUBLIC_HEADER DESTINATION . +) diff --git a/plugins/input/sqlite/CMakeLists.txt b/plugins/input/sqlite/CMakeLists.txt new file mode 100644 index 0000000000..a4913fc7cc --- /dev/null +++ b/plugins/input/sqlite/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.15.0) +project(input-sqlite) + +find_package(SQLite3 REQUIRED) + +add_library(input-sqlite SHARED + sqlite_datasource.cpp + sqlite_featureset.cpp +) +add_library(mapnik::plugin::input::sqlite ALIAS input-sqlite) + +target_link_libraries(input-sqlite PRIVATE + mapnik::headers + mapnik::mapnik + SQLite::SQLite3 +) + +set_target_properties(input-sqlite PROPERTIES PREFIX "") +set_target_properties(input-sqlite PROPERTIES OUTPUT_NAME "sqlite") +set_target_properties(input-sqlite PROPERTIES SUFFIX ".input") + +install(TARGETS input-sqlite + EXPORT MapnikTargets + LIBRARY DESTINATION lib/plugins/input + ARCHIVE DESTINATION lib/plugins/input + RUNTIME DESTINATION bin/plugins/input + INCLUDES DESTINATION . + PUBLIC_HEADER DESTINATION . +) diff --git a/plugins/input/topojson/CMakeLists.txt b/plugins/input/topojson/CMakeLists.txt new file mode 100644 index 0000000000..93dc4968ea --- /dev/null +++ b/plugins/input/topojson/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.15.0) +project(input-topojson) + +add_library(input-topojson SHARED + topojson_datasource.cpp + topojson_featureset.cpp +) +add_library(mapnik::plugin::input::topojson ALIAS input-topojson) + +target_link_libraries(input-topojson PRIVATE + mapnik::headers + mapnik::mapnik + mapnik::json +) + +set_target_properties(input-topojson PROPERTIES PREFIX "") +set_target_properties(input-topojson PROPERTIES OUTPUT_NAME "topojson") +set_target_properties(input-topojson PROPERTIES SUFFIX ".input") + +install(TARGETS input-topojson + EXPORT MapnikTargets + LIBRARY DESTINATION lib/plugins/input + ARCHIVE DESTINATION lib/plugins/input + RUNTIME DESTINATION bin/plugins/input + INCLUDES DESTINATION . + PUBLIC_HEADER DESTINATION . +) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a947f0cd51..dddba92782 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -272,7 +272,7 @@ add_library(mapnik ${COMPILE_SRC}) add_library(mapnik::mapnik ALIAS mapnik) -target_compile_definitions(mapnik PRIVATE ${MAPNIK_EXPORTS} ${MAPNIK_COMPILE_DEFS}) +target_compile_definitions(mapnik PRIVATE MAPNIK_EXPORTS) target_link_libraries(mapnik PRIVATE mapnik::headers mapnik::agg diff --git a/utils/geometry_to_wkb/CMakeLists.txt b/utils/geometry_to_wkb/CMakeLists.txt index b721708bf5..12cc699a3c 100644 --- a/utils/geometry_to_wkb/CMakeLists.txt +++ b/utils/geometry_to_wkb/CMakeLists.txt @@ -1,6 +1,6 @@ add_executable(geometry_to_wkb main.cpp) -target_link_libraries(geometry_to_wkb PRIVATE mapnik::mapnik) +target_link_libraries(geometry_to_wkb PRIVATE mapnik::headers mapnik::mapnik) install(TARGETS geometry_to_wkb EXPORT MapnikTargets diff --git a/utils/mapnik-index/CMakeLists.txt b/utils/mapnik-index/CMakeLists.txt index 1fe9717f51..b06de87b2c 100644 --- a/utils/mapnik-index/CMakeLists.txt +++ b/utils/mapnik-index/CMakeLists.txt @@ -2,8 +2,15 @@ add_executable(mapnik-index mapnik-index.cpp process_csv_file.cpp process_geojson_file_x3.cpp + ../../plugins/input/csv/csv_utils.cpp # this project depends on this file +) +target_link_libraries(mapnik-index PRIVATE + mapnik::headers + mapnik::mapnik + mapnik::json + mapnik::wkt + Boost::program_options ) -target_link_libraries(mapnik-index PRIVATE mapnik::mapnik) install(TARGETS mapnik-index EXPORT MapnikTargets RUNTIME DESTINATION bin diff --git a/utils/mapnik-render/CMakeLists.txt b/utils/mapnik-render/CMakeLists.txt index 74f09aa1d8..0e2e6cd107 100644 --- a/utils/mapnik-render/CMakeLists.txt +++ b/utils/mapnik-render/CMakeLists.txt @@ -1,6 +1,10 @@ add_executable(mapnik-render mapnik-render.cpp) -target_link_libraries(mapnik-render PRIVATE mapnik::mapnik) +target_link_libraries(mapnik-render PRIVATE + mapnik::headers + mapnik::mapnik + Boost::program_options +) install(TARGETS mapnik-render EXPORT MapnikTargets RUNTIME DESTINATION bin diff --git a/utils/ogrindex/CMakeLists.txt b/utils/ogrindex/CMakeLists.txt index 86edc72a7e..0575f26b7b 100644 --- a/utils/ogrindex/CMakeLists.txt +++ b/utils/ogrindex/CMakeLists.txt @@ -1,6 +1,6 @@ add_executable(ogrindex ogrindex.cpp) -target_link_libraries(ogrindex PRIVATE mapnik::mapnik) +target_link_libraries(ogrindex PRIVATE mapnik::headers mapnik::mapnik) install(TARGETS ogrindex EXPORT MapnikTargets RUNTIME DESTINATION bin diff --git a/utils/pgsql2sqlite/CMakeLists.txt b/utils/pgsql2sqlite/CMakeLists.txt index 90db76f4f5..29569a904c 100644 --- a/utils/pgsql2sqlite/CMakeLists.txt +++ b/utils/pgsql2sqlite/CMakeLists.txt @@ -3,7 +3,7 @@ add_executable(pgsql2sqlite sqlite.cpp ) -target_link_libraries(pgsql2sqlite PRIVATE mapnik::mapnik) +target_link_libraries(pgsql2sqlite PRIVATE mapnik::headers mapnik::mapnik) install(TARGETS pgsql2sqlite EXPORT MapnikTargets RUNTIME DESTINATION bin diff --git a/utils/shapeindex/CMakeLists.txt b/utils/shapeindex/CMakeLists.txt index 5a2f72ad75..15ebf477c1 100644 --- a/utils/shapeindex/CMakeLists.txt +++ b/utils/shapeindex/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(shapeindex shapeindex.cpp ) -target_link_libraries(shapeindex PRIVATE mapnik::mapnik) +target_link_libraries(shapeindex PRIVATE mapnik::headers mapnik::mapnik) install(TARGETS shapeindex EXPORT MapnikTargets RUNTIME DESTINATION bin diff --git a/utils/svg2png/CMakeLists.txt b/utils/svg2png/CMakeLists.txt index abf3de3ba7..feb84e80aa 100644 --- a/utils/svg2png/CMakeLists.txt +++ b/utils/svg2png/CMakeLists.txt @@ -2,7 +2,7 @@ add_executable(svg2png svg2png.cpp ) -target_link_libraries(svg2png PRIVATE mapnik::mapnik) +target_link_libraries(svg2png PRIVATE mapnik::headers mapnik::mapnik) install(TARGETS svg2png EXPORT MapnikTargets RUNTIME DESTINATION bin From 8b640b1d7b0bebbc57305c0e197555941ebb8394 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 11:40:55 +0100 Subject: [PATCH 011/141] remove plugins from generated targets; install includes --- CMakeLists.txt | 15 +++++++++------ plugins/input/csv/CMakeLists.txt | 3 --- plugins/input/gdal/CMakeLists.txt | 3 --- plugins/input/geobuf/CMakeLists.txt | 3 --- plugins/input/geojson/CMakeLists.txt | 3 --- plugins/input/ogr/CMakeLists.txt | 3 --- plugins/input/pgraster/CMakeLists.txt | 3 --- plugins/input/postgis/CMakeLists.txt | 3 --- plugins/input/raster/CMakeLists.txt | 3 --- plugins/input/shape/CMakeLists.txt | 3 --- plugins/input/sqlite/CMakeLists.txt | 5 +---- plugins/input/topojson/CMakeLists.txt | 3 --- 12 files changed, 10 insertions(+), 40 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e275491b51..16c4704788 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,11 +144,11 @@ if(USE_CAIRO) list(APPEND MAPNIK_OPTIONAL_LIBS Cairo::Cairo) endif() -add_library(mapnik-headers INTERFACE) -add_library(mapnik::headers ALIAS mapnik-headers) +add_library(headers INTERFACE) +add_library(mapnik::headers ALIAS headers) # todo: mapbox includes need to included private. -target_include_directories(mapnik-headers INTERFACE +target_include_directories(headers INTERFACE $ $ ${MAPBOX_GEOMETRY_INCLUDE_DIRS} @@ -158,7 +158,7 @@ target_include_directories(mapnik-headers INTERFACE $ $ ) -target_link_libraries(mapnik-headers INTERFACE +target_link_libraries(headers INTERFACE Boost::boost Boost::regex Boost::filesystem @@ -167,9 +167,9 @@ target_link_libraries(mapnik-headers INTERFACE harfbuzz::harfbuzz ${MAPNIK_OPTIONAL_LIBS} ) -target_compile_definitions(mapnik-headers INTERFACE ${MAPNIK_COMPILE_DEFS}) +target_compile_definitions(headers INTERFACE ${MAPNIK_COMPILE_DEFS}) -install(TARGETS mapnik-headers +install(TARGETS headers EXPORT MapnikTargets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib @@ -208,3 +208,6 @@ install(EXPORT MapnikTargets NAMESPACE mapnik:: DESTINATION lib/cmake/mapnik ) + +install(DIRECTORY include/ DESTINATION include) +install(DIRECTORY deps/agg/include/ DESTINATION include) \ No newline at end of file diff --git a/plugins/input/csv/CMakeLists.txt b/plugins/input/csv/CMakeLists.txt index 6d3ffe272d..4597cee156 100644 --- a/plugins/input/csv/CMakeLists.txt +++ b/plugins/input/csv/CMakeLists.txt @@ -22,10 +22,7 @@ set_target_properties(input-csv PROPERTIES SUFFIX ".input") #install(TARGETS input-csv DESTINATION bin/plugins/input) install(TARGETS input-csv - EXPORT MapnikTargets LIBRARY DESTINATION lib/plugins/input ARCHIVE DESTINATION lib/plugins/input RUNTIME DESTINATION bin/plugins/input - INCLUDES DESTINATION . - PUBLIC_HEADER DESTINATION . ) \ No newline at end of file diff --git a/plugins/input/gdal/CMakeLists.txt b/plugins/input/gdal/CMakeLists.txt index 90758ec4e0..4c2919cc11 100644 --- a/plugins/input/gdal/CMakeLists.txt +++ b/plugins/input/gdal/CMakeLists.txt @@ -20,10 +20,7 @@ set_target_properties(input-gdal PROPERTIES OUTPUT_NAME "gdal") set_target_properties(input-gdal PROPERTIES SUFFIX ".input") install(TARGETS input-gdal - EXPORT MapnikTargets LIBRARY DESTINATION lib/plugins/input ARCHIVE DESTINATION lib/plugins/input RUNTIME DESTINATION bin/plugins/input - INCLUDES DESTINATION . - PUBLIC_HEADER DESTINATION . ) diff --git a/plugins/input/geobuf/CMakeLists.txt b/plugins/input/geobuf/CMakeLists.txt index c325e6109f..75bd7af2a8 100644 --- a/plugins/input/geobuf/CMakeLists.txt +++ b/plugins/input/geobuf/CMakeLists.txt @@ -16,10 +16,7 @@ set_target_properties(input-geobuf PROPERTIES OUTPUT_NAME "geobuf") set_target_properties(input-geobuf PROPERTIES SUFFIX ".input") install(TARGETS input-geobuf - EXPORT MapnikTargets LIBRARY DESTINATION lib/plugins/input ARCHIVE DESTINATION lib/plugins/input RUNTIME DESTINATION bin/plugins/input - INCLUDES DESTINATION . - PUBLIC_HEADER DESTINATION . ) diff --git a/plugins/input/geojson/CMakeLists.txt b/plugins/input/geojson/CMakeLists.txt index 7243eb7239..d8f945e0c4 100644 --- a/plugins/input/geojson/CMakeLists.txt +++ b/plugins/input/geojson/CMakeLists.txt @@ -20,10 +20,7 @@ set_target_properties(input-geojson PROPERTIES OUTPUT_NAME "geojson") set_target_properties(input-geojson PROPERTIES SUFFIX ".input") install(TARGETS input-geojson - EXPORT MapnikTargets LIBRARY DESTINATION lib/plugins/input ARCHIVE DESTINATION lib/plugins/input RUNTIME DESTINATION bin/plugins/input - INCLUDES DESTINATION . - PUBLIC_HEADER DESTINATION . ) diff --git a/plugins/input/ogr/CMakeLists.txt b/plugins/input/ogr/CMakeLists.txt index 8311175faa..034311c7e0 100644 --- a/plugins/input/ogr/CMakeLists.txt +++ b/plugins/input/ogr/CMakeLists.txt @@ -22,10 +22,7 @@ set_target_properties(input-ogr PROPERTIES OUTPUT_NAME "ogr") set_target_properties(input-ogr PROPERTIES SUFFIX ".input") install(TARGETS input-ogr - EXPORT MapnikTargets LIBRARY DESTINATION lib/plugins/input ARCHIVE DESTINATION lib/plugins/input RUNTIME DESTINATION bin/plugins/input - INCLUDES DESTINATION . - PUBLIC_HEADER DESTINATION . ) diff --git a/plugins/input/pgraster/CMakeLists.txt b/plugins/input/pgraster/CMakeLists.txt index 40b35fd6f3..20ae20760c 100644 --- a/plugins/input/pgraster/CMakeLists.txt +++ b/plugins/input/pgraster/CMakeLists.txt @@ -21,10 +21,7 @@ set_target_properties(input-pgraster PROPERTIES OUTPUT_NAME "pgraster") set_target_properties(input-pgraster PROPERTIES SUFFIX ".input") install(TARGETS input-pgraster - EXPORT MapnikTargets LIBRARY DESTINATION lib/plugins/input ARCHIVE DESTINATION lib/plugins/input RUNTIME DESTINATION bin/plugins/input - INCLUDES DESTINATION . - PUBLIC_HEADER DESTINATION . ) diff --git a/plugins/input/postgis/CMakeLists.txt b/plugins/input/postgis/CMakeLists.txt index 2c4cc37d70..3085e62468 100644 --- a/plugins/input/postgis/CMakeLists.txt +++ b/plugins/input/postgis/CMakeLists.txt @@ -20,10 +20,7 @@ set_target_properties(input-postgis PROPERTIES OUTPUT_NAME "postgis") set_target_properties(input-postgis PROPERTIES SUFFIX ".input") install(TARGETS input-postgis - EXPORT MapnikTargets LIBRARY DESTINATION lib/plugins/input ARCHIVE DESTINATION lib/plugins/input RUNTIME DESTINATION bin/plugins/input - INCLUDES DESTINATION . - PUBLIC_HEADER DESTINATION . ) diff --git a/plugins/input/raster/CMakeLists.txt b/plugins/input/raster/CMakeLists.txt index 22c5d203df..557668536b 100644 --- a/plugins/input/raster/CMakeLists.txt +++ b/plugins/input/raster/CMakeLists.txt @@ -18,10 +18,7 @@ set_target_properties(input-raster PROPERTIES OUTPUT_NAME "raster") set_target_properties(input-raster PROPERTIES SUFFIX ".input") install(TARGETS input-raster - EXPORT MapnikTargets LIBRARY DESTINATION lib/plugins/input ARCHIVE DESTINATION lib/plugins/input RUNTIME DESTINATION bin/plugins/input - INCLUDES DESTINATION . - PUBLIC_HEADER DESTINATION . ) diff --git a/plugins/input/shape/CMakeLists.txt b/plugins/input/shape/CMakeLists.txt index 8b73af6c81..64beadd574 100644 --- a/plugins/input/shape/CMakeLists.txt +++ b/plugins/input/shape/CMakeLists.txt @@ -21,10 +21,7 @@ set_target_properties(input-shape PROPERTIES OUTPUT_NAME "shape") set_target_properties(input-shape PROPERTIES SUFFIX ".input") install(TARGETS input-shape - EXPORT MapnikTargets LIBRARY DESTINATION lib/plugins/input ARCHIVE DESTINATION lib/plugins/input RUNTIME DESTINATION bin/plugins/input - INCLUDES DESTINATION . - PUBLIC_HEADER DESTINATION . ) diff --git a/plugins/input/sqlite/CMakeLists.txt b/plugins/input/sqlite/CMakeLists.txt index a4913fc7cc..8b4a57cff9 100644 --- a/plugins/input/sqlite/CMakeLists.txt +++ b/plugins/input/sqlite/CMakeLists.txt @@ -19,11 +19,8 @@ set_target_properties(input-sqlite PROPERTIES PREFIX "") set_target_properties(input-sqlite PROPERTIES OUTPUT_NAME "sqlite") set_target_properties(input-sqlite PROPERTIES SUFFIX ".input") -install(TARGETS input-sqlite - EXPORT MapnikTargets +install(TARGETS input-sqlite LIBRARY DESTINATION lib/plugins/input ARCHIVE DESTINATION lib/plugins/input RUNTIME DESTINATION bin/plugins/input - INCLUDES DESTINATION . - PUBLIC_HEADER DESTINATION . ) diff --git a/plugins/input/topojson/CMakeLists.txt b/plugins/input/topojson/CMakeLists.txt index 93dc4968ea..f727a5e19b 100644 --- a/plugins/input/topojson/CMakeLists.txt +++ b/plugins/input/topojson/CMakeLists.txt @@ -18,10 +18,7 @@ set_target_properties(input-topojson PROPERTIES OUTPUT_NAME "topojson") set_target_properties(input-topojson PROPERTIES SUFFIX ".input") install(TARGETS input-topojson - EXPORT MapnikTargets LIBRARY DESTINATION lib/plugins/input ARCHIVE DESTINATION lib/plugins/input RUNTIME DESTINATION bin/plugins/input - INCLUDES DESTINATION . - PUBLIC_HEADER DESTINATION . ) From 0069e919125d11697090d954f63e6a7a679f894e Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 12:24:34 +0100 Subject: [PATCH 012/141] build utilities correctly --- CMakeLists.txt | 15 ++++++--- demo/CMakeLists.txt | 11 +++++++ demo/c++/CMakeLists.txt | 11 +++++++ demo/viewer/CMakeLists.txt | 46 ++++++++++++++++++++++++++++ utils/CMakeLists.txt | 2 +- utils/geometry_to_wkb/CMakeLists.txt | 5 ++- utils/ogrindex/CMakeLists.txt | 4 ++- utils/pgsql2sqlite/CMakeLists.txt | 16 ++++++++-- utils/shapeindex/CMakeLists.txt | 7 ++++- utils/svg2png/CMakeLists.txt | 7 ++++- 10 files changed, 112 insertions(+), 12 deletions(-) create mode 100644 demo/CMakeLists.txt create mode 100644 demo/c++/CMakeLists.txt create mode 100644 demo/viewer/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 16c4704788..b2b5c971f8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,11 @@ 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) +option(BUILD_DEMO_VIEWER "builds the demo viewer" ON) +option(BUILD_DEMO_CPP "builds the demo c++ application" ON) + + + set(CXX_STANDARD 17) find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex program_options) @@ -181,9 +186,8 @@ install(TARGETS headers add_subdirectory(deps) add_subdirectory(src) add_subdirectory(plugins) -#add_subdirectory(utils) -#add_subdirectory(utils) -#add_subdirectory(plugins) +add_subdirectory(utils) +add_subdirectory(demo) include(CMakePackageConfigHelpers) @@ -209,5 +213,6 @@ install(EXPORT MapnikTargets DESTINATION lib/cmake/mapnik ) -install(DIRECTORY include/ DESTINATION include) -install(DIRECTORY deps/agg/include/ DESTINATION include) \ No newline at end of file +install(DIRECTORY include/ TYPE INCLUDE) +install(DIRECTORY deps/agg/include/ TYPE INCLUDE) +install(DIRECTORY fonts/ DESTINATION bin/fonts FILES_MATCHING PATTERN "*.py" EXCLUDE PATTERN "*") diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt new file mode 100644 index 0000000000..96556acb38 --- /dev/null +++ b/demo/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.15.0) + +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() \ No newline at end of file diff --git a/demo/c++/CMakeLists.txt b/demo/c++/CMakeLists.txt new file mode 100644 index 0000000000..84627451bd --- /dev/null +++ b/demo/c++/CMakeLists.txt @@ -0,0 +1,11 @@ +project(mapnik-demo) + +add_executable(mapnik-demo rundemo.cpp) + +target_link_libraries(mapnik-demo PRIVATE mapnik::headers mapnik::agg mapnik::mapnik) + +install(TARGETS mapnik-demo + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin +) diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt new file mode 100644 index 0000000000..bc4aa0dc31 --- /dev/null +++ b/demo/viewer/CMakeLists.txt @@ -0,0 +1,46 @@ +project(mapnik-viewer) + +find_package(Qt5 COMPONENTS Widgets REQUIRED) + +add_executable(mapnik-viewer + about_dialog.cpp + info_dialog.cpp + layerdelegate.cpp + layerlistmodel.cpp + layerwidget.cpp + layer_info_dialog.cpp + main.cpp + mainwindow.cpp + mapwidget.cpp + styles_model.cpp + forms/about.ui + forms/info.ui + forms/layer_info.ui + mapnik_viewer.qrc +) + +set_target_properties(mapnik-viewer PROPERTIES + AUTOUIC_SEARCH_PATHS forms + AUTORCC ON + AUTOUIC ON + AUTOMOC ON +) + + +target_link_libraries(mapnik-viewer PRIVATE + Qt5::Widgets + mapnik::headers + mapnik::agg + mapnik::mapnik +) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini +"[mapnik] +plugins_dir=plugins/input +fonts/1/dir=fonts" +) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini DESTINATION bin) +install(TARGETS mapnik-viewer + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin +) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 8ad98aeb5f..1d60b6d187 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15.0) add_subdirectory(geometry_to_wkb) add_subdirectory(mapnik-index) add_subdirectory(mapnik-render) -add_subdirectory(ogrindex) +# add_subdirectory(ogrindex) # missing include file shapeindex/quadtree.hpp add_subdirectory(pgsql2sqlite) add_subdirectory(shapeindex) add_subdirectory(svg2png) diff --git a/utils/geometry_to_wkb/CMakeLists.txt b/utils/geometry_to_wkb/CMakeLists.txt index 12cc699a3c..b6ec671bc2 100644 --- a/utils/geometry_to_wkb/CMakeLists.txt +++ b/utils/geometry_to_wkb/CMakeLists.txt @@ -1,6 +1,9 @@ add_executable(geometry_to_wkb main.cpp) -target_link_libraries(geometry_to_wkb PRIVATE mapnik::headers mapnik::mapnik) +target_link_libraries(geometry_to_wkb PRIVATE + mapnik::headers + mapnik::mapnik +) install(TARGETS geometry_to_wkb EXPORT MapnikTargets diff --git a/utils/ogrindex/CMakeLists.txt b/utils/ogrindex/CMakeLists.txt index 0575f26b7b..eafa23289c 100644 --- a/utils/ogrindex/CMakeLists.txt +++ b/utils/ogrindex/CMakeLists.txt @@ -1,7 +1,9 @@ add_executable(ogrindex ogrindex.cpp) + target_link_libraries(ogrindex PRIVATE mapnik::headers mapnik::mapnik) + install(TARGETS ogrindex EXPORT MapnikTargets RUNTIME DESTINATION bin -) \ No newline at end of file +) diff --git a/utils/pgsql2sqlite/CMakeLists.txt b/utils/pgsql2sqlite/CMakeLists.txt index 29569a904c..3ba2f66bc2 100644 --- a/utils/pgsql2sqlite/CMakeLists.txt +++ b/utils/pgsql2sqlite/CMakeLists.txt @@ -1,10 +1,22 @@ + +find_package(SQLite3 REQUIRED) +find_package(PostgreSQL REQUIRED) + add_executable(pgsql2sqlite main.cpp sqlite.cpp ) -target_link_libraries(pgsql2sqlite PRIVATE mapnik::headers mapnik::mapnik) +target_include_directories(pgsql2sqlite PRIVATE ../../plugins/input/postgis) +target_link_libraries(pgsql2sqlite PRIVATE + SQLite::SQLite3 + PostgreSQL::PostgreSQL + Boost::program_options + mapnik::headers + mapnik::mapnik +) + install(TARGETS pgsql2sqlite EXPORT MapnikTargets RUNTIME DESTINATION bin -) \ No newline at end of file +) diff --git a/utils/shapeindex/CMakeLists.txt b/utils/shapeindex/CMakeLists.txt index 15ebf477c1..92ab1594a2 100644 --- a/utils/shapeindex/CMakeLists.txt +++ b/utils/shapeindex/CMakeLists.txt @@ -2,7 +2,12 @@ add_executable(shapeindex shapeindex.cpp ) -target_link_libraries(shapeindex PRIVATE mapnik::headers mapnik::mapnik) +target_include_directories(shapeindex PRIVATE ../../plugins/input/shape) +target_link_libraries(shapeindex PRIVATE + Boost::program_options + mapnik::headers + mapnik::mapnik +) install(TARGETS shapeindex EXPORT MapnikTargets RUNTIME DESTINATION bin diff --git a/utils/svg2png/CMakeLists.txt b/utils/svg2png/CMakeLists.txt index feb84e80aa..b0819685b4 100644 --- a/utils/svg2png/CMakeLists.txt +++ b/utils/svg2png/CMakeLists.txt @@ -2,7 +2,12 @@ add_executable(svg2png svg2png.cpp ) -target_link_libraries(svg2png PRIVATE mapnik::headers mapnik::mapnik) +target_link_libraries(svg2png PRIVATE + Boost::program_options + mapnik::headers + mapnik::mapnik + mapnik::agg +) install(TARGETS svg2png EXPORT MapnikTargets RUNTIME DESTINATION bin From e97d1dc92305f0b87e3cc5ba22d91f6d5a24fb70 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 12:30:34 +0100 Subject: [PATCH 013/141] add options to enable/disable utilitys --- CMakeLists.txt | 8 +++++++- utils/CMakeLists.txt | 36 +++++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2b5c971f8..cd32621162 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,13 @@ 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) - +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) set(CXX_STANDARD 17) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 1d60b6d187..9a95c5713f 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,8 +1,30 @@ cmake_minimum_required(VERSION 3.15.0) -add_subdirectory(geometry_to_wkb) -add_subdirectory(mapnik-index) -add_subdirectory(mapnik-render) -# add_subdirectory(ogrindex) # missing include file shapeindex/quadtree.hpp -add_subdirectory(pgsql2sqlite) -add_subdirectory(shapeindex) -add_subdirectory(svg2png) +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() From a7306a2a63027fe08bbe7932ef920269ebf3955c Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 12:38:29 +0100 Subject: [PATCH 014/141] add support for proj4 --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd32621162..9c6dd598b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ 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_PROJ4 "adds proj4 support" ON) option(USE_PLUGIN_INPUT_CSV "adds plugin input csv" ON) option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON) @@ -155,6 +156,13 @@ if(USE_CAIRO) list(APPEND MAPNIK_OPTIONAL_LIBS Cairo::Cairo) endif() +if(USE_PROJ4) + message(STATUS "Using PROJ4") + find_package(PROJ4 CONFIG REQUIRED) + list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ4) + list(APPEND MAPNIK_OPTIONAL_LIBS proj) +endif() + add_library(headers INTERFACE) add_library(mapnik::headers ALIAS headers) From bea3f45bda9ff2e2c16f8af8f582a1c2187d1132 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 12:50:11 +0100 Subject: [PATCH 015/141] add proj required define --- CMakeLists.txt | 2 +- cmake/MapnikConfig.cmake.in | 2 +- demo/CMakeLists.txt | 2 +- deps/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c6dd598b8..79aa279eaf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,7 +159,7 @@ endif() if(USE_PROJ4) message(STATUS "Using PROJ4") find_package(PROJ4 CONFIG REQUIRED) - list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ4) + list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ4 ACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1) list(APPEND MAPNIK_OPTIONAL_LIBS proj) endif() diff --git a/cmake/MapnikConfig.cmake.in b/cmake/MapnikConfig.cmake.in index db991109b6..4a1773f42e 100644 --- a/cmake/MapnikConfig.cmake.in +++ b/cmake/MapnikConfig.cmake.in @@ -2,4 +2,4 @@ include("${CMAKE_CURRENT_LIST_DIR}/MapnikTargets.cmake") -check_required_components(mapnik) \ No newline at end of file +check_required_components(mapnik) diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt index 96556acb38..1bc4c8ddd7 100644 --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -8,4 +8,4 @@ endif() if(BUILD_DEMO_CPP) message(STATUS "Building c++ demo app") add_subdirectory(c++) -endif() \ No newline at end of file +endif() diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 69527cdfeb..e96f655840 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -1,2 +1,2 @@ cmake_minimum_required(VERSION 3.15.0) -add_subdirectory(agg) \ No newline at end of file +add_subdirectory(agg) From bab67938642cbbaaff888cc3880013c8589c6148 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 13:20:04 +0100 Subject: [PATCH 016/141] add initial test support --- CMakeLists.txt | 7 ++++++- test/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 79aa279eaf..debac47e58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,8 @@ project(mapnik set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -set(BUILD_SHARED_LIBS ON) +option(BUILD_SHARED_LIBS "build mapnik dynamic" 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) @@ -202,6 +203,10 @@ add_subdirectory(src) add_subdirectory(plugins) add_subdirectory(utils) add_subdirectory(demo) +if(BUILD_TEST) + enable_testing() + add_subdirectory(test) +endif() include(CMakePackageConfigHelpers) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000000..fc11917393 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,31 @@ +project(mapnik-test) + +Include(FetchContent) + +FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v2.13.1) +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}) + +add_executable(mapnik-test-unit + unit/run.cpp + unit/color/css_color.cpp +) +target_link_libraries(mapnik-test-unit PUBLIC + Catch + mapnik::headers + mapnik::agg + mapnik::mapnik +) + +include(CTest) +include(${catch2_SOURCE_DIR}/contrib/Catch.cmake) +include(${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake) + +ParseAndAddCatchTests(mapnik-test-unit) \ No newline at end of file From 3b84a831c1be5b240b2da3c9b4883cacc2375d23 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 14:54:26 +0100 Subject: [PATCH 017/141] do not compile features if they are not set --- src/CMakeLists.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index dddba92782..e4955c9498 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,7 +47,6 @@ set(MAPNIK_SOURCES image_view_any.cpp image_view.cpp image.cpp - jpeg_reader.cpp layer.cpp load_map.cpp map.cpp @@ -62,7 +61,6 @@ set(MAPNIK_SOURCES parse_transform.cpp path_expression_grammar_x3.cpp plugin.cpp - png_reader.cpp proj_transform.cpp projection.cpp raster_colorizer.cpp @@ -74,8 +72,7 @@ set(MAPNIK_SOURCES simplify.cpp symbolizer_enumerations.cpp symbolizer_keys.cpp - symbolizer.cpp - tiff_reader.cpp + symbolizer.cpp transform_expression_grammar_x3.cpp transform_expression.cpp twkb.cpp @@ -90,6 +87,16 @@ set(MAPNIK_SOURCES ) set(COMPILE_SRC ${MAPNIK_SOURCES}) +if(NOT USE_JPEG) + list(APPEND COMPILE_SRC jpeg_reader.cpp) +endif() +if(NOT USE_PNG) + list(APPEND COMPILE_SRC png_reader.cpp) +endif() +if(NOT USE_TIFF) + list(APPEND COMPILE_SRC tiff_reader.cpp) +endif() + set(AGG_COMPILE_SRC ../deps/agg/src/agg_arc.cpp ../deps/agg/src/agg_arrowhead.cpp From 2ad72abd0c9adedcd6b706fd760b83f58d784169 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 15:02:07 +0100 Subject: [PATCH 018/141] do not compile features.... --- src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e4955c9498..a4746f37cf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -87,13 +87,13 @@ set(MAPNIK_SOURCES ) set(COMPILE_SRC ${MAPNIK_SOURCES}) -if(NOT USE_JPEG) +if(USE_JPEG) list(APPEND COMPILE_SRC jpeg_reader.cpp) endif() -if(NOT USE_PNG) +if(USE_PNG) list(APPEND COMPILE_SRC png_reader.cpp) endif() -if(NOT USE_TIFF) +if(USE_TIFF) list(APPEND COMPILE_SRC tiff_reader.cpp) endif() From 073de4e35ab23eb5daf874ee67cf14f5c3d43c94 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 15:10:20 +0100 Subject: [PATCH 019/141] enable c++17 and do not use c++ extensions --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index debac47e58..b8059acba2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,9 @@ 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) -set(CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex program_options) find_package(ICU REQUIRED COMPONENTS uc) From 74605f8e256da5f701ffcebda5a4e433bd115817 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 15:18:31 +0100 Subject: [PATCH 020/141] use only c++17 with extensions.. --- CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8059acba2..245f8922c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,8 +46,6 @@ option(BUILD_UTILITY_SHAPEINDEX "builds the utility program shapeindex" ON) option(BUILD_UTILITY_SVG2PNG "builds the utility program svg2png" ON) set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex program_options) find_package(ICU REQUIRED COMPONENTS uc) From c3cb74a8a172f6a68d61c7b5cdc479102d5cff89 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 15:34:13 +0100 Subject: [PATCH 021/141] try with c++14 --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 245f8922c9..be0195a6ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ 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) -set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD 14) find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex program_options) find_package(ICU REQUIRED COMPONENTS uc) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a4746f37cf..534085ff52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -278,8 +278,12 @@ 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 MAPNIK_EXPORTS) +target_compile_definitions(mapnik PRIVATE ${COMPILE_DEFS}) target_link_libraries(mapnik PRIVATE mapnik::headers mapnik::agg From 08d9bf32b08208fef7189cb8b6ae10d672820c15 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 15:41:03 +0100 Subject: [PATCH 022/141] use feature test for --- src/image_util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/image_util.cpp b/src/image_util.cpp index d8811082cc..3f59abf25d 100644 --- a/src/image_util.cpp +++ b/src/image_util.cpp @@ -54,7 +54,7 @@ MAPNIK_DISABLE_WARNING_POP #include #include -#if __cplusplus >= 201703L +#if __cpp_lib_execution >= 201603 #include #endif From 09e9362b720d423ade941882aeca0e934de54fbf Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 17:03:30 +0100 Subject: [PATCH 023/141] add options for grid/svg renderer --- CMakeLists.txt | 24 ++++++--- src/CMakeLists.txt | 68 +++++++++++++------------ test/CMakeLists.txt | 119 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 173 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be0195a6ec..dc30e0b672 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,13 +14,15 @@ option(USE_EXTERNAL_MAPBOX_GEOMETRY "Use a external mapnik/geometry.hpp. If 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_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_PROJ4 "adds proj4 support" ON) +option(USE_GRID_RENDERER "adds grid renderer" ON) +option(USE_SVG_RENDERER "adds grid renderer" ON) option(USE_PLUGIN_INPUT_CSV "adds plugin input csv" ON) option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON) @@ -164,6 +166,16 @@ if(USE_PROJ4) list(APPEND MAPNIK_OPTIONAL_LIBS proj) 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() + add_library(headers INTERFACE) add_library(mapnik::headers ALIAS headers) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 534085ff52..e08138ee93 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -180,22 +180,25 @@ set(GEOMETRY_SRC ) list(APPEND COMPILE_SRC ${GEOMETRY_SRC}) -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}) +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 @@ -213,22 +216,25 @@ set(RENDERER_COMMON_SRC ) list(APPEND COMPILE_SRC ${RENDERER_COMMON_SRC}) -set(SVG_SRC - 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_SRC + 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 - 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 COMPILE_SRC ${SVG_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 COMPILE_SRC ${SVG_SRC}) +endif() set(TEXT_SRC text/color_font_renderer.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fc11917393..35bba6998c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,6 +16,85 @@ target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}) add_executable(mapnik-test-unit unit/run.cpp unit/color/css_color.cpp + unit/core/box2d_test.cpp + unit/core/comparison_test.cpp + unit/core/conversions_test.cpp + unit/core/copy_move_test.cpp + unit/core/exceptions_test.cpp + unit/core/expressions_test.cpp + unit/core/params_test.cpp + unit/core/transform_expressions_test.cpp + unit/core/value_test.cpp + unit/datasource/csv.cpp + unit/datasource/gdal.cpp + unit/datasource/geobuf.cpp + unit/datasource/geojson.cpp + unit/datasource/memory.cpp + unit/datasource/ogr.cpp + unit/datasource/postgis.cpp + unit/datasource/shapeindex.cpp + unit/datasource/spatial_index.cpp + unit/datasource/topojson.cpp + unit/font/fontset_runtime_test.cpp + unit/geometry/centroid.cpp + unit/geometry/closest_point.cpp + unit/geometry/geometry.cpp + unit/geometry/geometry_envelope_test.cpp + unit/geometry/geometry_hit_test.cpp + unit/geometry/geometry_is_simple.cpp + unit/geometry/geometry_is_valid.cpp + unit/geometry/geometry_reprojection.cpp + unit/geometry/geometry_strategy_test.cpp + unit/geometry/geometry_test_helper.cpp + unit/geometry/grid_vertex_converter.cpp + unit/geometry/interior.cpp + unit/geometry/is_clockwise.cpp + unit/geometry/is_empty.cpp + unit/geometry/polygon_vertex_processor.cpp + unit/geometry/polylabel.cpp + unit/geometry/remove_empty.cpp + unit/imaging/image.cpp + unit/imaging/image_apply_opacity.cpp + unit/imaging/image_filter.cpp + unit/imaging/image_io_test.cpp + unit/imaging/image_is_solid.cpp + unit/imaging/image_painted_test.cpp + unit/imaging/image_premultiply.cpp + unit/imaging/image_set_pixel.cpp + unit/imaging/image_view.cpp + unit/imaging/tiff_io.cpp + unit/imaging/webp_io.cpp + unit/map/background.cpp + unit/numerics/enumeration.cpp + unit/numerics/safe_cast.cpp + unit/pixel/agg_blend_src_over_test.cpp + unit/pixel/palette.cpp + unit/projection/proj_transform.cpp + unit/renderer/buffer_size_scale_factor.cpp + unit/renderer/cairo_io.cpp + unit/renderer/feature_style_processor.cpp + unit/serialization/wkb_formats_test.cpp + unit/serialization/wkb_test.cpp + unit/serialization/xml_parser_trim.cpp + unit/sql/sql_parse.cpp + unit/svg/svg_parser_test.cpp + unit/svg/svg_path_parser_test.cpp + unit/svg/svg_renderer_test.cpp + unit/symbolizer/marker_placement_vertex_last.cpp + unit/symbolizer/markers_point_placement.cpp + unit/symbolizer/symbolizer_test.cpp + unit/text/script_runs.cpp + unit/text/shaping.cpp + unit/text/text_placements_list.cpp + unit/text/text_placements_simple.cpp + unit/util/char_array_buffer.cpp + unit/vertex_adapter/clipping_test.cpp + unit/vertex_adapter/extend_converter.cpp + unit/vertex_adapter/line_offset_test.cpp + unit/vertex_adapter/offset_converter.cpp + unit/vertex_adapter/simplify_converters_test.cpp + unit/vertex_adapter/transform_path_adapter.cpp + unit/vertex_adapter/vertex_adapter.cpp ) target_link_libraries(mapnik-test-unit PUBLIC Catch @@ -24,8 +103,46 @@ target_link_libraries(mapnik-test-unit PUBLIC mapnik::mapnik ) +add_executable(agg_rasterizer_integer_overflow_test standalone/agg_rasterizer_integer_overflow_test.cpp) +target_link_libraries(agg_rasterizer_integer_overflow_test PUBLIC + Catch + +) + +add_executable(datasource_registration_test standalone/datasource_registration_test.cpp) +target_link_libraries(datasource_registration_test PUBLIC + Catch +) + +add_executable(font_registration_test standalone/font_registration_test.cpp) +target_link_libraries(font_registration_test PUBLIC + Catch +) + +add_executable(map_xml_test standalone/map_xml_test.cpp) +target_link_libraries(map_xml_test PUBLIC + Catch +) + +add_executable(mapnik-test-visual + visual/parse_map_sizes.cpp + visual/report.cpp + visual/runner.cpp + visual/run.cpp +) +target_link_libraries( + mapnik-test-visual PRIVATE + Boost::program_options + mapnik::headers + mapnik::mapnik +) + include(CTest) include(${catch2_SOURCE_DIR}/contrib/Catch.cmake) include(${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake) -ParseAndAddCatchTests(mapnik-test-unit) \ No newline at end of file +ParseAndAddCatchTests(mapnik-test-unit) +catch_discover_tests(agg_rasterizer_integer_overflow_test) +catch_discover_tests(datasource_registration_test) +catch_discover_tests(font_registration_test) +catch_discover_tests(map_xml_test) \ No newline at end of file From 3cd0f56a2b6129ad07598a2f56bc3ff69bea1ade Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 17:45:44 +0100 Subject: [PATCH 024/141] add libraries to test --- test/CMakeLists.txt | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 35bba6998c..47259cbe53 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -101,27 +101,43 @@ target_link_libraries(mapnik-test-unit PUBLIC mapnik::headers mapnik::agg mapnik::mapnik + mapnik::json + mapnik::wkt ) add_executable(agg_rasterizer_integer_overflow_test standalone/agg_rasterizer_integer_overflow_test.cpp) target_link_libraries(agg_rasterizer_integer_overflow_test PUBLIC Catch - + mapnik::headers + mapnik::mapnik + mapnik::agg + mapnik::json ) add_executable(datasource_registration_test standalone/datasource_registration_test.cpp) target_link_libraries(datasource_registration_test PUBLIC Catch + mapnik::headers + mapnik::mapnik + mapnik::agg ) add_executable(font_registration_test standalone/font_registration_test.cpp) target_link_libraries(font_registration_test PUBLIC Catch + mapnik::headers + mapnik::mapnik + mapnik::agg + mapnik::json ) add_executable(map_xml_test standalone/map_xml_test.cpp) target_link_libraries(map_xml_test PUBLIC Catch + mapnik::headers + mapnik::mapnik + mapnik::agg + mapnik::json ) add_executable(mapnik-test-visual @@ -133,8 +149,10 @@ add_executable(mapnik-test-visual target_link_libraries( mapnik-test-visual PRIVATE Boost::program_options + Boost::filesystem mapnik::headers mapnik::mapnik + mapnik::agg ) include(CTest) From 32dcd93c2627afa77fb70f09e0b4996c76363375 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 18:01:48 +0100 Subject: [PATCH 025/141] fix svg renderer --- src/CMakeLists.txt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e08138ee93..2c5c361355 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -216,15 +216,16 @@ set(RENDERER_COMMON_SRC ) list(APPEND COMPILE_SRC ${RENDERER_COMMON_SRC}) +set(SVG_SRC + 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_SRC - 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 - + set(SVG_RENDERER_SRC) svg/output/process_line_symbolizer.cpp svg/output/process_polygon_symbolizer.cpp svg/output/process_symbolizers.cpp @@ -233,8 +234,9 @@ if(USE_SVG_RENDERER) svg/output/svg_output_grammars.cpp svg/output/svg_renderer.cpp ) - list(APPEND COMPILE_SRC ${SVG_SRC}) + list(APPEND SVG_SRC ${SVG_RENDERER_SRC}) endif() +list(APPEND COMPILE_SRC ${SVG_SRC}) set(TEXT_SRC text/color_font_renderer.cpp From 76385a89eeb3bd8afc5d77c3286bf0e7c3b940b5 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 18:04:24 +0100 Subject: [PATCH 026/141] fix cmake typo --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2c5c361355..be6388656c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -225,7 +225,7 @@ set(SVG_SRC ) if(USE_SVG_RENDERER) message(STATUS "adding svg renderer to compilation") - set(SVG_RENDERER_SRC) + set(SVG_RENDERER_SRC svg/output/process_line_symbolizer.cpp svg/output/process_polygon_symbolizer.cpp svg/output/process_symbolizers.cpp From 65b4734a001455e7c9338e3b457defac99d43b2c Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 18:17:32 +0100 Subject: [PATCH 027/141] comment not workable test out --- test/CMakeLists.txt | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 47259cbe53..0e551e8b81 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -131,14 +131,15 @@ target_link_libraries(font_registration_test PUBLIC mapnik::json ) -add_executable(map_xml_test standalone/map_xml_test.cpp) -target_link_libraries(map_xml_test PUBLIC - Catch - mapnik::headers - mapnik::mapnik - mapnik::agg - mapnik::json -) +# 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 +# mapnik::headers +# mapnik::mapnik +# mapnik::agg +# mapnik::json +#) add_executable(mapnik-test-visual visual/parse_map_sizes.cpp @@ -148,6 +149,7 @@ add_executable(mapnik-test-visual ) target_link_libraries( mapnik-test-visual PRIVATE + Catch Boost::program_options Boost::filesystem mapnik::headers @@ -163,4 +165,4 @@ ParseAndAddCatchTests(mapnik-test-unit) catch_discover_tests(agg_rasterizer_integer_overflow_test) catch_discover_tests(datasource_registration_test) catch_discover_tests(font_registration_test) -catch_discover_tests(map_xml_test) \ No newline at end of file +#catch_discover_tests(map_xml_test) \ No newline at end of file From cde2bd7aca15c32e6956eaa771c6ec3ceb3e7120 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 18:18:21 +0100 Subject: [PATCH 028/141] removed MAPNIK_DECL from feature_style_processor; conflicts with the feature_style_processor_impl.h --- include/mapnik/feature_style_processor.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/feature_style_processor.hpp b/include/mapnik/feature_style_processor.hpp index 7e10d758dc..e92e3962d0 100644 --- a/include/mapnik/feature_style_processor.hpp +++ b/include/mapnik/feature_style_processor.hpp @@ -52,7 +52,7 @@ enum eAttributeCollectionPolicy }; template -class MAPNIK_DECL feature_style_processor +class feature_style_processor { public: explicit feature_style_processor(Map const& m, From 2060f528d43fb2072fccaec2ae08b158aab33d0b Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 18:19:58 +0100 Subject: [PATCH 029/141] added MAPNIK_DECL to interior and polylabel explicit template --- src/geometry/interior.cpp | 2 +- src/geometry/polylabel.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/geometry/interior.cpp b/src/geometry/interior.cpp index 77ea03fba6..304e949e6d 100644 --- a/src/geometry/interior.cpp +++ b/src/geometry/interior.cpp @@ -232,7 +232,7 @@ bool interior(polygon const& polygon, double scale_factor, point & pt) return true; } -template +template MAPNIK_DECL bool interior(polygon const& polygon, double scale_factor, point & pt); } } diff --git a/src/geometry/polylabel.cpp b/src/geometry/polylabel.cpp index 07012fcdb8..b36bb30d43 100644 --- a/src/geometry/polylabel.cpp +++ b/src/geometry/polylabel.cpp @@ -46,14 +46,14 @@ bool polylabel(polygon const& polygon, T precision, point & pt) return true; } -template -bool polylabel(polygon const& polygon, - double precision, - point & pt); - -template -double polylabel_precision(polygon const& polygon, - double scale_factor); +template MAPNIK_DECL +bool polylabel(polygon const& polygon, + double precision, + point & pt); + +template MAPNIK_DECL +double polylabel_precision(polygon const& polygon, +double scale_factor); } } From e1f9eb6e041dd5d5bc9b48f31665c1d3d5343cc9 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 19:03:55 +0100 Subject: [PATCH 030/141] fixed map_xml_test --- cmake/CopyDllsForDebug.cmake | 31 +++++++++++++++++++++++++++++++ test/CMakeLists.txt | 31 ++++++++++++++++++++----------- test/standalone/map_xml_test.cpp | 26 +++++++++++++------------- 3 files changed, 64 insertions(+), 24 deletions(-) create mode 100644 cmake/CopyDllsForDebug.cmake diff --git a/cmake/CopyDllsForDebug.cmake b/cmake/CopyDllsForDebug.cmake new file mode 100644 index 0000000000..f2f2b153b7 --- /dev/null +++ b/cmake/CopyDllsForDebug.cmake @@ -0,0 +1,31 @@ +# This is a helper script to run BundleUtilities fixup_bundle as postbuild +# for a target. The primary use case is to copy .DLLs to the build directory for +# the Windows platform. It allows generator expressions to be used to determine +# the binary location +# +# Usage : copy_dlls_for_debug TARGET LIBS DIRS +# - TARGET : A cmake target +# - See fixup_bundle for LIBS and DIRS arguments + +if(RUN_IT) +# Script ran by the add_custom_command + include(BundleUtilities) + include(InstallRequiredSystemLibraries) + fixup_bundle("${TO_FIXUP_FILE}" "${TO_FIXUP_LIBS}" "${TO_FIXUP_DIRS}") +# End of script ran by the add_custom_command +else() + +set(THIS_FILE ${CMAKE_CURRENT_LIST_FILE}) +function(copy_dlls_for_debug _target _libs _dirs) + if(WIN32) + add_custom_command( + TARGET ${_target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -DRUN_IT:BOOL=ON -DTO_FIXUP_FILE=$ -DTO_FIXUP_LIBS=${_libs} -DTO_FIXUP_DIRS=${_dirs} -P ${THIS_FILE} + COMMENT "Fixing up dependencies for ${_target}" + VERBATIM + ) + endif(WIN32) +endfunction() + +endif() + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0e551e8b81..4009311347 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,7 @@ project(mapnik-test) -Include(FetchContent) +include(FetchContent) +include(CopyDllsForDebug) FetchContent_Declare( Catch2 @@ -13,6 +14,8 @@ set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) add_library(Catch INTERFACE) target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}) + + add_executable(mapnik-test-unit unit/run.cpp unit/color/css_color.cpp @@ -131,15 +134,15 @@ target_link_libraries(font_registration_test PUBLIC mapnik::json ) -# 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 -# mapnik::headers -# mapnik::mapnik -# mapnik::agg -# mapnik::json -#) +#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 + mapnik::headers + mapnik::mapnik + mapnik::agg + mapnik::json +) add_executable(mapnik-test-visual visual/parse_map_sizes.cpp @@ -160,9 +163,15 @@ target_link_libraries( include(CTest) include(${catch2_SOURCE_DIR}/contrib/Catch.cmake) include(${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake) +set(APPS mapnik-test-unit mapnik-test-visual mapnik::mapnik) # paths to executables +set(DIRS ${CMAKE_BINARY_DIR}/src/RelWithDebInfo) # directories to search for prerequisites +copy_dlls_for_debug(${APPS} \"\" ${DIRS}) + +file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test) +file(COPY data-visual DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test) ParseAndAddCatchTests(mapnik-test-unit) catch_discover_tests(agg_rasterizer_integer_overflow_test) catch_discover_tests(datasource_registration_test) catch_discover_tests(font_registration_test) -#catch_discover_tests(map_xml_test) \ No newline at end of file +catch_discover_tests(map_xml_test) \ No newline at end of file diff --git a/test/standalone/map_xml_test.cpp b/test/standalone/map_xml_test.cpp index b33a3f7180..0bd42d14cc 100644 --- a/test/standalone/map_xml_test.cpp +++ b/test/standalone/map_xml_test.cpp @@ -76,17 +76,17 @@ void compare_map(bfs::path xml) { // is a normalisation step to ensure that the file is in // whatever the current version of mapnik uses as the // standard indentation, quote style, etc... - REQUIRE_NOTHROW(mapnik::load_map(m, xml.native(), false, abs_base.native())); + REQUIRE_NOTHROW(mapnik::load_map(m, xml.generic_string(), false, abs_base.generic_string())); bfs::path test_map1 = dir.path() / "mapnik-temp-map1.xml"; - REQUIRE_NOTHROW(mapnik::save_map(m, test_map1.native())); + REQUIRE_NOTHROW(mapnik::save_map(m, test_map1.generic_string())); // create a new map, load the one saved in the previous // step, and write it out again. mapnik::Map new_map(256, 256); REQUIRE(new_map.register_fonts("fonts", true)); - REQUIRE_NOTHROW(mapnik::load_map(new_map, test_map1.native(), false, abs_base.native())); + REQUIRE_NOTHROW(mapnik::load_map(new_map, test_map1.generic_string(), false, abs_base.generic_string())); bfs::path test_map2 = dir.path() / "mapnik-temp-map2.xml"; - REQUIRE_NOTHROW(mapnik::save_map(new_map, test_map2.native())); + REQUIRE_NOTHROW(mapnik::save_map(new_map, test_map2.generic_string())); // if all the information survived the load/save round-trip // then the two files ought to be identical. @@ -102,7 +102,7 @@ void add_xml_files(bfs::path dir, std::vector &xml_files) { for (auto const &entry : boost::make_iterator_range( bfs::directory_iterator(dir), bfs::directory_iterator())) { auto path = entry.path(); - if (path.extension().native() == ".xml") { + if (path.extension().generic_string() == ".xml") { xml_files.emplace_back(path); } } @@ -112,7 +112,7 @@ void load_map(mapnik::Map &m, bfs::path const &path) { try { - mapnik::load_map(m, path.native()); + mapnik::load_map(m, path.generic_string()); } catch (std::exception const &ex) { @@ -129,7 +129,7 @@ void load_map(mapnik::Map &m, bfs::path const &path) { } // anonymous namespace -const bool registered = mapnik::datasource_cache::instance().register_datasources("./plugins/input/"); +const bool registered = mapnik::datasource_cache::instance().register_datasources((bfs::path("plugins") / "input").generic_string()); TEST_CASE("map xml I/O") { // make sure plugins are loaded @@ -141,7 +141,7 @@ TEST_CASE("map xml I/O") { SECTION("good maps") { std::vector good_maps; - add_xml_files("test/data/good_maps", good_maps); + add_xml_files(bfs::path("test") / "data" / "good_maps", good_maps); for (auto const &path : good_maps) { CAPTURE(path.native()); @@ -157,7 +157,7 @@ TEST_CASE("map xml I/O") { } // END SECTION SECTION("duplicate styles only throw in strict mode") { - std::string duplicate_stylename("test/data/broken_maps/duplicate_stylename.xml"); + std::string duplicate_stylename((bfs::path("test") / "data" / "broken_maps" / "duplicate_stylename.xml").generic_string()); CAPTURE(duplicate_stylename); mapnik::Map m(256, 256); REQUIRE(m.register_fonts("fonts", true)); @@ -169,15 +169,15 @@ TEST_CASE("map xml I/O") { SECTION("broken maps") { std::vector broken_maps; - add_xml_files("test/data/broken_maps", broken_maps); - broken_maps.emplace_back("test/data/broken_maps/does_not_exist.xml"); + add_xml_files(bfs::path("test") / "data" / "broken_maps", broken_maps); + broken_maps.emplace_back(bfs::path("test") / "data" / "broken_maps" / "does_not_exist.xml"); for (auto const &path : broken_maps) { - CAPTURE(path.native()); + CAPTURE(path.generic_string()); mapnik::Map m(256, 256); REQUIRE(m.register_fonts("fonts", true)); - REQUIRE_THROWS(mapnik::load_map(m, path.native(), true)); + REQUIRE_THROWS(mapnik::load_map(m, path.generic_string(), true)); } } // END SECTION From 7a672fe185b4a74e4ad4db04a0629c359e3b69b6 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 21 Nov 2020 19:16:47 +0100 Subject: [PATCH 031/141] fix one forgotton native() --- test/standalone/map_xml_test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/standalone/map_xml_test.cpp b/test/standalone/map_xml_test.cpp index 0bd42d14cc..5f1dba9001 100644 --- a/test/standalone/map_xml_test.cpp +++ b/test/standalone/map_xml_test.cpp @@ -144,7 +144,7 @@ TEST_CASE("map xml I/O") { add_xml_files(bfs::path("test") / "data" / "good_maps", good_maps); for (auto const &path : good_maps) { - CAPTURE(path.native()); + CAPTURE(path.generic_string()); // check that it can load mapnik::Map m(256, 256); From 2247856b9a2ba433a56895048f742d1da5926d94 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sun, 22 Nov 2020 22:01:33 +0100 Subject: [PATCH 032/141] cmake improvements --- CMakeLists.txt | 39 +++++++++++++++++---------- cmake/MapnikConfig.cmake.in | 4 +++ demo/viewer/CMakeLists.txt | 4 +-- plugins/input/csv/CMakeLists.txt | 4 +-- plugins/input/gdal/CMakeLists.txt | 4 +-- plugins/input/geobuf/CMakeLists.txt | 6 ++--- plugins/input/geojson/CMakeLists.txt | 4 +-- plugins/input/ogr/CMakeLists.txt | 4 +-- plugins/input/pgraster/CMakeLists.txt | 4 +-- plugins/input/postgis/CMakeLists.txt | 4 +-- plugins/input/raster/CMakeLists.txt | 4 +-- plugins/input/shape/CMakeLists.txt | 4 +-- plugins/input/sqlite/CMakeLists.txt | 4 +-- plugins/input/topojson/CMakeLists.txt | 4 +-- test/CMakeLists.txt | 4 +-- utils/geometry_to_wkb/CMakeLists.txt | 2 ++ utils/mapnik-index/CMakeLists.txt | 4 +++ utils/mapnik-render/CMakeLists.txt | 4 +++ utils/ogrindex/CMakeLists.txt | 2 ++ utils/pgsql2sqlite/CMakeLists.txt | 3 ++- utils/shapeindex/CMakeLists.txt | 4 +++ utils/svg2png/CMakeLists.txt | 4 +++ 22 files changed, 67 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dc30e0b672..9de080db4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,15 +47,23 @@ 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) +set(PLUGINS_INSTALL_DIR bin/plugins/input CACHE STRING "installs the plugins in the specified directory") +get_filename_component(ABSOLUTE_PLUGINS_INSTALL_DIR ${PLUGINS_INSTALL_DIR} ABSOLUTE) +message("Installing plugins to ${ABSOLUTE_PLUGINS_INSTALL_DIR}") +set(FONTS_INSTALL_DIR bin/fonts CACHE STRING "installs the fonts in the specified directory") +get_filename_component(ABSOLUTE_FONTS_INSTALL_DIR ${FONTS_INSTALL_DIR} ABSOLUTE) +message("Installing fonts to ${FONTS_INSTALL_DIR}") + + set(CMAKE_CXX_STANDARD 14) -find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex program_options) +find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) find_package(ICU REQUIRED COMPONENTS uc) find_package(Freetype REQUIRED) find_package(harfbuzz CONFIG REQUIRED) if(USE_EXTERNAL_MAPBOX_GEOMETRY) - # provide a way to specify the include dirs with the CACHE VARIABLES + # this is used to provide a way to specify include dirs with CACHE VARIABLES 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) @@ -179,16 +187,14 @@ endif() add_library(headers INTERFACE) add_library(mapnik::headers ALIAS headers) -# todo: mapbox includes need to included private. target_include_directories(headers INTERFACE $ + $ + $ + $ + $ + $ $ - ${MAPBOX_GEOMETRY_INCLUDE_DIRS} - ${MAPBOX_POLYLABEL_INCLUDE_DIRS} - ${MAPBOX_VARIANT_INCLUDE_DIRS} - ${MAPBOX_PROTOZERO_INCLUDE_DIRS} - $ - $ ) target_link_libraries(headers INTERFACE Boost::boost @@ -220,8 +226,12 @@ if(BUILD_TEST) add_subdirectory(test) endif() - +# start package mapnik include(CMakePackageConfigHelpers) + +# set the cmake targets install location +set(INSTALL_CMAKE_DIR lib/cmake) +set(INCLUDE_INSTALL_DIR include/) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfigVersion.cmake" VERSION ${PROJECT_VERSION} @@ -230,20 +240,21 @@ write_basic_package_version_file( configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/MapnikConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfig.cmake" - INSTALL_DESTINATION lib/cmake/mapnik + INSTALL_DESTINATION ${INSTALL_CMAKE_DIR} + PATH_VARS INCLUDE_INSTALL_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfigVersion.cmake" - DESTINATION lib/cmake/mapnik + DESTINATION ${INSTALL_CMAKE_DIR} ) install(EXPORT MapnikTargets FILE MapnikTargets.cmake NAMESPACE mapnik:: - DESTINATION lib/cmake/mapnik + DESTINATION ${INSTALL_CMAKE_DIR} ) install(DIRECTORY include/ TYPE INCLUDE) install(DIRECTORY deps/agg/include/ TYPE INCLUDE) -install(DIRECTORY fonts/ DESTINATION bin/fonts FILES_MATCHING PATTERN "*.py" EXCLUDE PATTERN "*") +install(DIRECTORY fonts/ DESTINATION ${FONTS_INSTALL_DIR} FILES_MATCHING PATTERN "*.py" EXCLUDE PATTERN "*") diff --git a/cmake/MapnikConfig.cmake.in b/cmake/MapnikConfig.cmake.in index 4a1773f42e..3075df2d9d 100644 --- a/cmake/MapnikConfig.cmake.in +++ b/cmake/MapnikConfig.cmake.in @@ -1,5 +1,9 @@ @PACKAGE_INIT@ +set_and_check(MAPNIK_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@" CACHE STRING "") +set_and_check(MAPNIK_PLUGINS_DIR "@PACKAGE_PLUGINS_INSTALL_DIR@" CACHE STRING "") +set_and_check(MAPNIK_PLUGINS_DIR "@PACKAGE_FONTS_INSTALL_DIR@" CACHE STRING "") + include("${CMAKE_CURRENT_LIST_DIR}/MapnikTargets.cmake") check_required_components(mapnik) diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index bc4aa0dc31..721b761957 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -35,8 +35,8 @@ target_link_libraries(mapnik-viewer PRIVATE ) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini "[mapnik] -plugins_dir=plugins/input -fonts/1/dir=fonts" +plugins_dir=${ABSOLUTE_PLUGINS_INSTALL_DIR} +fonts/1/dir=${ABSOLUTE_FONTS_INSTALL_DIR}" ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini DESTINATION bin) install(TARGETS mapnik-viewer diff --git a/plugins/input/csv/CMakeLists.txt b/plugins/input/csv/CMakeLists.txt index 4597cee156..bef173f84d 100644 --- a/plugins/input/csv/CMakeLists.txt +++ b/plugins/input/csv/CMakeLists.txt @@ -22,7 +22,5 @@ set_target_properties(input-csv PROPERTIES SUFFIX ".input") #install(TARGETS input-csv DESTINATION bin/plugins/input) install(TARGETS input-csv - LIBRARY DESTINATION lib/plugins/input - ARCHIVE DESTINATION lib/plugins/input - RUNTIME DESTINATION bin/plugins/input + RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} ) \ No newline at end of file diff --git a/plugins/input/gdal/CMakeLists.txt b/plugins/input/gdal/CMakeLists.txt index 4c2919cc11..366b3f920a 100644 --- a/plugins/input/gdal/CMakeLists.txt +++ b/plugins/input/gdal/CMakeLists.txt @@ -20,7 +20,5 @@ set_target_properties(input-gdal PROPERTIES OUTPUT_NAME "gdal") set_target_properties(input-gdal PROPERTIES SUFFIX ".input") install(TARGETS input-gdal - LIBRARY DESTINATION lib/plugins/input - ARCHIVE DESTINATION lib/plugins/input - RUNTIME DESTINATION bin/plugins/input + RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} ) diff --git a/plugins/input/geobuf/CMakeLists.txt b/plugins/input/geobuf/CMakeLists.txt index 75bd7af2a8..3e36629eac 100644 --- a/plugins/input/geobuf/CMakeLists.txt +++ b/plugins/input/geobuf/CMakeLists.txt @@ -16,7 +16,5 @@ set_target_properties(input-geobuf PROPERTIES OUTPUT_NAME "geobuf") set_target_properties(input-geobuf PROPERTIES SUFFIX ".input") install(TARGETS input-geobuf - LIBRARY DESTINATION lib/plugins/input - ARCHIVE DESTINATION lib/plugins/input - RUNTIME DESTINATION bin/plugins/input -) + RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} +) \ No newline at end of file diff --git a/plugins/input/geojson/CMakeLists.txt b/plugins/input/geojson/CMakeLists.txt index d8f945e0c4..26a0821a2b 100644 --- a/plugins/input/geojson/CMakeLists.txt +++ b/plugins/input/geojson/CMakeLists.txt @@ -20,7 +20,5 @@ set_target_properties(input-geojson PROPERTIES OUTPUT_NAME "geojson") set_target_properties(input-geojson PROPERTIES SUFFIX ".input") install(TARGETS input-geojson - LIBRARY DESTINATION lib/plugins/input - ARCHIVE DESTINATION lib/plugins/input - RUNTIME DESTINATION bin/plugins/input + RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} ) diff --git a/plugins/input/ogr/CMakeLists.txt b/plugins/input/ogr/CMakeLists.txt index 034311c7e0..c01c6bb5fb 100644 --- a/plugins/input/ogr/CMakeLists.txt +++ b/plugins/input/ogr/CMakeLists.txt @@ -22,7 +22,5 @@ set_target_properties(input-ogr PROPERTIES OUTPUT_NAME "ogr") set_target_properties(input-ogr PROPERTIES SUFFIX ".input") install(TARGETS input-ogr - LIBRARY DESTINATION lib/plugins/input - ARCHIVE DESTINATION lib/plugins/input - RUNTIME DESTINATION bin/plugins/input + RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} ) diff --git a/plugins/input/pgraster/CMakeLists.txt b/plugins/input/pgraster/CMakeLists.txt index 20ae20760c..a6166128dd 100644 --- a/plugins/input/pgraster/CMakeLists.txt +++ b/plugins/input/pgraster/CMakeLists.txt @@ -21,7 +21,5 @@ set_target_properties(input-pgraster PROPERTIES OUTPUT_NAME "pgraster") set_target_properties(input-pgraster PROPERTIES SUFFIX ".input") install(TARGETS input-pgraster - LIBRARY DESTINATION lib/plugins/input - ARCHIVE DESTINATION lib/plugins/input - RUNTIME DESTINATION bin/plugins/input + RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} ) diff --git a/plugins/input/postgis/CMakeLists.txt b/plugins/input/postgis/CMakeLists.txt index 3085e62468..ba3192a98a 100644 --- a/plugins/input/postgis/CMakeLists.txt +++ b/plugins/input/postgis/CMakeLists.txt @@ -20,7 +20,5 @@ set_target_properties(input-postgis PROPERTIES OUTPUT_NAME "postgis") set_target_properties(input-postgis PROPERTIES SUFFIX ".input") install(TARGETS input-postgis - LIBRARY DESTINATION lib/plugins/input - ARCHIVE DESTINATION lib/plugins/input - RUNTIME DESTINATION bin/plugins/input + RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} ) diff --git a/plugins/input/raster/CMakeLists.txt b/plugins/input/raster/CMakeLists.txt index 557668536b..2aed0fdc0d 100644 --- a/plugins/input/raster/CMakeLists.txt +++ b/plugins/input/raster/CMakeLists.txt @@ -18,7 +18,5 @@ set_target_properties(input-raster PROPERTIES OUTPUT_NAME "raster") set_target_properties(input-raster PROPERTIES SUFFIX ".input") install(TARGETS input-raster - LIBRARY DESTINATION lib/plugins/input - ARCHIVE DESTINATION lib/plugins/input - RUNTIME DESTINATION bin/plugins/input + RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} ) diff --git a/plugins/input/shape/CMakeLists.txt b/plugins/input/shape/CMakeLists.txt index 64beadd574..6753eb9dea 100644 --- a/plugins/input/shape/CMakeLists.txt +++ b/plugins/input/shape/CMakeLists.txt @@ -21,7 +21,5 @@ set_target_properties(input-shape PROPERTIES OUTPUT_NAME "shape") set_target_properties(input-shape PROPERTIES SUFFIX ".input") install(TARGETS input-shape - LIBRARY DESTINATION lib/plugins/input - ARCHIVE DESTINATION lib/plugins/input - RUNTIME DESTINATION bin/plugins/input + RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} ) diff --git a/plugins/input/sqlite/CMakeLists.txt b/plugins/input/sqlite/CMakeLists.txt index 8b4a57cff9..439d19dfb8 100644 --- a/plugins/input/sqlite/CMakeLists.txt +++ b/plugins/input/sqlite/CMakeLists.txt @@ -20,7 +20,5 @@ set_target_properties(input-sqlite PROPERTIES OUTPUT_NAME "sqlite") set_target_properties(input-sqlite PROPERTIES SUFFIX ".input") install(TARGETS input-sqlite - LIBRARY DESTINATION lib/plugins/input - ARCHIVE DESTINATION lib/plugins/input - RUNTIME DESTINATION bin/plugins/input + RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} ) diff --git a/plugins/input/topojson/CMakeLists.txt b/plugins/input/topojson/CMakeLists.txt index f727a5e19b..6b3ffb16f4 100644 --- a/plugins/input/topojson/CMakeLists.txt +++ b/plugins/input/topojson/CMakeLists.txt @@ -18,7 +18,5 @@ set_target_properties(input-topojson PROPERTIES OUTPUT_NAME "topojson") set_target_properties(input-topojson PROPERTIES SUFFIX ".input") install(TARGETS input-topojson - LIBRARY DESTINATION lib/plugins/input - ARCHIVE DESTINATION lib/plugins/input - RUNTIME DESTINATION bin/plugins/input + RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4009311347..a73a0f288b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,7 @@ project(mapnik-test) +find_package(Boost 1.74 REQUIRED COMPONENTS program_options) + include(FetchContent) include(CopyDllsForDebug) @@ -14,8 +16,6 @@ set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) add_library(Catch INTERFACE) target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}) - - add_executable(mapnik-test-unit unit/run.cpp unit/color/css_color.cpp diff --git a/utils/geometry_to_wkb/CMakeLists.txt b/utils/geometry_to_wkb/CMakeLists.txt index b6ec671bc2..adb0c84090 100644 --- a/utils/geometry_to_wkb/CMakeLists.txt +++ b/utils/geometry_to_wkb/CMakeLists.txt @@ -1,3 +1,5 @@ +project(geometry_to_wkb) + add_executable(geometry_to_wkb main.cpp) target_link_libraries(geometry_to_wkb PRIVATE diff --git a/utils/mapnik-index/CMakeLists.txt b/utils/mapnik-index/CMakeLists.txt index b06de87b2c..e2c8f2cfb0 100644 --- a/utils/mapnik-index/CMakeLists.txt +++ b/utils/mapnik-index/CMakeLists.txt @@ -1,3 +1,7 @@ +project(mapnik-index) + +find_package(Boost 1.74 REQUIRED COMPONENTS program_options) + add_executable(mapnik-index mapnik-index.cpp process_csv_file.cpp diff --git a/utils/mapnik-render/CMakeLists.txt b/utils/mapnik-render/CMakeLists.txt index 0e2e6cd107..b8dde3cd6c 100644 --- a/utils/mapnik-render/CMakeLists.txt +++ b/utils/mapnik-render/CMakeLists.txt @@ -1,3 +1,7 @@ +project(mapnik-render) + +find_package(Boost 1.74 REQUIRED COMPONENTS program_options) + add_executable(mapnik-render mapnik-render.cpp) target_link_libraries(mapnik-render PRIVATE diff --git a/utils/ogrindex/CMakeLists.txt b/utils/ogrindex/CMakeLists.txt index eafa23289c..7ecad8db9a 100644 --- a/utils/ogrindex/CMakeLists.txt +++ b/utils/ogrindex/CMakeLists.txt @@ -1,3 +1,5 @@ +project(ogrindex) + add_executable(ogrindex ogrindex.cpp) diff --git a/utils/pgsql2sqlite/CMakeLists.txt b/utils/pgsql2sqlite/CMakeLists.txt index 3ba2f66bc2..baa4ff1560 100644 --- a/utils/pgsql2sqlite/CMakeLists.txt +++ b/utils/pgsql2sqlite/CMakeLists.txt @@ -1,4 +1,5 @@ - +project(pgsql2sqlite) +find_package(Boost 1.74 REQUIRED COMPONENTS program_options) find_package(SQLite3 REQUIRED) find_package(PostgreSQL REQUIRED) diff --git a/utils/shapeindex/CMakeLists.txt b/utils/shapeindex/CMakeLists.txt index 92ab1594a2..b1a555d77f 100644 --- a/utils/shapeindex/CMakeLists.txt +++ b/utils/shapeindex/CMakeLists.txt @@ -1,3 +1,7 @@ +project(shapeindex) + +find_package(Boost 1.74 REQUIRED COMPONENTS program_options) + add_executable(shapeindex shapeindex.cpp ) diff --git a/utils/svg2png/CMakeLists.txt b/utils/svg2png/CMakeLists.txt index b0819685b4..eb10219037 100644 --- a/utils/svg2png/CMakeLists.txt +++ b/utils/svg2png/CMakeLists.txt @@ -1,3 +1,7 @@ +project(svg2png) + +find_package(Boost 1.74 REQUIRED COMPONENTS program_options) + add_executable(svg2png svg2png.cpp ) From 386674d7992f7fabd83007d611419ea471ded6c3 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sun, 22 Nov 2020 22:02:17 +0100 Subject: [PATCH 033/141] name fonts correctly --- cmake/MapnikConfig.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/MapnikConfig.cmake.in b/cmake/MapnikConfig.cmake.in index 3075df2d9d..0785d57f7e 100644 --- a/cmake/MapnikConfig.cmake.in +++ b/cmake/MapnikConfig.cmake.in @@ -2,7 +2,7 @@ set_and_check(MAPNIK_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@" CACHE STRING "") set_and_check(MAPNIK_PLUGINS_DIR "@PACKAGE_PLUGINS_INSTALL_DIR@" CACHE STRING "") -set_and_check(MAPNIK_PLUGINS_DIR "@PACKAGE_FONTS_INSTALL_DIR@" CACHE STRING "") +set_and_check(MAPNIK_FONTS_DIR "@PACKAGE_FONTS_INSTALL_DIR@" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/MapnikTargets.cmake") From 6496df7938de1980cdbcbc4a4f4b4de8f24781d6 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sun, 22 Nov 2020 22:06:15 +0100 Subject: [PATCH 034/141] do not use the install interface for mapbox deps --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9de080db4e..a3d709443b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,6 @@ if(USE_EXTERNAL_MAPBOX_GEOMETRY) else() set(MAPBOX_GEOMETRY_INCLUDE_DIRS $ - $ ) endif() if(NOT MAPBOX_GEOMETRY_INCLUDE_DIRS) @@ -86,7 +85,6 @@ if(USE_EXTERNAL_MAPBOX_POLYLABEL) else() set(MAPBOX_POLYLABEL_INCLUDE_DIRS $ - $ ) endif() if(NOT MAPBOX_POLYLABEL_INCLUDE_DIRS) @@ -101,7 +99,6 @@ if(USE_EXTERNAL_MAPBOX_PROTOZERO) else() set(MAPBOX_PROTOZERO_INCLUDE_DIRS $ - $ ) endif() if(NOT MAPBOX_PROTOZERO_INCLUDE_DIRS) @@ -116,7 +113,6 @@ if(USE_EXTERNAL_MAPBOX_VARIANT) else() set(MAPBOX_VARIANT_INCLUDE_DIRS $ - $ ) endif() if(NOT MAPBOX_VARIANT_INCLUDE_DIRS) From 1918a94b1ca70db42e146c5e51d1ee6de612eb31 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sun, 22 Nov 2020 22:11:27 +0100 Subject: [PATCH 035/141] cache var for cxx standard --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a3d709443b..06eaa23d41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,10 +52,10 @@ get_filename_component(ABSOLUTE_PLUGINS_INSTALL_DIR ${PLUGINS_INSTALL_DIR} ABSOL message("Installing plugins to ${ABSOLUTE_PLUGINS_INSTALL_DIR}") set(FONTS_INSTALL_DIR bin/fonts CACHE STRING "installs the fonts in the specified directory") get_filename_component(ABSOLUTE_FONTS_INSTALL_DIR ${FONTS_INSTALL_DIR} ABSOLUTE) -message("Installing fonts to ${FONTS_INSTALL_DIR}") +message("Installing fonts to ${ABSOLUTE_FONTS_INSTALL_DIR}") - -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++11 is minimum.") +message("Using c++${CMAKE_CXX_STANDARD}") find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) find_package(ICU REQUIRED COMPONENTS uc) From ddf132f1845351b49bd9bc9da35ffb412ac20566 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 25 Nov 2020 08:23:41 +0100 Subject: [PATCH 036/141] added correct plugin default paths --- CMakeLists.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06eaa23d41..4ab9d29d49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,9 +47,15 @@ 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) -set(PLUGINS_INSTALL_DIR bin/plugins/input CACHE STRING "installs the plugins in the specified directory") +if(WIN32) + set(DEFAULT_PLUGINS_INSTALL_DIR bin/mapnik/input) +else() + set(DEFAULT_PLUGINS_INSTALL_DIR lib/mapnik/input) +endif() +set(PLUGINS_INSTALL_DIR ${DEFAULT_PLUGINS_INSTALL_DIR} CACHE STRING "installs the plugins in the specified directory") get_filename_component(ABSOLUTE_PLUGINS_INSTALL_DIR ${PLUGINS_INSTALL_DIR} ABSOLUTE) message("Installing plugins to ${ABSOLUTE_PLUGINS_INSTALL_DIR}") + set(FONTS_INSTALL_DIR bin/fonts CACHE STRING "installs the fonts in the specified directory") get_filename_component(ABSOLUTE_FONTS_INSTALL_DIR ${FONTS_INSTALL_DIR} ABSOLUTE) message("Installing fonts to ${ABSOLUTE_FONTS_INSTALL_DIR}") From 85bbc80c6ce11755373f92f5b318fdecceb8ebb7 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 25 Nov 2020 10:45:20 +0100 Subject: [PATCH 037/141] update catch dep --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a73a0f288b..fe7a2166bc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -8,7 +8,7 @@ include(CopyDllsForDebug) FetchContent_Declare( Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v2.13.1) + GIT_TAG v2.13.3) FetchContent_MakeAvailable(Catch2) # Prepare "Catch" library for other executables From c8b8706bb8ce2f7d7351013ed32f4cc458363055 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 25 Nov 2020 10:56:49 +0100 Subject: [PATCH 038/141] create boilerplate code --- .github/workflows/cmake.yml | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/cmake.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 0000000000..d5217692c3 --- /dev/null +++ b/.github/workflows/cmake.yml @@ -0,0 +1,46 @@ +name: CMake + +on: [push] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + build: + # The CMake configure and build commands are platform agnostic and should work equally + # well on Windows or Mac. You can convert this to a matrix build if you need + # cross-platform coverage. + # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Create Build Environment + # Some projects don't allow in-source building, so create a separate build directory + # We'll use this as our working directory for all subsequent commands + run: cmake -E make_directory ${{runner.workspace}}/build + + - name: Configure CMake + # Use a bash shell so we can use the same syntax for environment variable + # access regardless of the host operating system + shell: bash + working-directory: ${{runner.workspace}}/build + # Note the current convention is to use the -S and -B options here to specify source + # and build directories, but this is only available with CMake 3.13 and higher. + # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 + run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE + + - name: Build + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute the build. You can specify a specific target with "--target " + run: cmake --build . --config $BUILD_TYPE + + - name: Test + working-directory: ${{runner.workspace}}/build + shell: bash + # Execute tests defined by the CMake configuration. + # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail + run: ctest -C $BUILD_TYPE From 5b175c2577a7a68156685e91d1110b6db916a56d Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 25 Nov 2020 12:16:06 +0100 Subject: [PATCH 039/141] added cache variable for lib/bin/archive output --- CMakeLists.txt | 19 ++++++++++++++++++- demo/c++/CMakeLists.txt | 6 +++--- demo/viewer/CMakeLists.txt | 6 +++--- deps/vcpkg | 1 + src/CMakeLists.txt | 6 +++--- src/json/CMakeLists.txt | 6 +++--- src/wkt/CMakeLists.txt | 6 +++--- test/CMakeLists.txt | 4 ++++ utils/geometry_to_wkb/CMakeLists.txt | 4 +++- utils/mapnik-index/CMakeLists.txt | 4 +++- utils/mapnik-render/CMakeLists.txt | 4 +++- utils/ogrindex/CMakeLists.txt | 4 +++- utils/pgsql2sqlite/CMakeLists.txt | 4 +++- utils/shapeindex/CMakeLists.txt | 4 +++- utils/svg2png/CMakeLists.txt | 4 +++- 15 files changed, 59 insertions(+), 23 deletions(-) create mode 160000 deps/vcpkg diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ab9d29d49..a9aaaf757f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ project(mapnik set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -option(BUILD_SHARED_LIBS "build mapnik dynamic" 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) @@ -63,6 +63,23 @@ message("Installing fonts to ${ABSOLUTE_FONTS_INSTALL_DIR}") set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++11 is minimum.") message("Using c++${CMAKE_CXX_STANDARD}") +if(WIN32) + set(DEFAULT_BIN_DIR bin) + set(DEFAULT_LIB_DIR lib) + set(DEFAULT_ARCHIVE_DIR lib) +else() + include(GNUInstallDirs) + set(DEFAULT_BIN_DIR ${CMAKE_INSTALL_BINDIR}) + set(DEFAULT_LIB_DIR ${CMAKE_INSTALL_LIBDIR}) + set(DEFAULT_ARCHIVE_DIR ${CMAKE_INSTALL_LIBDIR}) +endif() +# https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#runtime-output-artifacts +set(MAPNIK_BIN_DIR ${DEFAULT_BIN_DIR} CACHE STRING "Install directory for binaries") +# https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#library-output-artifacts +set(MAPNIK_LIB_DIR ${DEFAULT_LIB_DIR} CACHE STRING "Install directory for libraries") +# https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#archive-output-artifacts +set(MAPNIK_ARCHIVE_DIR ${DEFAULT_ARCHIVE_DIR} CACHE STRING "Install directory for archives") + find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) find_package(ICU REQUIRED COMPONENTS uc) find_package(Freetype REQUIRED) diff --git a/demo/c++/CMakeLists.txt b/demo/c++/CMakeLists.txt index 84627451bd..48e83ce780 100644 --- a/demo/c++/CMakeLists.txt +++ b/demo/c++/CMakeLists.txt @@ -5,7 +5,7 @@ add_executable(mapnik-demo rundemo.cpp) target_link_libraries(mapnik-demo PRIVATE mapnik::headers mapnik::agg mapnik::mapnik) install(TARGETS mapnik-demo - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index 721b761957..96e6414987 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -40,7 +40,7 @@ fonts/1/dir=${ABSOLUTE_FONTS_INSTALL_DIR}" ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini DESTINATION bin) install(TARGETS mapnik-viewer - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) diff --git a/deps/vcpkg b/deps/vcpkg new file mode 160000 index 0000000000..6e073f1686 --- /dev/null +++ b/deps/vcpkg @@ -0,0 +1 @@ +Subproject commit 6e073f168652a551d8f29d19481ec67be3fccac8 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index be6388656c..2ff07f3fcf 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -299,9 +299,9 @@ target_link_libraries(mapnik PRIVATE install(TARGETS mapnik EXPORT MapnikTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} INCLUDES DESTINATION include/ PUBLIC_HEADER DESTINATION include/ ) diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index c3b818387d..8428e87e4a 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -28,7 +28,7 @@ target_link_libraries(json PRIVATE mapnik::headers ${ICUU_LIB}) install(TARGETS json EXPORT MapnikTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index 82de6f9cff..c787df8d5f 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -21,7 +21,7 @@ target_link_libraries(wkt PRIVATE mapnik::headers) install(TARGETS wkt EXPORT MapnikTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fe7a2166bc..eb5149e14e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,6 +16,10 @@ set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) add_library(Catch INTERFACE) target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}) +# 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) + add_executable(mapnik-test-unit unit/run.cpp unit/color/css_color.cpp diff --git a/utils/geometry_to_wkb/CMakeLists.txt b/utils/geometry_to_wkb/CMakeLists.txt index adb0c84090..b9f4cb3b13 100644 --- a/utils/geometry_to_wkb/CMakeLists.txt +++ b/utils/geometry_to_wkb/CMakeLists.txt @@ -9,5 +9,7 @@ target_link_libraries(geometry_to_wkb PRIVATE install(TARGETS geometry_to_wkb EXPORT MapnikTargets - RUNTIME DESTINATION bin + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) \ No newline at end of file diff --git a/utils/mapnik-index/CMakeLists.txt b/utils/mapnik-index/CMakeLists.txt index e2c8f2cfb0..4926c1b0ea 100644 --- a/utils/mapnik-index/CMakeLists.txt +++ b/utils/mapnik-index/CMakeLists.txt @@ -17,5 +17,7 @@ target_link_libraries(mapnik-index PRIVATE ) install(TARGETS mapnik-index EXPORT MapnikTargets - RUNTIME DESTINATION bin + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) \ No newline at end of file diff --git a/utils/mapnik-render/CMakeLists.txt b/utils/mapnik-render/CMakeLists.txt index b8dde3cd6c..3e7ef65f19 100644 --- a/utils/mapnik-render/CMakeLists.txt +++ b/utils/mapnik-render/CMakeLists.txt @@ -11,5 +11,7 @@ target_link_libraries(mapnik-render PRIVATE ) install(TARGETS mapnik-render EXPORT MapnikTargets - RUNTIME DESTINATION bin + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) \ No newline at end of file diff --git a/utils/ogrindex/CMakeLists.txt b/utils/ogrindex/CMakeLists.txt index 7ecad8db9a..8e9eed31a1 100644 --- a/utils/ogrindex/CMakeLists.txt +++ b/utils/ogrindex/CMakeLists.txt @@ -7,5 +7,7 @@ target_link_libraries(ogrindex PRIVATE mapnik::headers mapnik::mapnik) install(TARGETS ogrindex EXPORT MapnikTargets - RUNTIME DESTINATION bin + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) diff --git a/utils/pgsql2sqlite/CMakeLists.txt b/utils/pgsql2sqlite/CMakeLists.txt index baa4ff1560..c98427ec95 100644 --- a/utils/pgsql2sqlite/CMakeLists.txt +++ b/utils/pgsql2sqlite/CMakeLists.txt @@ -19,5 +19,7 @@ target_link_libraries(pgsql2sqlite PRIVATE install(TARGETS pgsql2sqlite EXPORT MapnikTargets - RUNTIME DESTINATION bin + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) diff --git a/utils/shapeindex/CMakeLists.txt b/utils/shapeindex/CMakeLists.txt index b1a555d77f..56eb501bd5 100644 --- a/utils/shapeindex/CMakeLists.txt +++ b/utils/shapeindex/CMakeLists.txt @@ -14,5 +14,7 @@ target_link_libraries(shapeindex PRIVATE ) install(TARGETS shapeindex EXPORT MapnikTargets - RUNTIME DESTINATION bin + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) \ No newline at end of file diff --git a/utils/svg2png/CMakeLists.txt b/utils/svg2png/CMakeLists.txt index eb10219037..e1c691c058 100644 --- a/utils/svg2png/CMakeLists.txt +++ b/utils/svg2png/CMakeLists.txt @@ -14,5 +14,7 @@ target_link_libraries(svg2png PRIVATE ) install(TARGETS svg2png EXPORT MapnikTargets - RUNTIME DESTINATION bin + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) \ No newline at end of file From 5bb743bca3bdebc93b7860764a094f32d0a844c1 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 25 Nov 2020 12:17:31 +0100 Subject: [PATCH 040/141] some line endings --- utils/geometry_to_wkb/CMakeLists.txt | 2 +- utils/mapnik-index/CMakeLists.txt | 2 +- utils/mapnik-render/CMakeLists.txt | 2 +- utils/shapeindex/CMakeLists.txt | 2 +- utils/svg2png/CMakeLists.txt | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/geometry_to_wkb/CMakeLists.txt b/utils/geometry_to_wkb/CMakeLists.txt index b9f4cb3b13..f706fd5848 100644 --- a/utils/geometry_to_wkb/CMakeLists.txt +++ b/utils/geometry_to_wkb/CMakeLists.txt @@ -12,4 +12,4 @@ install(TARGETS geometry_to_wkb LIBRARY DESTINATION ${MAPNIK_LIB_DIR} ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) \ No newline at end of file +) diff --git a/utils/mapnik-index/CMakeLists.txt b/utils/mapnik-index/CMakeLists.txt index 4926c1b0ea..22076f781f 100644 --- a/utils/mapnik-index/CMakeLists.txt +++ b/utils/mapnik-index/CMakeLists.txt @@ -20,4 +20,4 @@ install(TARGETS mapnik-index LIBRARY DESTINATION ${MAPNIK_LIB_DIR} ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) \ No newline at end of file +) diff --git a/utils/mapnik-render/CMakeLists.txt b/utils/mapnik-render/CMakeLists.txt index 3e7ef65f19..eed2e90a64 100644 --- a/utils/mapnik-render/CMakeLists.txt +++ b/utils/mapnik-render/CMakeLists.txt @@ -14,4 +14,4 @@ install(TARGETS mapnik-render LIBRARY DESTINATION ${MAPNIK_LIB_DIR} ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) \ No newline at end of file +) diff --git a/utils/shapeindex/CMakeLists.txt b/utils/shapeindex/CMakeLists.txt index 56eb501bd5..969c868170 100644 --- a/utils/shapeindex/CMakeLists.txt +++ b/utils/shapeindex/CMakeLists.txt @@ -17,4 +17,4 @@ install(TARGETS shapeindex LIBRARY DESTINATION ${MAPNIK_LIB_DIR} ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) \ No newline at end of file +) diff --git a/utils/svg2png/CMakeLists.txt b/utils/svg2png/CMakeLists.txt index e1c691c058..015de5c3d0 100644 --- a/utils/svg2png/CMakeLists.txt +++ b/utils/svg2png/CMakeLists.txt @@ -17,4 +17,4 @@ install(TARGETS svg2png LIBRARY DESTINATION ${MAPNIK_LIB_DIR} ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) \ No newline at end of file +) From 86375c2fa86f1ca9e5cf596eea3a50f5248a6d93 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 25 Nov 2020 13:20:07 +0100 Subject: [PATCH 041/141] do not use absolute paths for fonts/plugins --- CMakeLists.txt | 33 ++++++++++++++++----------------- demo/viewer/CMakeLists.txt | 4 ++-- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a9aaaf757f..1726097455 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,19 +47,6 @@ 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) -if(WIN32) - set(DEFAULT_PLUGINS_INSTALL_DIR bin/mapnik/input) -else() - set(DEFAULT_PLUGINS_INSTALL_DIR lib/mapnik/input) -endif() -set(PLUGINS_INSTALL_DIR ${DEFAULT_PLUGINS_INSTALL_DIR} CACHE STRING "installs the plugins in the specified directory") -get_filename_component(ABSOLUTE_PLUGINS_INSTALL_DIR ${PLUGINS_INSTALL_DIR} ABSOLUTE) -message("Installing plugins to ${ABSOLUTE_PLUGINS_INSTALL_DIR}") - -set(FONTS_INSTALL_DIR bin/fonts CACHE STRING "installs the fonts in the specified directory") -get_filename_component(ABSOLUTE_FONTS_INSTALL_DIR ${FONTS_INSTALL_DIR} ABSOLUTE) -message("Installing fonts to ${ABSOLUTE_FONTS_INSTALL_DIR}") - set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++11 is minimum.") message("Using c++${CMAKE_CXX_STANDARD}") @@ -80,6 +67,19 @@ set(MAPNIK_LIB_DIR ${DEFAULT_LIB_DIR} CACHE STRING "Install directory for librar # https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#archive-output-artifacts set(MAPNIK_ARCHIVE_DIR ${DEFAULT_ARCHIVE_DIR} CACHE STRING "Install directory for archives") +set(INSTALL_CMAKE_DIR ${MAPNIK_LIB_DIR}/mapnik/cmake CACHE STRING "Install directory of the cmake targets") + +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") +message("Installing plugins to ${PLUGINS_INSTALL_DIR}") + +set(FONTS_INSTALL_DIR ${MAPNIK_BIN_DIR}/fonts CACHE STRING "installs the fonts in the specified directory") +message("Installing fonts to ${FONTS_INSTALL_DIR}") + find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) find_package(ICU REQUIRED COMPONENTS uc) find_package(Freetype REQUIRED) @@ -228,9 +228,9 @@ target_compile_definitions(headers INTERFACE ${MAPNIK_COMPILE_DEFS}) install(TARGETS headers EXPORT MapnikTargets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} INCLUDES DESTINATION include/ PUBLIC_HEADER DESTINATION include/ ) @@ -249,7 +249,6 @@ endif() include(CMakePackageConfigHelpers) # set the cmake targets install location -set(INSTALL_CMAKE_DIR lib/cmake) set(INCLUDE_INSTALL_DIR include/) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfigVersion.cmake" diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index 96e6414987..45604e28d8 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -35,8 +35,8 @@ target_link_libraries(mapnik-viewer PRIVATE ) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini "[mapnik] -plugins_dir=${ABSOLUTE_PLUGINS_INSTALL_DIR} -fonts/1/dir=${ABSOLUTE_FONTS_INSTALL_DIR}" +plugins_dir=${PLUGINS_INSTALL_DIR} +fonts/1/dir=${FONTS_INSTALL_DIR}" ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini DESTINATION bin) install(TARGETS mapnik-viewer From 2397079265077241d4c01560b83e52635ff5f5e2 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 25 Nov 2020 15:42:33 +0100 Subject: [PATCH 042/141] use status message --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1726097455..f622ed18c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,7 @@ option(BUILD_UTILITY_SHAPEINDEX "builds the utility program shapeindex" ON) option(BUILD_UTILITY_SVG2PNG "builds the utility program svg2png" ON) set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++11 is minimum.") -message("Using c++${CMAKE_CXX_STANDARD}") +message(STATUS "Using c++${CMAKE_CXX_STANDARD}") if(WIN32) set(DEFAULT_BIN_DIR bin) @@ -75,10 +75,10 @@ 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") -message("Installing plugins to ${PLUGINS_INSTALL_DIR}") +message(STATUS "Installing plugins to ${PLUGINS_INSTALL_DIR}") set(FONTS_INSTALL_DIR ${MAPNIK_BIN_DIR}/fonts CACHE STRING "installs the fonts in the specified directory") -message("Installing fonts to ${FONTS_INSTALL_DIR}") +message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}") find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) find_package(ICU REQUIRED COMPONENTS uc) From 68ac622f5b3c11250dcba1c3a80f2d88a8e33a00 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 17 Dec 2020 10:21:25 +0100 Subject: [PATCH 043/141] remove vcpkg folder --- deps/vcpkg | 1 - 1 file changed, 1 deletion(-) delete mode 160000 deps/vcpkg diff --git a/deps/vcpkg b/deps/vcpkg deleted file mode 160000 index 6e073f1686..0000000000 --- a/deps/vcpkg +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6e073f168652a551d8f29d19481ec67be3fccac8 From 4ed997d4391def8e2fd94fdbb7e709e8ad9e0b84 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sun, 24 Jan 2021 19:34:51 +0100 Subject: [PATCH 044/141] better support for proj --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f622ed18c5..5c2c1f4fde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,6 +144,7 @@ endif() set(MAPNIK_COMPILE_DEFS "") set(MAPNIK_OPTIONAL_LIBS "") +set(MAPNIK_OPTIONAL_LIBS_INCLUDE "") if(USE_LIBXML2) message(STATUS "Using LibXml2") @@ -187,10 +188,12 @@ if(USE_CAIRO) endif() if(USE_PROJ4) + #https://proj.org/development/cmake.html message(STATUS "Using PROJ4") find_package(PROJ4 CONFIG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ4 ACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1) - list(APPEND MAPNIK_OPTIONAL_LIBS proj) + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ4_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) @@ -214,6 +217,7 @@ target_include_directories(headers INTERFACE $ $ $ + ${MAPNIK_OPTIONAL_LIBS_INCLUDE} ) target_link_libraries(headers INTERFACE Boost::boost From bb53d7cb4eaa8676e12500705c430c15e3527f6e Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sun, 24 Jan 2021 19:35:21 +0100 Subject: [PATCH 045/141] enable position independent code for wkt and json --- src/json/CMakeLists.txt | 2 ++ src/wkt/CMakeLists.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index 8428e87e4a..a8430a2f71 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -17,6 +17,8 @@ add_library(json STATIC ) add_library(mapnik::json ALIAS json) +set_property(TARGET json PROPERTY POSITION_INDEPENDENT_CODE ON) + target_include_directories(json PRIVATE ${JPEG_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index c787df8d5f..1741834c2d 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -9,6 +9,8 @@ add_library(wkt STATIC ) add_library(mapnik::wkt ALIAS wkt) +set_property(TARGET wkt PROPERTY POSITION_INDEPENDENT_CODE ON) + target_include_directories(wkt PRIVATE ${MAPNIK_INCLUDE_PATH} ${JPEG_INCLUDE_DIR} From 12fff144241e3669b1f85e0daa07c1f3c5652e7d Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sun, 24 Jan 2021 19:36:01 +0100 Subject: [PATCH 046/141] temporarily remove find dll. only windows specific. needs better impl --- test/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index eb5149e14e..63a0da82cc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -167,9 +167,6 @@ target_link_libraries( include(CTest) include(${catch2_SOURCE_DIR}/contrib/Catch.cmake) include(${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake) -set(APPS mapnik-test-unit mapnik-test-visual mapnik::mapnik) # paths to executables -set(DIRS ${CMAKE_BINARY_DIR}/src/RelWithDebInfo) # directories to search for prerequisites -copy_dlls_for_debug(${APPS} \"\" ${DIRS}) file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test) file(COPY data-visual DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test) @@ -178,4 +175,4 @@ ParseAndAddCatchTests(mapnik-test-unit) catch_discover_tests(agg_rasterizer_integer_overflow_test) catch_discover_tests(datasource_registration_test) catch_discover_tests(font_registration_test) -catch_discover_tests(map_xml_test) \ No newline at end of file +catch_discover_tests(map_xml_test) From e2f6ddff510afcc779368d9da929c2e7115cc9ac Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 27 Jan 2021 00:41:54 +0100 Subject: [PATCH 047/141] windows: copy all dlls. optional library dir if some dlls are not found. --- CMakeLists.txt | 3 ++- cmake/CopyDllsForDebug.cmake | 17 +++++++++-------- demo/viewer/CMakeLists.txt | 7 +++++++ test/CMakeLists.txt | 7 +++++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c2c1f4fde..1c533e2822 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,8 @@ project(mapnik set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +set(ADDITIONAL_LIBARIES_PATHS "" CACHE STRING "currently 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(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) @@ -79,7 +81,6 @@ message(STATUS "Installing plugins to ${PLUGINS_INSTALL_DIR}") set(FONTS_INSTALL_DIR ${MAPNIK_BIN_DIR}/fonts CACHE STRING "installs the fonts in the specified directory") message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}") - find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) find_package(ICU REQUIRED COMPONENTS uc) find_package(Freetype REQUIRED) diff --git a/cmake/CopyDllsForDebug.cmake b/cmake/CopyDllsForDebug.cmake index f2f2b153b7..7f668868a6 100644 --- a/cmake/CopyDllsForDebug.cmake +++ b/cmake/CopyDllsForDebug.cmake @@ -16,16 +16,17 @@ if(RUN_IT) else() set(THIS_FILE ${CMAKE_CURRENT_LIST_FILE}) -function(copy_dlls_for_debug _target _libs _dirs) +function(copy_dlls_for_debug _targets _libs _dirs) if(WIN32) - add_custom_command( - TARGET ${_target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -DRUN_IT:BOOL=ON -DTO_FIXUP_FILE=$ -DTO_FIXUP_LIBS=${_libs} -DTO_FIXUP_DIRS=${_dirs} -P ${THIS_FILE} - COMMENT "Fixing up dependencies for ${_target}" - VERBATIM - ) + foreach(_target ${_targets}) + add_custom_command( + TARGET ${_target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -DRUN_IT:BOOL=ON -DTO_FIXUP_FILE=$ -DTO_FIXUP_LIBS=${_libs} -DTO_FIXUP_DIRS=${_dirs} -P ${THIS_FILE} + COMMENT "Fixing up dependencies for ${_target}" + VERBATIM + ) + endforeach() endif(WIN32) endfunction() endif() - diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index 45604e28d8..599255d9f3 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -44,3 +44,10 @@ install(TARGETS mapnik-viewer ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) + + +if(WIN32) + include(CopyDllsForDebug) + add_custom_command(TARGET mapnik-viewer POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}) + copy_dlls_for_debug(mapnik-viewer \"\" \"${ADDITIONAL_LIBARIES_PATHS}\") +endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 63a0da82cc..05cdfbe99c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -168,6 +168,13 @@ include(CTest) include(${catch2_SOURCE_DIR}/contrib/Catch.cmake) include(${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake) +if(WIN32) + include(CopyDllsForDebug) + add_custom_command(TARGET mapnik-test-unit POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}) + set(APPS mapnik-test-unit agg_rasterizer_integer_overflow_test datasource_registration_test font_registration_test map_xml_test mapnik-test-visual) + copy_dlls_for_debug(${APPS} \"\" \"${ADDITIONAL_LIBARIES_PATHS}\") +endif() + file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test) file(COPY data-visual DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test) From 1d856ce58f56b99b6792b4949838598d57bf8ddd Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 27 Jan 2021 00:42:19 +0100 Subject: [PATCH 048/141] FindCairo: find debug release library --- cmake/FindCairo.cmake | 47 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/cmake/FindCairo.cmake b/cmake/FindCairo.cmake index 5bf2d339dc..c6a33fa1b8 100644 --- a/cmake/FindCairo.cmake +++ b/cmake/FindCairo.cmake @@ -63,11 +63,16 @@ find_path(Cairo_INCLUDE_DIR PATH_SUFFIXES cairo ) -find_library(Cairo_LIBRARY +find_library(Cairo_LIBRARY_RELEASE NAMES ${Cairo_NAMES} cairo HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS} ) +find_library(Cairo_LIBRARY_DEBUG + NAMES ${Cairo_NAMES} cairod + 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) @@ -86,24 +91,52 @@ if (Cairo_INCLUDE_DIR AND NOT Cairo_VERSION) endif () include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Cairo +if(Cairo_LIBRARY_RELEASE AND Cairo_LIBRARY_DEBUG) + # set the libaries varible to use the release and debug versions + find_package_handle_standard_args(Cairo FOUND_VAR Cairo_FOUND - REQUIRED_VARS Cairo_LIBRARY Cairo_INCLUDE_DIR + REQUIRED_VARS Cairo_LIBRARY_RELEASE Cairo_LIBRARY_DEBUG Cairo_INCLUDE_DIR VERSION_VAR Cairo_VERSION -) + ) + set(Cairo_LIBRARIES optimized ${Cairo_LIBRARY_RELEASE} debug ${Cairo_LIBRARY_DEBUG}) +elseif(Cairo_LIBRARY_RELEASE) + # only the release library is available + find_package_handle_standard_args(Cairo + FOUND_VAR Cairo_FOUND + REQUIRED_VARS Cairo_LIBRARY_RELEASE Cairo_INCLUDE_DIR + VERSION_VAR Cairo_VERSION + ) + set(Cairo_LIBRARIES optimized ${Cairo_LIBRARY_RELEASE}) +elseif(Cairo_LIBRARY_DEBUG) + # only the debug library is available + find_package_handle_standard_args(Cairo + FOUND_VAR Cairo_FOUND + REQUIRED_VARS Cairo_LIBRARY_DEBUG Cairo_INCLUDE_DIR + VERSION_VAR Cairo_VERSION + ) + set(Cairo_LIBRARIES debug ${Cairo_LIBRARY_DEBUG}) +else() + # neither library is available - give standard error message + find_package_handle_standard_args(Cairo + FOUND_VAR Cairo_FOUND + REQUIRED_VARS Cairo_LIBRARY_RELEASE Cairo_LIBRARY_DEBUG Cairo_INCLUDE_DIR + VERSION_VAR Cairo_VERSION + ) +endif() 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}" + IMPORTED_LOCATION "${Cairo_LIBRARY_RELEASE}" + IMPORTED_LOCATION_DEBUG "${Cairo_LIBRARY_DEBUG}" INTERFACE_COMPILE_OPTIONS "${Cairo_COMPILE_OPTIONS}" INTERFACE_INCLUDE_DIRECTORIES "${Cairo_INCLUDE_DIR}" ) endif () -mark_as_advanced(Cairo_INCLUDE_DIR Cairo_LIBRARIES) +mark_as_advanced(Cairo_INCLUDE_DIR Cairo_LIBRARY_RELEASE Cairo_LIBRARY_DEBUG) if (Cairo_FOUND) set(Cairo_LIBRARIES ${Cairo_LIBRARY}) set(Cairo_INCLUDE_DIRS ${Cairo_INCLUDE_DIR}) -endif () \ No newline at end of file +endif () From c7cb6c22527151ddac3eb94ea28d3a5eedea4d89 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 27 Jan 2021 01:17:00 +0100 Subject: [PATCH 049/141] add option to disable shared lib fixup --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c533e2822..009c13f72a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ project(mapnik set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(ADDITIONAL_LIBARIES_PATHS "" CACHE STRING "currently 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 (currently only windows) to the executable directory" ON) option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON) option(BUILD_TEST "builds the tests" ON) From e5b96b9f7b0d9e1347044e0ad728cc16452f4ce6 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 27 Jan 2021 01:20:32 +0100 Subject: [PATCH 050/141] should use the ADDITIONAL_LIBARIES_PATHS var... --- demo/viewer/CMakeLists.txt | 2 +- test/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index 599255d9f3..8d12c33e9d 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -46,7 +46,7 @@ install(TARGETS mapnik-viewer ) -if(WIN32) +if(ADDITIONAL_LIBARIES_PATHS AND WIN32) include(CopyDllsForDebug) add_custom_command(TARGET mapnik-viewer POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}) copy_dlls_for_debug(mapnik-viewer \"\" \"${ADDITIONAL_LIBARIES_PATHS}\") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 05cdfbe99c..37947404bb 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -168,7 +168,7 @@ include(CTest) include(${catch2_SOURCE_DIR}/contrib/Catch.cmake) include(${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake) -if(WIN32) +if(ADDITIONAL_LIBARIES_PATHS AND WIN32) include(CopyDllsForDebug) add_custom_command(TARGET mapnik-test-unit POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}) set(APPS mapnik-test-unit agg_rasterizer_integer_overflow_test datasource_registration_test font_registration_test map_xml_test mapnik-test-visual) From 36ee0b6638c4a137237c742c6f6a625c352bf186 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 27 Jan 2021 01:22:41 +0100 Subject: [PATCH 051/141] its getting too late.. --- demo/viewer/CMakeLists.txt | 2 +- test/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index 8d12c33e9d..c618b6fa59 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -46,7 +46,7 @@ install(TARGETS mapnik-viewer ) -if(ADDITIONAL_LIBARIES_PATHS AND WIN32) +if(COPY_LIBRARIES_FOR_EXECUTABLES AND WIN32) include(CopyDllsForDebug) add_custom_command(TARGET mapnik-viewer POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}) copy_dlls_for_debug(mapnik-viewer \"\" \"${ADDITIONAL_LIBARIES_PATHS}\") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 37947404bb..025a872d0f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -168,7 +168,7 @@ include(CTest) include(${catch2_SOURCE_DIR}/contrib/Catch.cmake) include(${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake) -if(ADDITIONAL_LIBARIES_PATHS AND WIN32) +if(COPY_LIBRARIES_FOR_EXECUTABLES AND WIN32) include(CopyDllsForDebug) add_custom_command(TARGET mapnik-test-unit POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}) set(APPS mapnik-test-unit agg_rasterizer_integer_overflow_test datasource_registration_test font_registration_test map_xml_test mapnik-test-visual) From 0c4e981e8cdcc0a29568a1099789ebede08086ba Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 3 Feb 2021 19:14:08 +0100 Subject: [PATCH 052/141] remove unnecessary cmake_minimum_required from sub projects --- demo/CMakeLists.txt | 2 -- deps/CMakeLists.txt | 1 - deps/agg/CMakeLists.txt | 1 - plugins/CMakeLists.txt | 1 - plugins/input/CMakeLists.txt | 1 - plugins/input/csv/CMakeLists.txt | 3 +-- plugins/input/gdal/CMakeLists.txt | 1 - plugins/input/geobuf/CMakeLists.txt | 3 +-- plugins/input/geojson/CMakeLists.txt | 1 - plugins/input/ogr/CMakeLists.txt | 1 - plugins/input/pgraster/CMakeLists.txt | 1 - plugins/input/postgis/CMakeLists.txt | 1 - plugins/input/raster/CMakeLists.txt | 1 - plugins/input/shape/CMakeLists.txt | 1 - plugins/input/sqlite/CMakeLists.txt | 1 - plugins/input/topojson/CMakeLists.txt | 1 - src/CMakeLists.txt | 3 --- src/json/CMakeLists.txt | 2 -- src/wkt/CMakeLists.txt | 3 --- utils/CMakeLists.txt | 1 - 20 files changed, 2 insertions(+), 28 deletions(-) diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt index 1bc4c8ddd7..f69a8f6970 100644 --- a/demo/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) - if(BUILD_DEMO_VIEWER) message(STATUS "Building demo viewer") add_subdirectory(viewer) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index e96f655840..603a29b691 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -1,2 +1 @@ -cmake_minimum_required(VERSION 3.15.0) add_subdirectory(agg) diff --git a/deps/agg/CMakeLists.txt b/deps/agg/CMakeLists.txt index ef505cdfac..f54669c493 100644 --- a/deps/agg/CMakeLists.txt +++ b/deps/agg/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) project(agg) add_library(agg INTERFACE) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index f53de93d36..76cc4ef349 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,2 +1 @@ -cmake_minimum_required(VERSION 3.15.0) add_subdirectory(input) diff --git a/plugins/input/CMakeLists.txt b/plugins/input/CMakeLists.txt index 78250545b4..d289c2a3e0 100644 --- a/plugins/input/CMakeLists.txt +++ b/plugins/input/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) if(USE_PLUGIN_INPUT_CSV) message(STATUS "using input plugin csv") add_subdirectory(csv) diff --git a/plugins/input/csv/CMakeLists.txt b/plugins/input/csv/CMakeLists.txt index bef173f84d..1c04d128b6 100644 --- a/plugins/input/csv/CMakeLists.txt +++ b/plugins/input/csv/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) project(input-csv) add_library(input-csv SHARED @@ -23,4 +22,4 @@ set_target_properties(input-csv PROPERTIES SUFFIX ".input") install(TARGETS input-csv RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} -) \ No newline at end of file +) diff --git a/plugins/input/gdal/CMakeLists.txt b/plugins/input/gdal/CMakeLists.txt index 366b3f920a..5c47cbb581 100644 --- a/plugins/input/gdal/CMakeLists.txt +++ b/plugins/input/gdal/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) project(input-gdal) find_package(GDAL REQUIRED) diff --git a/plugins/input/geobuf/CMakeLists.txt b/plugins/input/geobuf/CMakeLists.txt index 3e36629eac..77c7ff7433 100644 --- a/plugins/input/geobuf/CMakeLists.txt +++ b/plugins/input/geobuf/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) project(input-geobuf) add_library(input-geobuf SHARED @@ -17,4 +16,4 @@ set_target_properties(input-geobuf PROPERTIES SUFFIX ".input") install(TARGETS input-geobuf RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} -) \ No newline at end of file +) diff --git a/plugins/input/geojson/CMakeLists.txt b/plugins/input/geojson/CMakeLists.txt index 26a0821a2b..6d2c184f9b 100644 --- a/plugins/input/geojson/CMakeLists.txt +++ b/plugins/input/geojson/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) project(input-geojson) add_library(input-geojson SHARED diff --git a/plugins/input/ogr/CMakeLists.txt b/plugins/input/ogr/CMakeLists.txt index c01c6bb5fb..d03ac73291 100644 --- a/plugins/input/ogr/CMakeLists.txt +++ b/plugins/input/ogr/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) project(input-ogr) find_package(GDAL REQUIRED) diff --git a/plugins/input/pgraster/CMakeLists.txt b/plugins/input/pgraster/CMakeLists.txt index a6166128dd..3d837eb4f8 100644 --- a/plugins/input/pgraster/CMakeLists.txt +++ b/plugins/input/pgraster/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) project(input-pgraster) find_package(PostgreSQL REQUIRED) diff --git a/plugins/input/postgis/CMakeLists.txt b/plugins/input/postgis/CMakeLists.txt index ba3192a98a..f07a454586 100644 --- a/plugins/input/postgis/CMakeLists.txt +++ b/plugins/input/postgis/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) project(input-postgis) find_package(PostgreSQL REQUIRED) diff --git a/plugins/input/raster/CMakeLists.txt b/plugins/input/raster/CMakeLists.txt index 2aed0fdc0d..50586425cf 100644 --- a/plugins/input/raster/CMakeLists.txt +++ b/plugins/input/raster/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) project(input-raster) add_library(input-raster SHARED diff --git a/plugins/input/shape/CMakeLists.txt b/plugins/input/shape/CMakeLists.txt index 6753eb9dea..8f90aff12c 100644 --- a/plugins/input/shape/CMakeLists.txt +++ b/plugins/input/shape/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) project(input-shape) add_library(input-shape SHARED diff --git a/plugins/input/sqlite/CMakeLists.txt b/plugins/input/sqlite/CMakeLists.txt index 439d19dfb8..4bbd0fc98f 100644 --- a/plugins/input/sqlite/CMakeLists.txt +++ b/plugins/input/sqlite/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) project(input-sqlite) find_package(SQLite3 REQUIRED) diff --git a/plugins/input/topojson/CMakeLists.txt b/plugins/input/topojson/CMakeLists.txt index 6b3ffb16f4..78799a5d19 100644 --- a/plugins/input/topojson/CMakeLists.txt +++ b/plugins/input/topojson/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) project(input-topojson) add_library(input-topojson SHARED diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ff07f3fcf..e98bc2c3b9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) - - add_subdirectory(json) add_subdirectory(wkt) diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index a8430a2f71..b00651904c 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) - add_library(json STATIC extract_bounding_boxes_x3.cpp feature_from_geojson.cpp diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index 1741834c2d..2e3fc5fb9b 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -1,6 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) - - add_library(wkt STATIC geometry_to_wkt.cpp mapnik_wkt_generator_grammar.cpp diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 9a95c5713f..7aca5c8e47 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.15.0) if(BUILD_UTILITY_GEOMETRY_TO_WKB) message(STATUS "building utility geometry_to_wkb") add_subdirectory(geometry_to_wkb) From 8e90876d16b492876d8aa6df33090d08ea8a3d53 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 3 Feb 2021 19:29:43 +0100 Subject: [PATCH 053/141] rename boost::boost to boost::headers, added missing icu components --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 009c13f72a..95131765f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,7 @@ 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_PROJ4 "adds proj4 support" ON) +option(USE_PROJ "adds proj support" ON) option(USE_GRID_RENDERER "adds grid renderer" ON) option(USE_SVG_RENDERER "adds grid renderer" ON) @@ -83,7 +83,7 @@ message(STATUS "Installing plugins to ${PLUGINS_INSTALL_DIR}") set(FONTS_INSTALL_DIR ${MAPNIK_BIN_DIR}/fonts CACHE STRING "installs the fonts in the specified directory") message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}") find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) -find_package(ICU REQUIRED COMPONENTS uc) +find_package(ICU REQUIRED COMPONENTS uc i18n data) find_package(Freetype REQUIRED) find_package(harfbuzz CONFIG REQUIRED) @@ -189,7 +189,7 @@ if(USE_CAIRO) list(APPEND MAPNIK_OPTIONAL_LIBS Cairo::Cairo) endif() -if(USE_PROJ4) +if(USE_PROJ) #https://proj.org/development/cmake.html message(STATUS "Using PROJ4") find_package(PROJ4 CONFIG REQUIRED) @@ -222,10 +222,12 @@ target_include_directories(headers INTERFACE ${MAPNIK_OPTIONAL_LIBS_INCLUDE} ) target_link_libraries(headers INTERFACE - Boost::boost + Boost::headers Boost::regex Boost::filesystem ICU::uc + ICU::data + ICU::i18n Freetype::Freetype harfbuzz::harfbuzz ${MAPNIK_OPTIONAL_LIBS} From b5177ab801c36d845e4e66b2b2fb1fae8ccf1cff Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 3 Feb 2021 19:43:28 +0100 Subject: [PATCH 054/141] get mapnik version from mapnik/version.hpp --- CMakeLists.txt | 8 +++++++- cmake/GetVersion.cmake | 12 ++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 cmake/GetVersion.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 95131765f0..bbcd456fca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,17 @@ cmake_minimum_required(VERSION 3.15.0) + +include(cmake/GetVersion.cmake) +get_mapnik_version() + project(mapnik - VERSION 3.0.24 + VERSION ${MAPNIK_MAJOR_VERSION}.${MAPNIK_MINOR_VERSION}.${MAPNIK_PATCH_VERSION} HOMEPAGE_URL "https://mapnik.org/" DESCRIPTION "Mapnik is an open source toolkit for developing mapping applications" LANGUAGES CXX ) +message(STATUS "mapnik version: ${PROJECT_VERSION}") + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(ADDITIONAL_LIBARIES_PATHS "" CACHE STRING "currently only used on windows. Pass directories containing the dlls that are missing. You can ignore this, if the build (verify_app step) runs successfully" "") diff --git a/cmake/GetVersion.cmake b/cmake/GetVersion.cmake new file mode 100644 index 0000000000..8c512645b0 --- /dev/null +++ b/cmake/GetVersion.cmake @@ -0,0 +1,12 @@ +macro(get_mapnik_version) + file(READ ${CMAKE_CURRENT_SOURCE_DIR}/include/mapnik/version.hpp VERSION_FILE) + + string(REGEX MATCH "MAPNIK_MAJOR_VERSION ([0-9]*)" _ ${VERSION_FILE}) + set(MAPNIK_MAJOR_VERSION ${CMAKE_MATCH_1}) + + string(REGEX MATCH "MAPNIK_MINOR_VERSION ([0-9]*)" _ ${VERSION_FILE}) + set(MAPNIK_MINOR_VERSION ${CMAKE_MATCH_1}) + + string(REGEX MATCH "MAPNIK_PATCH_VERSION ([0-9]*)" _ ${VERSION_FILE}) + set(MAPNIK_PATCH_VERSION ${CMAKE_MATCH_1}) +endmacro() From 4b814154bb1f3b5e3cac51e446b4f7ccd405f78e Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 3 Feb 2021 22:47:15 +0100 Subject: [PATCH 055/141] add dlcfn on non windows systems --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bbcd456fca..c5243dc16e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,6 +214,12 @@ if(USE_SVG_RENDERER) list(APPEND MAPNIK_COMPILE_DEFS SVG_RENDERER) endif() +if(NOT WIN32) + message(STATUS "Compiling with -DMAPNIK_COMPILE_DEFS") + list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_HAS_DLCFN) + list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS}) +endif() + add_library(headers INTERFACE) add_library(mapnik::headers ALIAS headers) From f4e6aaa62f1d4b7f13c0ce467656610729489699 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 3 Feb 2021 22:48:25 +0100 Subject: [PATCH 056/141] fix comment --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c5243dc16e..fafa50ae8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,7 +215,7 @@ if(USE_SVG_RENDERER) endif() if(NOT WIN32) - message(STATUS "Compiling with -DMAPNIK_COMPILE_DEFS") + message(STATUS "Compiling with -DMAPNIK_HAS_DLCFN") list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_HAS_DLCFN) list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS}) endif() From c4db00d1b0b17ceb8d3c95de0ce9b2121c86ed85 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 3 Feb 2021 22:53:02 +0100 Subject: [PATCH 057/141] cmake do not test cmp0110 on versions less 3.19 --- test/CMakeLists.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 025a872d0f..e4b8eeef25 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -16,9 +16,12 @@ set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) add_library(Catch INTERFACE) target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR}) -# 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) +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 From cbe7fc2b11a13f7156eec65f927e586278a36780 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 5 Feb 2021 19:35:35 +0100 Subject: [PATCH 058/141] added clang toolchain file --- cmake/clang.cmake | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 cmake/clang.cmake diff --git a/cmake/clang.cmake b/cmake/clang.cmake new file mode 100644 index 0000000000..93aa0c73f4 --- /dev/null +++ b/cmake/clang.cmake @@ -0,0 +1,6 @@ +set(CMAKE_C_COMPILER clang) +set(CMAKE_CXX_COMPILER clang++) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++") From edfbc4d67ed21e91aa0001784379637cb7ef657a Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Mon, 15 Mar 2021 08:57:50 +0100 Subject: [PATCH 059/141] oops. do not push github workflow --- .github/workflows/cmake.yml | 46 ------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 .github/workflows/cmake.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml deleted file mode 100644 index d5217692c3..0000000000 --- a/.github/workflows/cmake.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: CMake - -on: [push] - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release - -jobs: - build: - # The CMake configure and build commands are platform agnostic and should work equally - # well on Windows or Mac. You can convert this to a matrix build if you need - # cross-platform coverage. - # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - - name: Create Build Environment - # Some projects don't allow in-source building, so create a separate build directory - # We'll use this as our working directory for all subsequent commands - run: cmake -E make_directory ${{runner.workspace}}/build - - - name: Configure CMake - # Use a bash shell so we can use the same syntax for environment variable - # access regardless of the host operating system - shell: bash - working-directory: ${{runner.workspace}}/build - # Note the current convention is to use the -S and -B options here to specify source - # and build directories, but this is only available with CMake 3.13 and higher. - # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 - run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE - - - name: Build - working-directory: ${{runner.workspace}}/build - shell: bash - # Execute the build. You can specify a specific target with "--target " - run: cmake --build . --config $BUILD_TYPE - - - name: Test - working-directory: ${{runner.workspace}}/build - shell: bash - # Execute tests defined by the CMake configuration. - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail - run: ctest -C $BUILD_TYPE From 42f6006b485db2d7ff230e6fa26e705e0d20dd3b Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Mon, 15 Mar 2021 10:03:26 +0100 Subject: [PATCH 060/141] fix find cairo --- cmake/FindCairo.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindCairo.cmake b/cmake/FindCairo.cmake index c6a33fa1b8..adf0c8e9cd 100644 --- a/cmake/FindCairo.cmake +++ b/cmake/FindCairo.cmake @@ -124,7 +124,7 @@ else() ) endif() -if (Cairo_LIBRARY AND NOT TARGET Cairo::Cairo) +if (NOT TARGET Cairo::Cairo) add_library(Cairo::Cairo UNKNOWN IMPORTED GLOBAL) set_target_properties(Cairo::Cairo PROPERTIES IMPORTED_LOCATION "${Cairo_LIBRARY_RELEASE}" From 05ff4ac07c566d7427bc662a12955cf5d32ba976 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 17 Mar 2021 21:29:00 +0100 Subject: [PATCH 061/141] fixes cairo renderer debug configuration. Copied FindCairo had a lot of issues with the multiconfiguration settings. Rewrite of the whole file --- cmake/FindCairo.cmake | 196 ++++++++++++++++-------------------------- 1 file changed, 76 insertions(+), 120 deletions(-) diff --git a/cmake/FindCairo.cmake b/cmake/FindCairo.cmake index adf0c8e9cd..1dc42a6a03 100644 --- a/cmake/FindCairo.cmake +++ b/cmake/FindCairo.cmake @@ -1,142 +1,98 @@ -# 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. +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. #[=======================================================================[.rst: FindCairo --------------- +----------- + +Find Cairo 2D graphics library. -Find Cairo headers and libraries. Imported Targets ^^^^^^^^^^^^^^^^ +This module defines :prop_tgt:`IMPORTED` target ``Cairo::Cairo``, if +cairo has been found. -``Cairo::Cairo`` - The Cairo library, if found. - -Result Variables +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 - +This module will set the following variables in your project: + +``CAIRO_FOUND`` + True if cairo headers and library were found. +``CAIRO_INCLUDE_DIRS`` + Directory where cairo headers are located. +``CAIRO_LIBRARIES`` + cairo libraries to link against. +``CAIRO_VERSION_MAJOR`` + The major version of cairo +``CAIRO_VERSION_MINOR`` + The minor version of cairo +``CAIRO_VERSION_PATCH`` + The patch version of cairo +``CAIRO_VERSION_STRING`` + version number as a string (ex: "1.16.0") #]=======================================================================] -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_RELEASE - NAMES ${Cairo_NAMES} cairo - HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS} -) - -find_library(Cairo_LIBRARY_DEBUG - NAMES ${Cairo_NAMES} cairod - HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS} -) +if(NOT CAIRO_LIBRARY) + find_path(CAIRO_INCLUDE_DIR NAMES cairo.h HINTS ${PC_CAIRO_INCLUDEDIR} ${PC_CAIRO_INCLUDE_DIR} PATH_SUFFIXES cairo) + find_library(CAIRO_LIBRARY_RELEASE NAMES ${Cairo_NAMES} cairo HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS}) + find_library(CAIRO_LIBRARY_DEBUG NAMES ${Cairo_NAMES} cairod HINTS ${PC_CAIRO_LIBDIR} ${PC_CAIRO_LIBRARY_DIRS}) + include(SelectLibraryConfigurations) + select_library_configurations(CAIRO) +else() + file(TO_CMAKE_PATH "${CAIRO_LIBRARY}" CAIRO_LIBRARY) +endif() -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) +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_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_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}") + 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 () + set(CAIRO_VERSION "${CAIRO_VERSION_MAJOR}.${CAIRO_VERSION_MINOR}.${CAIRO_VERSION_PATCH}") + set(CAIRO_VERSION_STRING ${CAIRO_VERSION}) + endif() +endif() include(FindPackageHandleStandardArgs) -if(Cairo_LIBRARY_RELEASE AND Cairo_LIBRARY_DEBUG) - # set the libaries varible to use the release and debug versions - find_package_handle_standard_args(Cairo - FOUND_VAR Cairo_FOUND - REQUIRED_VARS Cairo_LIBRARY_RELEASE Cairo_LIBRARY_DEBUG Cairo_INCLUDE_DIR - VERSION_VAR Cairo_VERSION - ) - set(Cairo_LIBRARIES optimized ${Cairo_LIBRARY_RELEASE} debug ${Cairo_LIBRARY_DEBUG}) -elseif(Cairo_LIBRARY_RELEASE) - # only the release library is available - find_package_handle_standard_args(Cairo - FOUND_VAR Cairo_FOUND - REQUIRED_VARS Cairo_LIBRARY_RELEASE Cairo_INCLUDE_DIR - VERSION_VAR Cairo_VERSION - ) - set(Cairo_LIBRARIES optimized ${Cairo_LIBRARY_RELEASE}) -elseif(Cairo_LIBRARY_DEBUG) - # only the debug library is available - find_package_handle_standard_args(Cairo - FOUND_VAR Cairo_FOUND - REQUIRED_VARS Cairo_LIBRARY_DEBUG Cairo_INCLUDE_DIR - VERSION_VAR Cairo_VERSION - ) - set(Cairo_LIBRARIES debug ${Cairo_LIBRARY_DEBUG}) -else() - # neither library is available - give standard error message - find_package_handle_standard_args(Cairo - FOUND_VAR Cairo_FOUND - REQUIRED_VARS Cairo_LIBRARY_RELEASE Cairo_LIBRARY_DEBUG Cairo_INCLUDE_DIR - VERSION_VAR Cairo_VERSION - ) -endif() +find_package_handle_standard_args(Cairo + REQUIRED_VARS + CAIRO_LIBRARY + CAIRO_INCLUDE_DIR + VERSION_VAR + CAIRO_VERSION_STRING +) +mark_as_advanced(CAIRO_INCLUDE_DIR CAIRO_LIBRARY) -if (NOT TARGET Cairo::Cairo) - add_library(Cairo::Cairo UNKNOWN IMPORTED GLOBAL) +if (CAIRO_FOUND) + set(CAIRO_LIBRARIES ${CAIRO_LIBRARY}) + set(CAIRO_INCLUDE_DIRS ${CAIRO_INCLUDE_DIR}) + if(NOT TARGET Cairo::Cairo) + add_library(Cairo::Cairo UNKNOWN IMPORTED) set_target_properties(Cairo::Cairo PROPERTIES - IMPORTED_LOCATION "${Cairo_LIBRARY_RELEASE}" - IMPORTED_LOCATION_DEBUG "${Cairo_LIBRARY_DEBUG}" - INTERFACE_COMPILE_OPTIONS "${Cairo_COMPILE_OPTIONS}" - INTERFACE_INCLUDE_DIRECTORIES "${Cairo_INCLUDE_DIR}" - ) -endif () - -mark_as_advanced(Cairo_INCLUDE_DIR Cairo_LIBRARY_RELEASE Cairo_LIBRARY_DEBUG) - -if (Cairo_FOUND) - set(Cairo_LIBRARIES ${Cairo_LIBRARY}) - set(Cairo_INCLUDE_DIRS ${Cairo_INCLUDE_DIR}) + INTERFACE_INCLUDE_DIRECTORIES ${CAIRO_INCLUDE_DIR} + IMPORTED_LINK_INTERFACE_LANGUAGES C) + + if(CAIRO_LIBRARY_RELEASE) + set_property(TARGET Cairo::Cairo APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(Cairo::Cairo PROPERTIES IMPORTED_LOCATION_RELEASE "${CAIRO_LIBRARY_RELEASE}") + endif() + + if(CAIRO_LIBRARY_DEBUG) + set_property(TARGET Cairo::Cairo APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(Cairo::Cairo PROPERTIES IMPORTED_LOCATION_DEBUG "${CAIRO_LIBRARY_DEBUG}") + endif() + + if(NOT CAIRO_LIBRARY_RELEASE AND NOT CAIRO_LIBRARY_DEBUG) + set_target_properties(Cairo::Cairo PROPERTIES IMPORTED_LOCATION "${CAIRO_LIBRARY}") + endif() + endif() endif () From 3abb4517932fdb62de699c1cd7eaafd8d78437e6 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 17 Mar 2021 22:18:21 +0100 Subject: [PATCH 062/141] add dependencies to cmake config. Provieded a new macro for better maintance --- CMakeLists.txt | 31 ++++++++++++++++++------------- cmake/MapnikConfig.cmake.in | 6 ++++++ cmake/MapnikFindPackage.cmake | 6 ++++++ 3 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 cmake/MapnikFindPackage.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index fafa50ae8a..30a1c59731 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ project(mapnik message(STATUS "mapnik version: ${PROJECT_VERSION}") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include(MapnikFindPackage) set(ADDITIONAL_LIBARIES_PATHS "" CACHE STRING "currently 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 (currently only windows) to the executable directory" ON) @@ -88,10 +89,11 @@ message(STATUS "Installing plugins to ${PLUGINS_INSTALL_DIR}") set(FONTS_INSTALL_DIR ${MAPNIK_BIN_DIR}/fonts CACHE STRING "installs the fonts in the specified directory") message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}") -find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) -find_package(ICU REQUIRED COMPONENTS uc i18n data) -find_package(Freetype REQUIRED) -find_package(harfbuzz CONFIG REQUIRED) + +mapnik_find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) +mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) +mapnik_find_package(Freetype REQUIRED) +mapnik_find_package(harfbuzz CONFIG REQUIRED) if(USE_EXTERNAL_MAPBOX_GEOMETRY) # this is used to provide a way to specify include dirs with CACHE VARIABLES @@ -156,49 +158,49 @@ set(MAPNIK_OPTIONAL_LIBS_INCLUDE "") if(USE_LIBXML2) message(STATUS "Using LibXml2") - find_package(LibXml2 REQUIRED) + mapnik_find_package(LibXml2 REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_LIBXML2) list(APPEND MAPNIK_OPTIONAL_LIBS LibXml2::LibXml2) endif() if(USE_PNG) message(STATUS "Using PNG") - find_package(PNG REQUIRED) + mapnik_find_package(PNG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_PNG) list(APPEND MAPNIK_OPTIONAL_LIBS PNG::PNG) endif() if(USE_JPEG) message(STATUS "Using JPEG") - find_package(JPEG REQUIRED) + mapnik_find_package(JPEG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG) list(APPEND MAPNIK_OPTIONAL_LIBS JPEG::JPEG) endif() if(USE_TIFF) - find_package(TIFF REQUIRED) message(STATUS "Using TIFF") + mapnik_find_package(TIFF REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_TIFF) list(APPEND MAPNIK_OPTIONAL_LIBS TIFF::TIFF) endif() if(USE_WEBP) message(STATUS "Using WEBP") - find_package(WebP CONFIG REQUIRED) + mapnik_find_package(WebP CONFIG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP) list(APPEND MAPNIK_OPTIONAL_LIBS WebP::webp) endif() if(USE_CAIRO) message(STATUS "Using Cairo renderer") - find_package(Cairo REQUIRED) + mapnik_find_package(Cairo REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_CAIRO) list(APPEND MAPNIK_OPTIONAL_LIBS Cairo::Cairo) endif() if(USE_PROJ) #https://proj.org/development/cmake.html - message(STATUS "Using PROJ4") - find_package(PROJ4 CONFIG REQUIRED) + message(STATUS "Using PROJ") + mapnik_find_package(PROJ4 CONFIG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ4 ACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1) list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ4_LIBRARIES}) list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) @@ -276,10 +278,11 @@ write_basic_package_version_file( COMPATIBILITY SameMajorVersion ) +list(JOIN MAPNIK_DEPENDENCIES "\n" MAPNIK_DEPENDENCIES) configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/MapnikConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfig.cmake" INSTALL_DESTINATION ${INSTALL_CMAKE_DIR} - PATH_VARS INCLUDE_INSTALL_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR + PATH_VARS INCLUDE_INSTALL_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR MAPNIK_DEPENDENCIES ) install(FILES @@ -287,6 +290,8 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfigVersion.cmake" DESTINATION ${INSTALL_CMAKE_DIR} ) +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindCairo.cmake" DESTINATION ${INSTALL_CMAKE_DIR}/Modules) + install(EXPORT MapnikTargets FILE MapnikTargets.cmake NAMESPACE mapnik:: diff --git a/cmake/MapnikConfig.cmake.in b/cmake/MapnikConfig.cmake.in index 0785d57f7e..74071d4932 100644 --- a/cmake/MapnikConfig.cmake.in +++ b/cmake/MapnikConfig.cmake.in @@ -4,6 +4,12 @@ set_and_check(MAPNIK_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@" CACHE STRING "" set_and_check(MAPNIK_PLUGINS_DIR "@PACKAGE_PLUGINS_INSTALL_DIR@" CACHE STRING "") set_and_check(MAPNIK_FONTS_DIR "@PACKAGE_FONTS_INSTALL_DIR@" CACHE STRING "") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/Modules/") + +include(CMakeFindDependencyMacro) +@MAPNIK_DEPENDENCIES@ + + include("${CMAKE_CURRENT_LIST_DIR}/MapnikTargets.cmake") check_required_components(mapnik) diff --git a/cmake/MapnikFindPackage.cmake b/cmake/MapnikFindPackage.cmake new file mode 100644 index 0000000000..d4e6c5acd9 --- /dev/null +++ b/cmake/MapnikFindPackage.cmake @@ -0,0 +1,6 @@ +macro(mapnik_find_package) + find_package(${ARGN}) + set(MAPNIK_TMP_DEP ${ARGN}) + list(JOIN MAPNIK_TMP_DEP " " MAPNIK_TMP_DEP) + list(APPEND MAPNIK_DEPENDENCIES "find_dependency(${MAPNIK_TMP_DEP})") +endmacro() From ed45e73629a7a0a3af6dc56d9baf98e35da25f84 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 17 Mar 2021 22:37:46 +0100 Subject: [PATCH 063/141] added some basic READMEs --- INSTALL.md | 7 +++++++ docs/cmake-usage.md | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 docs/cmake-usage.md diff --git a/INSTALL.md b/INSTALL.md index 4ef4a21249..7ee6420c0a 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -2,6 +2,13 @@ Mapnik runs on Linux, OS X, Windows, and BSD systems. +## Package managers +### vcpkg +To install mapnik with vcpkg type `vcpkg install mapnik`. It will install a minimal version of mapnik and all the needed dependencies. +To install more features, type `vcpkg search mapnik` to see all available features. + +## Source build + First clone mapnik from github and initialize submodules ```bash diff --git a/docs/cmake-usage.md b/docs/cmake-usage.md new file mode 100644 index 0000000000..e3d4e84a74 --- /dev/null +++ b/docs/cmake-usage.md @@ -0,0 +1,34 @@ +# Usage with CMake +## Build +First clone mapnik from github and initialize submodules + +```bash +git clone https://github.com/mapnik/mapnik.git +cd mapnik +git submodule update --init +``` + +Make sure that all dependencies are installed. + +All available cmake options are listed at the top of [CMakeLists.txt](../CMakeLists.txt). +Pass your options while configuring e.g.: `cmake -DBUILD_DEMO_VIEWER=OFF ..` to disable the build of the demo viewer application. + +To quickstart open a console in the root mapnik dir and execute the following commands: (Pass all options and dependency dirs after `-DBUILD_TEST=OFF`) +``` +> cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TEST=OFF +> cmake --build build --target install +``` + +## Usage + +To use Mapnik in your project add the following lines to your CMakeLists.tzt. +``` +find_package(mapnik CONFIG REQUIRED) +[...] +target_link_libraries(mytarget ... mapnik::headers mapnik::mapnik) +``` + +All mapnik executables and targets are exported within `MapnikTargets.cmake`. + +The plugin dir is available in the variable `MAPNIK_PLUGINS_DIR`. +The font path is is available in the variable `MAPNIK_FONTS_DIR`. From 4746c48099d95c4adf309b319aa55299650f601e Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 17 Mar 2021 23:06:49 +0100 Subject: [PATCH 064/141] 3.15 is the minium supported target. tested. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 30a1c59731..a2b3c14719 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,6 @@ -cmake_minimum_required(VERSION 3.15.0) +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 include(cmake/GetVersion.cmake) get_mapnik_version() From aafb1e118b38f5d79aaa5081b877c2468a52c6ed Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 18 Mar 2021 15:35:55 +0100 Subject: [PATCH 065/141] renamed target mapnik::headers to mapnik::core --- CMakeLists.txt | 12 ++++++------ demo/c++/CMakeLists.txt | 2 +- demo/viewer/CMakeLists.txt | 2 +- deps/agg/CMakeLists.txt | 2 +- docs/cmake-usage.md | 2 +- plugins/input/csv/CMakeLists.txt | 2 +- plugins/input/gdal/CMakeLists.txt | 2 +- plugins/input/geobuf/CMakeLists.txt | 2 +- plugins/input/geojson/CMakeLists.txt | 2 +- plugins/input/ogr/CMakeLists.txt | 2 +- plugins/input/pgraster/CMakeLists.txt | 2 +- plugins/input/postgis/CMakeLists.txt | 2 +- plugins/input/raster/CMakeLists.txt | 2 +- plugins/input/shape/CMakeLists.txt | 2 +- plugins/input/sqlite/CMakeLists.txt | 2 +- plugins/input/topojson/CMakeLists.txt | 2 +- src/CMakeLists.txt | 2 +- src/json/CMakeLists.txt | 2 +- src/wkt/CMakeLists.txt | 2 +- test/CMakeLists.txt | 12 ++++++------ utils/geometry_to_wkb/CMakeLists.txt | 2 +- utils/mapnik-index/CMakeLists.txt | 2 +- utils/mapnik-render/CMakeLists.txt | 2 +- utils/ogrindex/CMakeLists.txt | 2 +- utils/pgsql2sqlite/CMakeLists.txt | 2 +- utils/shapeindex/CMakeLists.txt | 2 +- utils/svg2png/CMakeLists.txt | 2 +- 27 files changed, 37 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2b3c14719..6f4e3fd841 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,10 +224,10 @@ if(NOT WIN32) list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS}) endif() -add_library(headers INTERFACE) -add_library(mapnik::headers ALIAS headers) +add_library(mapnik-core INTERFACE) +add_library(mapnik::core ALIAS mapnik-core) -target_include_directories(headers INTERFACE +target_include_directories(mapnik-core INTERFACE $ $ $ @@ -237,7 +237,7 @@ target_include_directories(headers INTERFACE $ ${MAPNIK_OPTIONAL_LIBS_INCLUDE} ) -target_link_libraries(headers INTERFACE +target_link_libraries(mapnik-core INTERFACE Boost::headers Boost::regex Boost::filesystem @@ -248,9 +248,9 @@ target_link_libraries(headers INTERFACE harfbuzz::harfbuzz ${MAPNIK_OPTIONAL_LIBS} ) -target_compile_definitions(headers INTERFACE ${MAPNIK_COMPILE_DEFS}) +target_compile_definitions(mapnik-core INTERFACE ${MAPNIK_COMPILE_DEFS}) -install(TARGETS headers +install(TARGETS mapnik-core EXPORT MapnikTargets LIBRARY DESTINATION ${MAPNIK_LIB_DIR} ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} diff --git a/demo/c++/CMakeLists.txt b/demo/c++/CMakeLists.txt index 48e83ce780..fece18e8a1 100644 --- a/demo/c++/CMakeLists.txt +++ b/demo/c++/CMakeLists.txt @@ -2,7 +2,7 @@ project(mapnik-demo) add_executable(mapnik-demo rundemo.cpp) -target_link_libraries(mapnik-demo PRIVATE mapnik::headers mapnik::agg mapnik::mapnik) +target_link_libraries(mapnik-demo PRIVATE mapnik::core mapnik::agg mapnik::mapnik) install(TARGETS mapnik-demo LIBRARY DESTINATION ${MAPNIK_LIB_DIR} diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index c618b6fa59..5d71d1c40f 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -29,7 +29,7 @@ set_target_properties(mapnik-viewer PROPERTIES target_link_libraries(mapnik-viewer PRIVATE Qt5::Widgets - mapnik::headers + mapnik::core mapnik::agg mapnik::mapnik ) diff --git a/deps/agg/CMakeLists.txt b/deps/agg/CMakeLists.txt index f54669c493..9cd0de942d 100644 --- a/deps/agg/CMakeLists.txt +++ b/deps/agg/CMakeLists.txt @@ -7,7 +7,7 @@ target_include_directories(agg INTERFACE $ $ ) -target_link_libraries(agg INTERFACE mapnik::headers) +target_link_libraries(agg INTERFACE mapnik::core) install(TARGETS agg EXPORT MapnikTargets diff --git a/docs/cmake-usage.md b/docs/cmake-usage.md index e3d4e84a74..57de8f5077 100644 --- a/docs/cmake-usage.md +++ b/docs/cmake-usage.md @@ -25,7 +25,7 @@ To use Mapnik in your project add the following lines to your CMakeLists.tzt. ``` find_package(mapnik CONFIG REQUIRED) [...] -target_link_libraries(mytarget ... mapnik::headers mapnik::mapnik) +target_link_libraries(mytarget ... mapnik::core mapnik::mapnik) ``` All mapnik executables and targets are exported within `MapnikTargets.cmake`. diff --git a/plugins/input/csv/CMakeLists.txt b/plugins/input/csv/CMakeLists.txt index 1c04d128b6..677ac25386 100644 --- a/plugins/input/csv/CMakeLists.txt +++ b/plugins/input/csv/CMakeLists.txt @@ -10,7 +10,7 @@ add_library(input-csv SHARED add_library(mapnik::plugin::input::csv ALIAS input-csv) target_link_libraries(input-csv PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik mapnik::wkt mapnik::json diff --git a/plugins/input/gdal/CMakeLists.txt b/plugins/input/gdal/CMakeLists.txt index 5c47cbb581..4b35fb8145 100644 --- a/plugins/input/gdal/CMakeLists.txt +++ b/plugins/input/gdal/CMakeLists.txt @@ -10,7 +10,7 @@ add_library(mapnik::plugin::input::gdal ALIAS input-gdal) target_include_directories(input-gdal PRIVATE ${GDAL_INCLUDE_DIR}) target_link_libraries(input-gdal PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik ${GDAL_LIBRARY} ) diff --git a/plugins/input/geobuf/CMakeLists.txt b/plugins/input/geobuf/CMakeLists.txt index 77c7ff7433..73d39e14a7 100644 --- a/plugins/input/geobuf/CMakeLists.txt +++ b/plugins/input/geobuf/CMakeLists.txt @@ -7,7 +7,7 @@ add_library(input-geobuf SHARED add_library(mapnik::plugin::input::geobuf ALIAS input-geobuf) target_link_libraries(input-geobuf PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik ) set_target_properties(input-geobuf PROPERTIES PREFIX "") diff --git a/plugins/input/geojson/CMakeLists.txt b/plugins/input/geojson/CMakeLists.txt index 6d2c184f9b..09da0e935b 100644 --- a/plugins/input/geojson/CMakeLists.txt +++ b/plugins/input/geojson/CMakeLists.txt @@ -9,7 +9,7 @@ add_library(input-geojson SHARED add_library(mapnik::plugin::input::geojson ALIAS input-geojson) target_link_libraries(input-geojson PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik mapnik::json ) diff --git a/plugins/input/ogr/CMakeLists.txt b/plugins/input/ogr/CMakeLists.txt index d03ac73291..3656e3a79a 100644 --- a/plugins/input/ogr/CMakeLists.txt +++ b/plugins/input/ogr/CMakeLists.txt @@ -12,7 +12,7 @@ add_library(mapnik::plugin::input::ogr ALIAS input-ogr) target_include_directories(input-ogr PRIVATE ${GDAL_INCLUDE_DIR}) target_link_libraries(input-ogr PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik ${GDAL_LIBRARY} ) diff --git a/plugins/input/pgraster/CMakeLists.txt b/plugins/input/pgraster/CMakeLists.txt index 3d837eb4f8..fe6622cf0a 100644 --- a/plugins/input/pgraster/CMakeLists.txt +++ b/plugins/input/pgraster/CMakeLists.txt @@ -11,7 +11,7 @@ add_library(mapnik::plugin::input::pgraster ALIAS input-pgraster) target_link_libraries(input-pgraster PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik PostgreSQL::PostgreSQL ) diff --git a/plugins/input/postgis/CMakeLists.txt b/plugins/input/postgis/CMakeLists.txt index f07a454586..73113f2828 100644 --- a/plugins/input/postgis/CMakeLists.txt +++ b/plugins/input/postgis/CMakeLists.txt @@ -9,7 +9,7 @@ add_library(input-postgis SHARED add_library(mapnik::plugin::input::postgis ALIAS input-postgis) target_link_libraries(input-postgis PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik PostgreSQL::PostgreSQL ) diff --git a/plugins/input/raster/CMakeLists.txt b/plugins/input/raster/CMakeLists.txt index 50586425cf..548a361a21 100644 --- a/plugins/input/raster/CMakeLists.txt +++ b/plugins/input/raster/CMakeLists.txt @@ -8,7 +8,7 @@ add_library(input-raster SHARED add_library(mapnik::plugin::input::raster ALIAS input-raster) target_link_libraries(input-raster PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik ) diff --git a/plugins/input/shape/CMakeLists.txt b/plugins/input/shape/CMakeLists.txt index 8f90aff12c..ed3a1f3659 100644 --- a/plugins/input/shape/CMakeLists.txt +++ b/plugins/input/shape/CMakeLists.txt @@ -11,7 +11,7 @@ add_library(input-shape SHARED add_library(mapnik::plugin::input::shape ALIAS input-shape) target_link_libraries(input-shape PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik ) diff --git a/plugins/input/sqlite/CMakeLists.txt b/plugins/input/sqlite/CMakeLists.txt index 4bbd0fc98f..7be226609c 100644 --- a/plugins/input/sqlite/CMakeLists.txt +++ b/plugins/input/sqlite/CMakeLists.txt @@ -9,7 +9,7 @@ add_library(input-sqlite SHARED add_library(mapnik::plugin::input::sqlite ALIAS input-sqlite) target_link_libraries(input-sqlite PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik SQLite::SQLite3 ) diff --git a/plugins/input/topojson/CMakeLists.txt b/plugins/input/topojson/CMakeLists.txt index 78799a5d19..baefe69ee2 100644 --- a/plugins/input/topojson/CMakeLists.txt +++ b/plugins/input/topojson/CMakeLists.txt @@ -7,7 +7,7 @@ add_library(input-topojson SHARED add_library(mapnik::plugin::input::topojson ALIAS input-topojson) target_link_libraries(input-topojson PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik mapnik::json ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e98bc2c3b9..7599ba4b43 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -290,7 +290,7 @@ endif() target_compile_definitions(mapnik PRIVATE ${COMPILE_DEFS}) target_link_libraries(mapnik PRIVATE - mapnik::headers + mapnik::core mapnik::agg ) diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index b00651904c..183b7c745a 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -24,7 +24,7 @@ target_include_directories(json PRIVATE ${MAPBOX_GEOMETRY_INCLUDE_DIRS} ${MAPBOX_VARIANT_INCLUDE_DIRS} ) -target_link_libraries(json PRIVATE mapnik::headers ${ICUU_LIB}) +target_link_libraries(json PRIVATE mapnik::core ${ICUU_LIB}) install(TARGETS json EXPORT MapnikTargets diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index 2e3fc5fb9b..35168f669b 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -16,7 +16,7 @@ target_include_directories(wkt PRIVATE ${MAPBOX_GEOMETRY_INCLUDE_DIRS} ${MAPBOX_VARIANT_INCLUDE_DIRS} ) -target_link_libraries(wkt PRIVATE mapnik::headers) +target_link_libraries(wkt PRIVATE mapnik::core) install(TARGETS wkt EXPORT MapnikTargets diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e4b8eeef25..c5787b6ace 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -108,7 +108,7 @@ add_executable(mapnik-test-unit ) target_link_libraries(mapnik-test-unit PUBLIC Catch - mapnik::headers + mapnik::core mapnik::agg mapnik::mapnik mapnik::json @@ -118,7 +118,7 @@ target_link_libraries(mapnik-test-unit PUBLIC add_executable(agg_rasterizer_integer_overflow_test standalone/agg_rasterizer_integer_overflow_test.cpp) target_link_libraries(agg_rasterizer_integer_overflow_test PUBLIC Catch - mapnik::headers + mapnik::core mapnik::mapnik mapnik::agg mapnik::json @@ -127,7 +127,7 @@ target_link_libraries(agg_rasterizer_integer_overflow_test PUBLIC add_executable(datasource_registration_test standalone/datasource_registration_test.cpp) target_link_libraries(datasource_registration_test PUBLIC Catch - mapnik::headers + mapnik::core mapnik::mapnik mapnik::agg ) @@ -135,7 +135,7 @@ target_link_libraries(datasource_registration_test PUBLIC add_executable(font_registration_test standalone/font_registration_test.cpp) target_link_libraries(font_registration_test PUBLIC Catch - mapnik::headers + mapnik::core mapnik::mapnik mapnik::agg mapnik::json @@ -145,7 +145,7 @@ target_link_libraries(font_registration_test PUBLIC add_executable(map_xml_test standalone/map_xml_test.cpp) target_link_libraries(map_xml_test PUBLIC Catch - mapnik::headers + mapnik::core mapnik::mapnik mapnik::agg mapnik::json @@ -162,7 +162,7 @@ target_link_libraries( Catch Boost::program_options Boost::filesystem - mapnik::headers + mapnik::core mapnik::mapnik mapnik::agg ) diff --git a/utils/geometry_to_wkb/CMakeLists.txt b/utils/geometry_to_wkb/CMakeLists.txt index f706fd5848..17d8e23cb1 100644 --- a/utils/geometry_to_wkb/CMakeLists.txt +++ b/utils/geometry_to_wkb/CMakeLists.txt @@ -3,7 +3,7 @@ project(geometry_to_wkb) add_executable(geometry_to_wkb main.cpp) target_link_libraries(geometry_to_wkb PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik ) diff --git a/utils/mapnik-index/CMakeLists.txt b/utils/mapnik-index/CMakeLists.txt index 22076f781f..70123b379e 100644 --- a/utils/mapnik-index/CMakeLists.txt +++ b/utils/mapnik-index/CMakeLists.txt @@ -9,7 +9,7 @@ add_executable(mapnik-index ../../plugins/input/csv/csv_utils.cpp # this project depends on this file ) target_link_libraries(mapnik-index PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik mapnik::json mapnik::wkt diff --git a/utils/mapnik-render/CMakeLists.txt b/utils/mapnik-render/CMakeLists.txt index eed2e90a64..0dbc73f2a4 100644 --- a/utils/mapnik-render/CMakeLists.txt +++ b/utils/mapnik-render/CMakeLists.txt @@ -5,7 +5,7 @@ find_package(Boost 1.74 REQUIRED COMPONENTS program_options) add_executable(mapnik-render mapnik-render.cpp) target_link_libraries(mapnik-render PRIVATE - mapnik::headers + mapnik::core mapnik::mapnik Boost::program_options ) diff --git a/utils/ogrindex/CMakeLists.txt b/utils/ogrindex/CMakeLists.txt index 8e9eed31a1..ad9c12e41b 100644 --- a/utils/ogrindex/CMakeLists.txt +++ b/utils/ogrindex/CMakeLists.txt @@ -3,7 +3,7 @@ project(ogrindex) add_executable(ogrindex ogrindex.cpp) -target_link_libraries(ogrindex PRIVATE mapnik::headers mapnik::mapnik) +target_link_libraries(ogrindex PRIVATE mapnik::core mapnik::mapnik) install(TARGETS ogrindex EXPORT MapnikTargets diff --git a/utils/pgsql2sqlite/CMakeLists.txt b/utils/pgsql2sqlite/CMakeLists.txt index c98427ec95..d57046bee7 100644 --- a/utils/pgsql2sqlite/CMakeLists.txt +++ b/utils/pgsql2sqlite/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_libraries(pgsql2sqlite PRIVATE SQLite::SQLite3 PostgreSQL::PostgreSQL Boost::program_options - mapnik::headers + mapnik::core mapnik::mapnik ) diff --git a/utils/shapeindex/CMakeLists.txt b/utils/shapeindex/CMakeLists.txt index 969c868170..79a9f24ff5 100644 --- a/utils/shapeindex/CMakeLists.txt +++ b/utils/shapeindex/CMakeLists.txt @@ -9,7 +9,7 @@ add_executable(shapeindex target_include_directories(shapeindex PRIVATE ../../plugins/input/shape) target_link_libraries(shapeindex PRIVATE Boost::program_options - mapnik::headers + mapnik::core mapnik::mapnik ) install(TARGETS shapeindex diff --git a/utils/svg2png/CMakeLists.txt b/utils/svg2png/CMakeLists.txt index 015de5c3d0..6f1a52eaba 100644 --- a/utils/svg2png/CMakeLists.txt +++ b/utils/svg2png/CMakeLists.txt @@ -8,7 +8,7 @@ add_executable(svg2png target_link_libraries(svg2png PRIVATE Boost::program_options - mapnik::headers + mapnik::core mapnik::mapnik mapnik::agg ) From 173c53f545beb4e96a43325f9cd46d842330ef64 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 19 Mar 2021 22:51:50 +0100 Subject: [PATCH 066/141] rename internal name mapnik-core to core since the exported name would be mapnik::mapnik-core instead of mapnik::core. This fixes the issue --- CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f4e3fd841..b6a4e4993e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,10 +224,10 @@ if(NOT WIN32) list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS}) endif() -add_library(mapnik-core INTERFACE) -add_library(mapnik::core ALIAS mapnik-core) +add_library(core INTERFACE) +add_library(mapnik::core ALIAS core) -target_include_directories(mapnik-core INTERFACE +target_include_directories(core INTERFACE $ $ $ @@ -237,7 +237,7 @@ target_include_directories(mapnik-core INTERFACE $ ${MAPNIK_OPTIONAL_LIBS_INCLUDE} ) -target_link_libraries(mapnik-core INTERFACE +target_link_libraries(core INTERFACE Boost::headers Boost::regex Boost::filesystem @@ -248,9 +248,9 @@ target_link_libraries(mapnik-core INTERFACE harfbuzz::harfbuzz ${MAPNIK_OPTIONAL_LIBS} ) -target_compile_definitions(mapnik-core INTERFACE ${MAPNIK_COMPILE_DEFS}) +target_compile_definitions(core INTERFACE ${MAPNIK_COMPILE_DEFS}) -install(TARGETS mapnik-core +install(TARGETS core EXPORT MapnikTargets LIBRARY DESTINATION ${MAPNIK_LIB_DIR} ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} From 5bc15d05e5aeb3982abb650eed49566290ad7198 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 24 Mar 2021 14:57:27 +0100 Subject: [PATCH 067/141] find and link icu first --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b6a4e4993e..8e37eac762 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -92,8 +92,8 @@ message(STATUS "Installing plugins to ${PLUGINS_INSTALL_DIR}") set(FONTS_INSTALL_DIR ${MAPNIK_BIN_DIR}/fonts CACHE STRING "installs the fonts in the specified directory") message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}") -mapnik_find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) +mapnik_find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) mapnik_find_package(Freetype REQUIRED) mapnik_find_package(harfbuzz CONFIG REQUIRED) @@ -238,12 +238,12 @@ target_include_directories(core INTERFACE ${MAPNIK_OPTIONAL_LIBS_INCLUDE} ) target_link_libraries(core INTERFACE - Boost::headers - Boost::regex - Boost::filesystem ICU::uc ICU::data ICU::i18n + Boost::headers + Boost::regex + Boost::filesystem Freetype::Freetype harfbuzz::harfbuzz ${MAPNIK_OPTIONAL_LIBS} From c13c3c47cfd70285854c3c3f3c2908bdf564cb17 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 24 Mar 2021 15:16:12 +0100 Subject: [PATCH 068/141] fix typo in text --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e37eac762..e7e98d7d3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ 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) -set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++11 is minimum.") +set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++14 is minimum.") message(STATUS "Using c++${CMAKE_CXX_STANDARD}") if(WIN32) From 0cb7bf35562f358bca626f3a31da31646c67ac45 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 24 Mar 2021 15:17:08 +0100 Subject: [PATCH 069/141] fix false default cmake install dir --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7e98d7d3f..c68aef0c58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ set(MAPNIK_LIB_DIR ${DEFAULT_LIB_DIR} CACHE STRING "Install directory for librar # https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#archive-output-artifacts set(MAPNIK_ARCHIVE_DIR ${DEFAULT_ARCHIVE_DIR} CACHE STRING "Install directory for archives") -set(INSTALL_CMAKE_DIR ${MAPNIK_LIB_DIR}/mapnik/cmake CACHE STRING "Install directory of the cmake targets") +set(INSTALL_CMAKE_DIR ${MAPNIK_LIB_DIR}/cmake/mapnik CACHE STRING "Install directory of the cmake targets") if(WIN32) set(DEFAULT_PLUGINS_INSTALL_DIR ${MAPNIK_BIN_DIR}/mapnik/input) From 44ab70f14f8af408eb41f607d33da6a2c44795bf Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 24 Mar 2021 15:21:39 +0100 Subject: [PATCH 070/141] find proj without config --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c68aef0c58..7a2b82559c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,7 +202,7 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html message(STATUS "Using PROJ") - mapnik_find_package(PROJ4 CONFIG REQUIRED) + mapnik_find_package(PROJ4 REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ4 ACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1) list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ4_LIBRARIES}) list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) From c4a496e5d36c132f3f52fe3e97cf007551fa9edb Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 24 Mar 2021 23:28:36 +0100 Subject: [PATCH 071/141] copy basic dlls for mapnik-demo --- demo/c++/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/demo/c++/CMakeLists.txt b/demo/c++/CMakeLists.txt index fece18e8a1..bdb517ec01 100644 --- a/demo/c++/CMakeLists.txt +++ b/demo/c++/CMakeLists.txt @@ -9,3 +9,9 @@ install(TARGETS mapnik-demo ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) + +if(COPY_LIBRARIES_FOR_EXECUTABLES AND WIN32) + include(CopyDllsForDebug) + add_custom_command(TARGET mapnik-demo POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}) + copy_dlls_for_debug(mapnik-demo \"\" \"${ADDITIONAL_LIBARIES_PATHS}\") +endif() From 514e2ad5362b931696e3572046edfd5e7eaf6f11 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 24 Mar 2021 23:31:11 +0100 Subject: [PATCH 072/141] test data changes --- test/data | 2 +- test/data-visual | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/data b/test/data index dd0c41c3f9..c67cf11850 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit dd0c41c3f9f5dc98291a727af00bb42734d2a8c0 +Subproject commit c67cf11850d65e963e6103b6141f1eca67667aa2 diff --git a/test/data-visual b/test/data-visual index 1f20cf257f..bacfd251da 160000 --- a/test/data-visual +++ b/test/data-visual @@ -1 +1 @@ -Subproject commit 1f20cf257f35224d3c139a6015b1cf70814b0d24 +Subproject commit bacfd251da550fa82ea56f6710dc6f85431480c2 From 6b3d631edc4178cf6e0f1e1298d49de5992e8062 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 24 Mar 2021 23:55:12 +0100 Subject: [PATCH 073/141] renamed MAPNIK_USE_PROJ4 to MAPNIK_USE_PROJ and removed ACCEPT_USE_OF_DEPRECATED_PROJ_API_H --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a2b82559c..72e308dba0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,7 +203,7 @@ if(USE_PROJ) #https://proj.org/development/cmake.html message(STATUS "Using PROJ") mapnik_find_package(PROJ4 REQUIRED) - list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ4 ACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1) + list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ) list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ4_LIBRARIES}) list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) endif() From 8f8feb3f96a01e0cf4289822c40267c4bf9cfdb9 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 25 Mar 2021 08:52:09 +0100 Subject: [PATCH 074/141] update test data deps. somehow got messed up in last commit --- test/data | 2 +- test/data-visual | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/data b/test/data index c67cf11850..dd0c41c3f9 160000 --- a/test/data +++ b/test/data @@ -1 +1 @@ -Subproject commit c67cf11850d65e963e6103b6141f1eca67667aa2 +Subproject commit dd0c41c3f9f5dc98291a727af00bb42734d2a8c0 diff --git a/test/data-visual b/test/data-visual index bacfd251da..1f20cf257f 160000 --- a/test/data-visual +++ b/test/data-visual @@ -1 +1 @@ -Subproject commit bacfd251da550fa82ea56f6710dc6f85431480c2 +Subproject commit 1f20cf257f35224d3c139a6015b1cf70814b0d24 From a0c7db4df24dd50b318b2c3f419ebcf81da99750 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 25 Mar 2021 13:34:25 +0100 Subject: [PATCH 075/141] add proj_transform_cache to source list --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7599ba4b43..a17e9d6b06 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -58,6 +58,7 @@ set(MAPNIK_SOURCES parse_transform.cpp path_expression_grammar_x3.cpp plugin.cpp + proj_transform_cache.cpp proj_transform.cpp projection.cpp raster_colorizer.cpp From bbd7161891108e59e9202969bd7f46c6ed1f3a1c Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 25 Mar 2021 17:26:29 +0100 Subject: [PATCH 076/141] added benchmarks; needed mutex header --- CMakeLists.txt | 5 +++ benchmark/CMakeLists.txt | 44 +++++++++++++++++++++++++++ benchmark/include/bench_framework.hpp | 1 + 3 files changed, 50 insertions(+) create mode 100644 benchmark/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 72e308dba0..b2a86d971e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,8 @@ 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) +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) @@ -264,6 +266,9 @@ add_subdirectory(src) add_subdirectory(plugins) add_subdirectory(utils) add_subdirectory(demo) +if(BUILD_BENCHMARK) + add_subdirectory(benchmark) +endif() if(BUILD_TEST) enable_testing() add_subdirectory(test) diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt new file mode 100644 index 0000000000..825fc95ea7 --- /dev/null +++ b/benchmark/CMakeLists.txt @@ -0,0 +1,44 @@ +project(mapnik-benchmark) + +set(BENCHMARK_SRCS + src/normalize_angle.cpp + src/test_array_allocation.cpp + src/test_expression_parse.cpp + src/test_face_ptr_creation.cpp + src/test_font_registration.cpp + src/test_getline.cpp + src/test_marker_cache.cpp + src/test_noop_rendering.cpp + src/test_numeric_cast_vs_static_cast.cpp + src/test_offset_converter.cpp + src/test_png_encoding1.cpp + src/test_png_encoding2.cpp + src/test_polygon_clipping_rendering.cpp + src/test_polygon_clipping.cpp + src/test_proj_transform1.cpp + src/test_quad_tree.cpp + src/test_rendering_shared_map.cpp + src/test_rendering.cpp + src/test_to_bool.cpp + src/test_to_double.cpp + src/test_to_int.cpp + src/test_to_string1.cpp + src/test_to_string2.cpp + src/test_utf_encoding.cpp +) +macro(mapnik_create_benchmark) + get_filename_component(BENCHNAME ${ARGV0} NAME_WE) + add_executable(mapnik-benchmark-${BENCHNAME} ${ARGV0}) + target_include_directories(mapnik-benchmark-${BENCHNAME} PRIVATE include) + target_link_libraries(mapnik-benchmark-${BENCHNAME} PRIVATE mapnik::core mapnik::agg mapnik::mapnik) + + if(COPY_LIBRARIES_FOR_EXECUTABLES AND WIN32) + include(CopyDllsForDebug) + add_custom_command(TARGET mapnik-benchmark-${BENCHNAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}) + copy_dlls_for_debug(mapnik-benchmark-${BENCHNAME} \"\" \"${ADDITIONAL_LIBARIES_PATHS}\") + endif() +endmacro() + +foreach(benchmark ${BENCHMARK_SRCS}) + mapnik_create_benchmark(${benchmark}) +endforeach() diff --git a/benchmark/include/bench_framework.hpp b/benchmark/include/bench_framework.hpp index df2a9e57b4..c7729dd160 100644 --- a/benchmark/include/bench_framework.hpp +++ b/benchmark/include/bench_framework.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include namespace benchmark { From f24d7ed3b4b2e5b7a39c20e782d01946280804d0 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 25 Mar 2021 18:42:17 +0100 Subject: [PATCH 077/141] add postgis to unit tests --- test/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c5787b6ace..f2feb2bc74 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,7 @@ project(mapnik-test) find_package(Boost 1.74 REQUIRED COMPONENTS program_options) +find_package(PostgreSQL REQUIRED) include(FetchContent) include(CopyDllsForDebug) @@ -113,6 +114,7 @@ target_link_libraries(mapnik-test-unit PUBLIC mapnik::mapnik mapnik::json mapnik::wkt + PostgreSQL::PostgreSQL ) add_executable(agg_rasterizer_integer_overflow_test standalone/agg_rasterizer_integer_overflow_test.cpp) From 03205ca21ccdd1e8ff62ff95fa7fb8bff0b2c80f Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 25 Mar 2021 18:46:18 +0100 Subject: [PATCH 078/141] changed proj; add mapnik_proj_version; use boost regex icu workaround --- CMakeLists.txt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2a86d971e..0264c2b56a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,6 +61,8 @@ 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) +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) + set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++14 is minimum.") message(STATUS "Using c++${CMAKE_CXX_STANDARD}") @@ -96,6 +98,9 @@ message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}") mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) mapnik_find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) +if(USE_BOOST_REGEX_ICU_WORKAROUND) + set_property(TARGET Boost::regex PROPERTY INTERFACE_LINK_LIBRARIES) +endif() mapnik_find_package(Freetype REQUIRED) mapnik_find_package(harfbuzz CONFIG REQUIRED) @@ -203,11 +208,12 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - message(STATUS "Using PROJ") - mapnik_find_package(PROJ4 REQUIRED) - list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ) - list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ4_LIBRARIES}) - list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) + mapnik_find_package(PROJ REQUIRED) + message(STATUS "Using PROJ version: ${PROJ_VERSION}") + math(EXPR MAPNIK_PROJ_VERSION "${PROJ_VERSION_MAJOR}*10000 + ${PROJ_VERSION_MINOR}*100 + ${PROJ_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) + 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 ${PROJ_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) From 66906f75b6841a44bd596f49d2ad4b568e097827 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 25 Mar 2021 21:28:41 +0100 Subject: [PATCH 079/141] print version strings if available --- CMakeLists.txt | 10 +++------- cmake/MapnikFindPackage.cmake | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0264c2b56a..881c904212 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,11 +96,14 @@ message(STATUS "Installing plugins to ${PLUGINS_INSTALL_DIR}") set(FONTS_INSTALL_DIR ${MAPNIK_BIN_DIR}/fonts CACHE STRING "installs the fonts in the specified directory") message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}") + +# Begin project configuration mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) mapnik_find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) if(USE_BOOST_REGEX_ICU_WORKAROUND) set_property(TARGET Boost::regex PROPERTY INTERFACE_LINK_LIBRARIES) endif() + mapnik_find_package(Freetype REQUIRED) mapnik_find_package(harfbuzz CONFIG REQUIRED) @@ -166,41 +169,35 @@ set(MAPNIK_OPTIONAL_LIBS "") set(MAPNIK_OPTIONAL_LIBS_INCLUDE "") if(USE_LIBXML2) - message(STATUS "Using LibXml2") mapnik_find_package(LibXml2 REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_LIBXML2) list(APPEND MAPNIK_OPTIONAL_LIBS LibXml2::LibXml2) endif() if(USE_PNG) - message(STATUS "Using PNG") mapnik_find_package(PNG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_PNG) list(APPEND MAPNIK_OPTIONAL_LIBS PNG::PNG) endif() if(USE_JPEG) - message(STATUS "Using JPEG") mapnik_find_package(JPEG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG) list(APPEND MAPNIK_OPTIONAL_LIBS JPEG::JPEG) endif() if(USE_TIFF) - message(STATUS "Using TIFF") mapnik_find_package(TIFF REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_TIFF) list(APPEND MAPNIK_OPTIONAL_LIBS TIFF::TIFF) endif() if(USE_WEBP) - message(STATUS "Using WEBP") mapnik_find_package(WebP CONFIG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP) list(APPEND MAPNIK_OPTIONAL_LIBS WebP::webp) endif() if(USE_CAIRO) - message(STATUS "Using Cairo renderer") mapnik_find_package(Cairo REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_CAIRO) list(APPEND MAPNIK_OPTIONAL_LIBS Cairo::Cairo) @@ -209,7 +206,6 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html mapnik_find_package(PROJ REQUIRED) - message(STATUS "Using PROJ version: ${PROJ_VERSION}") math(EXPR MAPNIK_PROJ_VERSION "${PROJ_VERSION_MAJOR}*10000 + ${PROJ_VERSION_MINOR}*100 + ${PROJ_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_USE_PROJ MAPNIK_PROJ_VERSION=${MAPNIK_PROJ_VERSION}) list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES}) diff --git a/cmake/MapnikFindPackage.cmake b/cmake/MapnikFindPackage.cmake index d4e6c5acd9..14c33805ea 100644 --- a/cmake/MapnikFindPackage.cmake +++ b/cmake/MapnikFindPackage.cmake @@ -1,6 +1,23 @@ +macro(mapnik_print_version) + string(TOUPPER ${ARGV0} TLNUP) + set(TLN ${ARGV0}) + if(${TLN}_VERSION_STRING) + message(STATUS "Using ${ARGV0} version: ${${TLN}_VERSION_STRING}") + elseif(${TLN}_VERSION) + message(STATUS "Using ${ARGV0} version: ${${TLN}_VERSION}") + elseif(${TLNUP}_VERSION_STRING) + message(STATUS "Using ${ARGV0} version: ${${TLNUP}_VERSION_STRING}") + elseif(${TLNUP}_VERSION) + message(STATUS "Using ${ARGV0} version: ${${TLNUP}_VERSION}") + else() + message(STATUS "Using ${ARGV0}") + endif() +endmacro() + macro(mapnik_find_package) find_package(${ARGN}) set(MAPNIK_TMP_DEP ${ARGN}) list(JOIN MAPNIK_TMP_DEP " " MAPNIK_TMP_DEP) list(APPEND MAPNIK_DEPENDENCIES "find_dependency(${MAPNIK_TMP_DEP})") + mapnik_print_version(${ARGV0}) endmacro() From 50fa6e4ee1c271780811b6dc04e21952632fa156 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 26 Mar 2021 15:45:15 +0100 Subject: [PATCH 080/141] add threads to mapnik::core --- CMakeLists.txt | 3 +++ cmake/MapnikFindPackage.cmake | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 881c904212..de4ff528d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,7 @@ message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}") # Begin project configuration +mapnik_find_threads() mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) mapnik_find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) if(USE_BOOST_REGEX_ICU_WORKAROUND) @@ -207,6 +208,7 @@ if(USE_PROJ) #https://proj.org/development/cmake.html mapnik_find_package(PROJ REQUIRED) 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 ${PROJ_INCLUDE_DIRS}) @@ -242,6 +244,7 @@ target_include_directories(core INTERFACE ${MAPNIK_OPTIONAL_LIBS_INCLUDE} ) target_link_libraries(core INTERFACE + Threads::Threads ICU::uc ICU::data ICU::i18n diff --git a/cmake/MapnikFindPackage.cmake b/cmake/MapnikFindPackage.cmake index 14c33805ea..a4a10ba7dd 100644 --- a/cmake/MapnikFindPackage.cmake +++ b/cmake/MapnikFindPackage.cmake @@ -21,3 +21,18 @@ macro(mapnik_find_package) list(APPEND MAPNIK_DEPENDENCIES "find_dependency(${MAPNIK_TMP_DEP})") mapnik_print_version(${ARGV0}) endmacro() + +macro(mapnik_find_threads) + find_package(Threads REQUIRED) + if(CMAKE_THREAD_LIBS_INIT) + message(STATUS "Using Threads (system libraries)") + elseif(CMAKE_USE_WIN32_THREADS_INIT) + message(STATUS "Using Threads (win32 threads)") + elseif(CMAKE_USE_PTHREADS_INIT) + message(STATUS "Using Threads (pthread)") + elseif(CMAKE_HP_PTHREADS_INIT) + message(STATUS "Using Threads (HP thread)") + else() + message(STATUS "Using Threads (unknown backend)") + endif() +endmacro() From dd028aa6d1e0661ab5d886bc712f2c1500173110 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 31 Mar 2021 20:25:46 +0200 Subject: [PATCH 081/141] hopefully fix unstatisfied proj_transform_cache --- src/cairo_io.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cairo_io.cpp b/src/cairo_io.cpp index 7d524e61f7..13f4689e24 100644 --- a/src/cairo_io.cpp +++ b/src/cairo_io.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #ifdef HAVE_CAIRO #include From aa9b391bcf7641a4e68280b69a243a5d0ea3da49 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 1 Apr 2021 15:55:57 +0200 Subject: [PATCH 082/141] Revert "hopefully fix unstatisfied proj_transform_cache" This reverts commit d2066da339a9732223fa3e00c636c4c7cd6ca2e3. --- src/cairo_io.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cairo_io.cpp b/src/cairo_io.cpp index 13f4689e24..7d524e61f7 100644 --- a/src/cairo_io.cpp +++ b/src/cairo_io.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #ifdef HAVE_CAIRO #include From 9df9d734f5b35eedd4a7317afe0e6e5ef53db542 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 1 Apr 2021 16:03:58 +0200 Subject: [PATCH 083/141] try fix linux take II --- include/mapnik/map.hpp | 2 +- src/map.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/mapnik/map.hpp b/include/mapnik/map.hpp index 7b0c155c57..8cb81f5db7 100644 --- a/include/mapnik/map.hpp +++ b/include/mapnik/map.hpp @@ -103,7 +103,7 @@ class MAPNIK_DECL Map : boost::equality_comparable boost::optional font_directory_; freetype_engine::font_file_mapping_type font_file_mapping_; freetype_engine::font_memory_cache_type font_memory_cache_; - std::unique_ptr proj_cache_ = {}; + std::unique_ptr proj_cache_; public: using const_style_iterator = std::map::const_iterator; using style_iterator = std::map::iterator; diff --git a/src/map.cpp b/src/map.cpp index 8d20225ca5..bc7d4d2c4b 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -76,7 +76,8 @@ Map::Map() extra_params_(), font_directory_(), font_file_mapping_(), - font_memory_cache_() {} + font_memory_cache_(), + proj_cache_(std::make_unique()) {} Map::Map(int width,int height, std::string const& srs) : width_(width), @@ -90,7 +91,8 @@ Map::Map(int width,int height, std::string const& srs) extra_params_(), font_directory_(), font_file_mapping_(), - font_memory_cache_() {} + font_memory_cache_(), + proj_cache_(std::make_unique()) {} Map::Map(Map const& rhs) : width_(rhs.width_), @@ -112,7 +114,8 @@ Map::Map(Map const& rhs) font_directory_(rhs.font_directory_), font_file_mapping_(rhs.font_file_mapping_), // on copy discard memory caches - font_memory_cache_() + font_memory_cache_(), + proj_cache_(std::make_unique()) { init_proj_transforms(); } From f14bffc99af45b8ea0b8568674421a3640c89e89 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 1 Apr 2021 16:15:32 +0200 Subject: [PATCH 084/141] add BIGINT and MAPNIK_MEMORY_MAPPED_FILE; require cxx standard, disable compiler specific flags (CXX_EXTENSIONS) --- CMakeLists.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index de4ff528d3..bb00aaae93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,8 @@ 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 grid renderer" ON) +option(USE_BIGINT "uses 64 bit instead of 32" ON) +option(USE_MEMORY_MAPPED_FILE "uses file cache" ON) option(USE_PLUGIN_INPUT_CSV "adds plugin input csv" ON) option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON) @@ -65,6 +67,11 @@ option(USE_BOOST_REGEX_ICU_WORKAROUND "if you don't use your system libraries an set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++14 is minimum.") message(STATUS "Using c++${CMAKE_CXX_STANDARD}") +# 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++ 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 if(WIN32) set(DEFAULT_BIN_DIR bin) @@ -169,6 +176,15 @@ set(MAPNIK_COMPILE_DEFS "") set(MAPNIK_OPTIONAL_LIBS "") set(MAPNIK_OPTIONAL_LIBS_INCLUDE "") +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_LIBXML2) mapnik_find_package(LibXml2 REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_LIBXML2) From b9d970eb5aa0e556917ace02e97b8a898c0d3813 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 1 Apr 2021 18:01:43 +0200 Subject: [PATCH 085/141] fix typo grid renderer -> svg renderer --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb00aaae93..25ac6309fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ 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 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) From bb800e6f5678edc3e765735130baeeb28d61d613 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 9 Apr 2021 15:50:50 +0200 Subject: [PATCH 086/141] fixed Dll copying on windows; copy plugins and fonts into appropiate directories when building. --- CMakeLists.txt | 3 +- benchmark/CMakeLists.txt | 28 +++++++++------ cmake/CopyDllsForDebug.cmake | 14 +++++--- cmake/MapnikCopyDependencies.cmake | 58 ++++++++++++++++++++++++++++++ demo/c++/CMakeLists.txt | 8 ++--- demo/viewer/CMakeLists.txt | 12 +++---- test/CMakeLists.txt | 22 ++++++++---- 7 files changed, 113 insertions(+), 32 deletions(-) create mode 100644 cmake/MapnikCopyDependencies.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 25ac6309fe..a01e05b495 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,8 +16,9 @@ message(STATUS "mapnik version: ${PROJECT_VERSION}") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(MapnikFindPackage) +include(MapnikCopyDependencies) -set(ADDITIONAL_LIBARIES_PATHS "" CACHE STRING "currently only used on windows. Pass directories containing the dlls that are missing. You can ignore this, if the build (verify_app step) runs successfully" "") +set(ADDITIONAL_LIBARIES_PATHS "" CACHE STRING "currently 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 (currently only windows) to the executable directory" ON) option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON) diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 825fc95ea7..7e409fb17d 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -26,18 +26,26 @@ set(BENCHMARK_SRCS src/test_to_string2.cpp src/test_utf_encoding.cpp ) -macro(mapnik_create_benchmark) +function(mapnik_create_benchmark) get_filename_component(BENCHNAME ${ARGV0} NAME_WE) - add_executable(mapnik-benchmark-${BENCHNAME} ${ARGV0}) - target_include_directories(mapnik-benchmark-${BENCHNAME} PRIVATE include) - target_link_libraries(mapnik-benchmark-${BENCHNAME} PRIVATE mapnik::core mapnik::agg mapnik::mapnik) + set(TARGET_NAME "mapnik-benchmark-${BENCHNAME}") + add_executable(${TARGET_NAME} ${ARGV0}) + target_include_directories(${TARGET_NAME} PRIVATE include) + target_link_libraries(${TARGET_NAME} PRIVATE mapnik::core mapnik::agg mapnik::mapnik) + + # it might be possible that some buildsystems generate different directories. So invoke the scripts for all benchmarks + mapnik_copy_plugins(TARGET ${TARGET_NAME} + DESTINATION plugins/input + PLUGINS + input-csv input-gdal input-geobuf input-geojson input-ogr input-pgraster input-postgis input-raster input-shape input-sqlite input-topojson + ) + mapnik_require_fonts(TARGET ${TARGET_NAME} mapnik-test-unit DESTINATION fonts) - if(COPY_LIBRARIES_FOR_EXECUTABLES AND WIN32) - include(CopyDllsForDebug) - add_custom_command(TARGET mapnik-benchmark-${BENCHNAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}) - copy_dlls_for_debug(mapnik-benchmark-${BENCHNAME} \"\" \"${ADDITIONAL_LIBARIES_PATHS}\") - endif() -endmacro() + mapnik_copy_dependencies(TARGETS ${TARGET_NAME} + PLUGINS + input-csv input-gdal input-geobuf input-geojson input-ogr input-pgraster input-postgis input-raster input-shape input-sqlite input-topojson + ) +endfunction() foreach(benchmark ${BENCHMARK_SRCS}) mapnik_create_benchmark(${benchmark}) diff --git a/cmake/CopyDllsForDebug.cmake b/cmake/CopyDllsForDebug.cmake index 7f668868a6..3c0e118a65 100644 --- a/cmake/CopyDllsForDebug.cmake +++ b/cmake/CopyDllsForDebug.cmake @@ -11,19 +11,25 @@ if(RUN_IT) # Script ran by the add_custom_command include(BundleUtilities) include(InstallRequiredSystemLibraries) + string (REPLACE " " ";" TO_FIXUP_LIBS "${TO_FIXUP_LIBS}") + string (REPLACE " " ";" TO_FIXUP_DIRS "${TO_FIXUP_DIRS}") + #message(STATUS "${TO_FIXUP_FILE} ${TO_FIXUP_LIBS} ${TO_FIXUP_DIRS}") fixup_bundle("${TO_FIXUP_FILE}" "${TO_FIXUP_LIBS}" "${TO_FIXUP_DIRS}") # End of script ran by the add_custom_command else() set(THIS_FILE ${CMAKE_CURRENT_LIST_FILE}) -function(copy_dlls_for_debug _targets _libs _dirs) +function(copy_dlls_for_debug) + set(options) + set(oneValueArgs) + set(multiValueArgs TARGETS LIBS DIRS) + cmake_parse_arguments(MAPNIK_COPY_DLLS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) if(WIN32) - foreach(_target ${_targets}) + foreach(_target IN LISTS MAPNIK_COPY_DLLS_TARGETS) add_custom_command( TARGET ${_target} POST_BUILD - COMMAND ${CMAKE_COMMAND} -DRUN_IT:BOOL=ON -DTO_FIXUP_FILE=$ -DTO_FIXUP_LIBS=${_libs} -DTO_FIXUP_DIRS=${_dirs} -P ${THIS_FILE} + COMMAND ${CMAKE_COMMAND} ARGS -DRUN_IT:BOOL=ON -DTO_FIXUP_FILE="$" -DTO_FIXUP_LIBS:STRING="${MAPNIK_COPY_DLLS_LIBS}" -DTO_FIXUP_DIRS="${MAPNIK_COPY_DLLS_DIRS}" -P "${THIS_FILE}" COMMENT "Fixing up dependencies for ${_target}" - VERBATIM ) endforeach() endif(WIN32) diff --git a/cmake/MapnikCopyDependencies.cmake b/cmake/MapnikCopyDependencies.cmake new file mode 100644 index 0000000000..11736c7e4b --- /dev/null +++ b/cmake/MapnikCopyDependencies.cmake @@ -0,0 +1,58 @@ +function(mapnik_find_target_location) + set(options) + set(multiValueArgs TARGETS) + cmake_parse_arguments( WIG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + +endfunction() + +function(mapnik_copy_dependencies) + if(COPY_LIBRARIES_FOR_EXECUTABLES AND WIN32) + set(options) + set(oneValueArgs) + set(multiValueArgs TARGETS PLUGINS) + cmake_parse_arguments(MAPNIK_CP_DEPS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + include(CopyDllsForDebug) + foreach(TARGET IN LISTS MAPNIK_CP_DEPS_TARGETS) + add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}) + endforeach() + + set(LIBS "") + foreach(PLUGIN IN LISTS MAPNIK_CP_DEPS_PLUGINS) + if(TARGET ${PLUGIN}) # only copy plugins that are be build + list(APPEND LIBS "$") + endif() + endforeach() + copy_dlls_for_debug(TARGETS ${MAPNIK_CP_DEPS_TARGETS} LIBS ${LIBS} DIRS ${ADDITIONAL_LIBARIES_PATHS}) + endif() +endfunction() + +function(mapnik_copy_plugins) + set(options) + set(oneValueArgs TARGET DESTINATION) + set(multiValueArgs PLUGINS) + cmake_parse_arguments(MAPNIK_CP_PLG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # copy_if_different requires a existing directory. + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${MAPNIK_CP_PLG_DESTINATION}) + foreach(PLUGIN IN LISTS MAPNIK_CP_PLG_PLUGINS) + #message(STATUS "copying plugin ${PLUGIN} to path: ${CMAKE_CURRENT_BINARY_DIR}/${MAPNIK_CP_PLG_DESTINATION}") + if(TARGET ${PLUGIN}) + add_custom_command(TARGET ${MAPNIK_CP_PLG_TARGET} POST_BUILD COMMAND + ${CMAKE_COMMAND} -E copy_if_different "$" ${CMAKE_CURRENT_BINARY_DIR}/${MAPNIK_CP_PLG_DESTINATION}/) + else() + message(NOTICE "${MAPNIK_CP_PLG_TARGET} requires plugin ${PLUGIN} but it isn't build. Check USE_PLUGIN_INPUT_ options to enable the plugin.") + endif() + endforeach() + +endfunction() + +function(mapnik_require_fonts) + set(options) + set(oneValueArgs TARGET DESTINATION) + set(multiValueArgs) + cmake_parse_arguments(MAPNIK_REQUIRE_FONTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + add_custom_command(TARGET ${MAPNIK_REQUIRE_FONTS_TARGET} POST_BUILD COMMAND + ${CMAKE_COMMAND} -E copy_directory ${mapnik_SOURCE_DIR}/fonts ${CMAKE_CURRENT_BINARY_DIR}/${MAPNIK_REQUIRE_FONTS_DESTINATION}/) +endfunction() diff --git a/demo/c++/CMakeLists.txt b/demo/c++/CMakeLists.txt index bdb517ec01..00bd7cf0f3 100644 --- a/demo/c++/CMakeLists.txt +++ b/demo/c++/CMakeLists.txt @@ -10,8 +10,6 @@ install(TARGETS mapnik-demo RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) -if(COPY_LIBRARIES_FOR_EXECUTABLES AND WIN32) - include(CopyDllsForDebug) - add_custom_command(TARGET mapnik-demo POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}) - copy_dlls_for_debug(mapnik-demo \"\" \"${ADDITIONAL_LIBARIES_PATHS}\") -endif() +mapnik_copy_plugins(TARGET mapnik-demo DESTINATION plugins/input PLUGINS input-shape) +mapnik_require_fonts(TARGET mapnik-demo DESTINATION fonts) +mapnik_copy_dependencies(TARGETS mapnik-demo PLUGINS input-shape) diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index 5d71d1c40f..9d0aadbadd 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -45,9 +45,9 @@ install(TARGETS mapnik-viewer RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) - -if(COPY_LIBRARIES_FOR_EXECUTABLES AND WIN32) - include(CopyDllsForDebug) - add_custom_command(TARGET mapnik-viewer POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}) - copy_dlls_for_debug(mapnik-viewer \"\" \"${ADDITIONAL_LIBARIES_PATHS}\") -endif() +mapnik_copy_dependencies( + TARGETS + mapnik-viewer + PLUGINS + input-csv input-gdal input-geobuf input-geojson input-ogr input-pgraster input-postgis input-raster input-shape input-sqlite input-topojson +) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f2feb2bc74..f29c53cc4e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -173,12 +173,22 @@ include(CTest) include(${catch2_SOURCE_DIR}/contrib/Catch.cmake) include(${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake) -if(COPY_LIBRARIES_FOR_EXECUTABLES AND WIN32) - include(CopyDllsForDebug) - add_custom_command(TARGET mapnik-test-unit POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" ${CMAKE_CURRENT_BINARY_DIR}) - set(APPS mapnik-test-unit agg_rasterizer_integer_overflow_test datasource_registration_test font_registration_test map_xml_test mapnik-test-visual) - copy_dlls_for_debug(${APPS} \"\" \"${ADDITIONAL_LIBARIES_PATHS}\") -endif() +# use only mapnik-test-unit since it has the same build path +mapnik_copy_plugins( + TARGET mapnik-test-unit + DESTINATION plugins/input + PLUGINS + input-csv input-gdal input-geobuf input-geojson input-ogr input-pgraster input-postgis input-raster input-shape input-sqlite input-topojson +) +mapnik_require_fonts(TARGET mapnik-test-unit DESTINATION fonts) + +mapnik_copy_dependencies( + TARGETS + mapnik-test-unit agg_rasterizer_integer_overflow_test datasource_registration_test font_registration_test map_xml_test mapnik-test-visual + PLUGINS + input-csv input-gdal input-geobuf input-geojson input-ogr input-pgraster input-postgis input-raster input-shape input-sqlite input-topojson +) + file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test) file(COPY data-visual DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test) From 1c7630f124e46b3003b568e24536cddf92deb74a Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 9 Apr 2021 15:53:21 +0200 Subject: [PATCH 087/141] add an option to disable plugin and font copying --- CMakeLists.txt | 5 +-- cmake/MapnikCopyDependencies.cmake | 49 ++++++++++++++++-------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a01e05b495..3e6bda8556 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,9 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(MapnikFindPackage) include(MapnikCopyDependencies) -set(ADDITIONAL_LIBARIES_PATHS "" CACHE STRING "currently 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 (currently only windows) to the executable directory" ON) +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" ON) +option(COPY_FONTS_AND_PLUGINS_FOR_EXECUTABLES "copies required plugins and fonts into the executable build directory" ON) option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON) option(BUILD_TEST "builds the tests" ON) diff --git a/cmake/MapnikCopyDependencies.cmake b/cmake/MapnikCopyDependencies.cmake index 11736c7e4b..4d14174a7a 100644 --- a/cmake/MapnikCopyDependencies.cmake +++ b/cmake/MapnikCopyDependencies.cmake @@ -28,31 +28,34 @@ function(mapnik_copy_dependencies) endfunction() function(mapnik_copy_plugins) - set(options) - set(oneValueArgs TARGET DESTINATION) - set(multiValueArgs PLUGINS) - cmake_parse_arguments(MAPNIK_CP_PLG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - - # copy_if_different requires a existing directory. - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${MAPNIK_CP_PLG_DESTINATION}) - foreach(PLUGIN IN LISTS MAPNIK_CP_PLG_PLUGINS) - #message(STATUS "copying plugin ${PLUGIN} to path: ${CMAKE_CURRENT_BINARY_DIR}/${MAPNIK_CP_PLG_DESTINATION}") - if(TARGET ${PLUGIN}) - add_custom_command(TARGET ${MAPNIK_CP_PLG_TARGET} POST_BUILD COMMAND - ${CMAKE_COMMAND} -E copy_if_different "$" ${CMAKE_CURRENT_BINARY_DIR}/${MAPNIK_CP_PLG_DESTINATION}/) - else() - message(NOTICE "${MAPNIK_CP_PLG_TARGET} requires plugin ${PLUGIN} but it isn't build. Check USE_PLUGIN_INPUT_ options to enable the plugin.") - endif() - endforeach() - + if(COPY_FONTS_AND_PLUGINS_FOR_EXECUTABLES) + set(options) + set(oneValueArgs TARGET DESTINATION) + set(multiValueArgs PLUGINS) + cmake_parse_arguments(MAPNIK_CP_PLG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # copy_if_different requires a existing directory. + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${MAPNIK_CP_PLG_DESTINATION}) + foreach(PLUGIN IN LISTS MAPNIK_CP_PLG_PLUGINS) + #message(STATUS "copying plugin ${PLUGIN} to path: ${CMAKE_CURRENT_BINARY_DIR}/${MAPNIK_CP_PLG_DESTINATION}") + if(TARGET ${PLUGIN}) + add_custom_command(TARGET ${MAPNIK_CP_PLG_TARGET} POST_BUILD COMMAND + ${CMAKE_COMMAND} -E copy_if_different "$" ${CMAKE_CURRENT_BINARY_DIR}/${MAPNIK_CP_PLG_DESTINATION}/) + else() + message(NOTICE "${MAPNIK_CP_PLG_TARGET} requires plugin ${PLUGIN} but it isn't build. Check USE_PLUGIN_INPUT_ options to enable the plugin.") + endif() + endforeach() + endif() endfunction() function(mapnik_require_fonts) - set(options) - set(oneValueArgs TARGET DESTINATION) - set(multiValueArgs) - cmake_parse_arguments(MAPNIK_REQUIRE_FONTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + if(COPY_FONTS_AND_PLUGINS_FOR_EXECUTABLES) + set(options) + set(oneValueArgs TARGET DESTINATION) + set(multiValueArgs) + cmake_parse_arguments(MAPNIK_REQUIRE_FONTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - add_custom_command(TARGET ${MAPNIK_REQUIRE_FONTS_TARGET} POST_BUILD COMMAND - ${CMAKE_COMMAND} -E copy_directory ${mapnik_SOURCE_DIR}/fonts ${CMAKE_CURRENT_BINARY_DIR}/${MAPNIK_REQUIRE_FONTS_DESTINATION}/) + add_custom_command(TARGET ${MAPNIK_REQUIRE_FONTS_TARGET} POST_BUILD COMMAND + ${CMAKE_COMMAND} -E copy_directory ${mapnik_SOURCE_DIR}/fonts ${CMAKE_CURRENT_BINARY_DIR}/${MAPNIK_REQUIRE_FONTS_DESTINATION}/) + endif() endfunction() From 462ea87bda19266b600605c129fdeed5c3afb92e Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 10 Apr 2021 14:36:22 +0200 Subject: [PATCH 088/141] install dependencies. Required for windows (and ?macos?). Needs testing on linux. --- CMakeLists.txt | 7 +++ benchmark/CMakeLists.txt | 27 ++++++------ cmake/MapnikInstall.cmake | 61 +++++++++++++++++++++++++++ demo/c++/CMakeLists.txt | 7 +-- demo/viewer/CMakeLists.txt | 6 +-- plugins/input/csv/CMakeLists.txt | 2 + plugins/input/gdal/CMakeLists.txt | 4 +- plugins/input/geobuf/CMakeLists.txt | 4 +- plugins/input/geojson/CMakeLists.txt | 4 +- plugins/input/ogr/CMakeLists.txt | 4 +- plugins/input/pgraster/CMakeLists.txt | 4 +- plugins/input/postgis/CMakeLists.txt | 4 +- plugins/input/raster/CMakeLists.txt | 4 +- plugins/input/shape/CMakeLists.txt | 4 +- plugins/input/sqlite/CMakeLists.txt | 4 +- plugins/input/topojson/CMakeLists.txt | 4 +- src/CMakeLists.txt | 2 + src/json/CMakeLists.txt | 7 +-- src/wkt/CMakeLists.txt | 7 +-- utils/geometry_to_wkb/CMakeLists.txt | 7 +-- utils/mapnik-index/CMakeLists.txt | 8 +--- utils/mapnik-render/CMakeLists.txt | 8 +--- utils/ogrindex/CMakeLists.txt | 2 + utils/pgsql2sqlite/CMakeLists.txt | 7 +-- utils/shapeindex/CMakeLists.txt | 8 +--- utils/svg2png/CMakeLists.txt | 8 +--- 26 files changed, 113 insertions(+), 101 deletions(-) create mode 100644 cmake/MapnikInstall.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e6bda8556..9cef601130 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,10 +17,12 @@ message(STATUS "mapnik version: ${PROJECT_VERSION}") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 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" ON) 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) option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON) option(BUILD_TEST "builds the tests" ON) @@ -177,6 +179,9 @@ endif() set(MAPNIK_COMPILE_DEFS "") set(MAPNIK_OPTIONAL_LIBS "") set(MAPNIK_OPTIONAL_LIBS_INCLUDE "") +# (used by MapnikInstall.cmake. properties are needed since "set(...)" will be out of scope +set_property(GLOBAL PROPERTY TARGETS "") +set_property(GLOBAL PROPERTY PLUGINS "") if(USE_BIGINT) message(STATUS "uses BIGINT") @@ -331,3 +336,5 @@ install(EXPORT MapnikTargets install(DIRECTORY include/ TYPE INCLUDE) install(DIRECTORY deps/agg/include/ TYPE INCLUDE) install(DIRECTORY fonts/ DESTINATION ${FONTS_INSTALL_DIR} FILES_MATCHING PATTERN "*.py" EXCLUDE PATTERN "*") + +mapnik_install_targets() diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 7e409fb17d..d67b4411f9 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -32,21 +32,24 @@ function(mapnik_create_benchmark) add_executable(${TARGET_NAME} ${ARGV0}) target_include_directories(${TARGET_NAME} PRIVATE include) target_link_libraries(${TARGET_NAME} PRIVATE mapnik::core mapnik::agg mapnik::mapnik) - - # it might be possible that some buildsystems generate different directories. So invoke the scripts for all benchmarks - mapnik_copy_plugins(TARGET ${TARGET_NAME} - DESTINATION plugins/input - PLUGINS - input-csv input-gdal input-geobuf input-geojson input-ogr input-pgraster input-postgis input-raster input-shape input-sqlite input-topojson - ) - mapnik_require_fonts(TARGET ${TARGET_NAME} mapnik-test-unit DESTINATION fonts) - mapnik_copy_dependencies(TARGETS ${TARGET_NAME} - PLUGINS - input-csv input-gdal input-geobuf input-geojson input-ogr input-pgraster input-postgis input-raster input-shape input-sqlite input-topojson - ) + mapnik_copy_dependencies(TARGETS ${TARGET_NAME}) endfunction() foreach(benchmark ${BENCHMARK_SRCS}) mapnik_create_benchmark(${benchmark}) endforeach() + +# we just need one target to reference the directory correctly. mapnik-benchmark-normalize_angle is just the first in BENCHMARK_SRCS +mapnik_require_fonts(TARGET mapnik-benchmark-normalize_angle DESTINATION fonts) +# copy all plugins +mapnik_copy_plugins(TARGET mapnik-benchmark-normalize_angle + DESTINATION plugins/input + PLUGINS + input-csv input-gdal input-geobuf input-geojson input-ogr input-pgraster input-postgis input-raster input-shape input-sqlite input-topojson +) +# copy all plugin dlls. +mapnik_copy_dependencies(TARGETS mapnik-benchmark-normalize_angle + PLUGINS + input-csv input-gdal input-geobuf input-geojson input-ogr input-pgraster input-postgis input-raster input-shape input-sqlite input-topojson +) diff --git a/cmake/MapnikInstall.cmake b/cmake/MapnikInstall.cmake new file mode 100644 index 0000000000..38b6c687d1 --- /dev/null +++ b/cmake/MapnikInstall.cmake @@ -0,0 +1,61 @@ +function(mapnik_install) + set(options ALREADY_INSTALLED IS_PLUGIN) + set(oneValueArgs TARGET) + set(multiValueArgs) + cmake_parse_arguments(MAPNIK_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(NOT ${MAPNIK_INSTALL_ALREADY_INSTALLED} AND NOT ${MAPNIK_INSTALL_IS_PLUGIN}) + install(TARGETS ${MAPNIK_INSTALL_TARGET} + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} + ) + elseif(NOT ${MAPNIK_INSTALL_ALREADY_INSTALLED} AND ${MAPNIK_INSTALL_IS_PLUGIN}) + install(TARGETS ${MAPNIK_INSTALL_TARGET} + RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} + ) + endif() + if(NOT ${MAPNIK_INSTALL_IS_PLUGIN}) + message(STATUS "${MAPNIK_INSTALL_TARGET}") + get_target_property(TARGET_TYPE "${MAPNIK_INSTALL_TARGET}" TYPE) + if (TARGET_TYPE STREQUAL "EXECUTABLE") + get_property(MAPNIK_INSTALLED_TARGETS GLOBAL PROPERTY TARGETS) + list(APPEND MAPNIK_INSTALLED_TARGETS ${MAPNIK_INSTALL_TARGET}) + set_property(GLOBAL PROPERTY TARGETS ${MAPNIK_INSTALLED_TARGETS}) + endif() + else() + get_property(MAPNIK_INSTALLED_PLUGINS GLOBAL PROPERTY PLUGINS) + list(APPEND MAPNIK_INSTALLED_PLUGINS ${MAPNIK_INSTALL_TARGET}) + set_property(GLOBAL PROPERTY PLUGINS ${MAPNIK_INSTALLED_PLUGINS}) + endif() +endfunction() + + +function(mapnik_install_targets) + if(INSTALL_DEPENDENCIES) + # https://cmake.org/cmake/help/latest/policy/CMP0087.html + cmake_policy(SET CMP0087 NEW) + get_property(MAPNIK_INSTALLED_TARGETS GLOBAL PROPERTY TARGETS) + get_property(MAPNIK_INSTALLED_PLUGINS GLOBAL PROPERTY PLUGINS) + set(INTERNAL_TARGETS "") + set(INTERNAL_PLUGINS "") + + foreach(_target IN LISTS MAPNIK_INSTALLED_TARGETS) + list(APPEND INTERNAL_TARGETS "${CMAKE_INSTALL_PREFIX}/${MAPNIK_BIN_DIR}/$") + endforeach() + foreach(_target IN LISTS MAPNIK_INSTALLED_PLUGINS) + list(APPEND INTERNAL_PLUGINS "${CMAKE_INSTALL_PREFIX}/${PLUGINS_INSTALL_DIR}/$") + endforeach() + # all other executables get auto detected and fixed. + list(GET INTERNAL_TARGETS 0 INTERNAL_TARGETS) + + INSTALL(CODE " + message(STATUS \"${INTERNAL_TARGETS}\") + message(STATUS \"${INTERNAL_PLUGINS}\") + + include(BundleUtilities) + fixup_bundle(\"${INTERNAL_TARGETS}\" \"${INTERNAL_PLUGINS}\" \"${ADDITIONAL_LIBARIES_PATHS}\") + " COMPONENT Runtime) + endif() + +endfunction() diff --git a/demo/c++/CMakeLists.txt b/demo/c++/CMakeLists.txt index 00bd7cf0f3..7b86d37f20 100644 --- a/demo/c++/CMakeLists.txt +++ b/demo/c++/CMakeLists.txt @@ -4,12 +4,7 @@ add_executable(mapnik-demo rundemo.cpp) target_link_libraries(mapnik-demo PRIVATE mapnik::core mapnik::agg mapnik::mapnik) -install(TARGETS mapnik-demo - LIBRARY DESTINATION ${MAPNIK_LIB_DIR} - ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} - RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) - +mapnik_install(TARGET mapnik-demo) mapnik_copy_plugins(TARGET mapnik-demo DESTINATION plugins/input PLUGINS input-shape) mapnik_require_fonts(TARGET mapnik-demo DESTINATION fonts) mapnik_copy_dependencies(TARGETS mapnik-demo PLUGINS input-shape) diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index 9d0aadbadd..01fab3db86 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -39,11 +39,7 @@ plugins_dir=${PLUGINS_INSTALL_DIR} fonts/1/dir=${FONTS_INSTALL_DIR}" ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini DESTINATION bin) -install(TARGETS mapnik-viewer - LIBRARY DESTINATION ${MAPNIK_LIB_DIR} - ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} - RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) +mapnik_install(TARGET mapnik-viewer) mapnik_copy_dependencies( TARGETS diff --git a/plugins/input/csv/CMakeLists.txt b/plugins/input/csv/CMakeLists.txt index 677ac25386..3d251a5eac 100644 --- a/plugins/input/csv/CMakeLists.txt +++ b/plugins/input/csv/CMakeLists.txt @@ -23,3 +23,5 @@ set_target_properties(input-csv PROPERTIES SUFFIX ".input") install(TARGETS input-csv RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} ) + +mapnik_install(TARGET input-csv IS_PLUGIN) diff --git a/plugins/input/gdal/CMakeLists.txt b/plugins/input/gdal/CMakeLists.txt index 4b35fb8145..92b3057663 100644 --- a/plugins/input/gdal/CMakeLists.txt +++ b/plugins/input/gdal/CMakeLists.txt @@ -18,6 +18,4 @@ set_target_properties(input-gdal PROPERTIES PREFIX "") set_target_properties(input-gdal PROPERTIES OUTPUT_NAME "gdal") set_target_properties(input-gdal PROPERTIES SUFFIX ".input") -install(TARGETS input-gdal - RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} -) +mapnik_install(TARGET input-gdal IS_PLUGIN) diff --git a/plugins/input/geobuf/CMakeLists.txt b/plugins/input/geobuf/CMakeLists.txt index 73d39e14a7..bb5fef85e4 100644 --- a/plugins/input/geobuf/CMakeLists.txt +++ b/plugins/input/geobuf/CMakeLists.txt @@ -14,6 +14,4 @@ set_target_properties(input-geobuf PROPERTIES PREFIX "") set_target_properties(input-geobuf PROPERTIES OUTPUT_NAME "geobuf") set_target_properties(input-geobuf PROPERTIES SUFFIX ".input") -install(TARGETS input-geobuf - RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} -) +mapnik_install(TARGET input-geobuf IS_PLUGIN) diff --git a/plugins/input/geojson/CMakeLists.txt b/plugins/input/geojson/CMakeLists.txt index 09da0e935b..39b392fe56 100644 --- a/plugins/input/geojson/CMakeLists.txt +++ b/plugins/input/geojson/CMakeLists.txt @@ -18,6 +18,4 @@ set_target_properties(input-geojson PROPERTIES PREFIX "") set_target_properties(input-geojson PROPERTIES OUTPUT_NAME "geojson") set_target_properties(input-geojson PROPERTIES SUFFIX ".input") -install(TARGETS input-geojson - RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} -) +mapnik_install(TARGET input-geojson IS_PLUGIN) diff --git a/plugins/input/ogr/CMakeLists.txt b/plugins/input/ogr/CMakeLists.txt index 3656e3a79a..0791c093bc 100644 --- a/plugins/input/ogr/CMakeLists.txt +++ b/plugins/input/ogr/CMakeLists.txt @@ -20,6 +20,4 @@ set_target_properties(input-ogr PROPERTIES PREFIX "") set_target_properties(input-ogr PROPERTIES OUTPUT_NAME "ogr") set_target_properties(input-ogr PROPERTIES SUFFIX ".input") -install(TARGETS input-ogr - RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} -) +mapnik_install(TARGET input-ogr IS_PLUGIN) diff --git a/plugins/input/pgraster/CMakeLists.txt b/plugins/input/pgraster/CMakeLists.txt index fe6622cf0a..146036044c 100644 --- a/plugins/input/pgraster/CMakeLists.txt +++ b/plugins/input/pgraster/CMakeLists.txt @@ -19,6 +19,4 @@ set_target_properties(input-pgraster PROPERTIES PREFIX "") set_target_properties(input-pgraster PROPERTIES OUTPUT_NAME "pgraster") set_target_properties(input-pgraster PROPERTIES SUFFIX ".input") -install(TARGETS input-pgraster - RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} -) +mapnik_install(TARGET input-pgraster IS_PLUGIN) diff --git a/plugins/input/postgis/CMakeLists.txt b/plugins/input/postgis/CMakeLists.txt index 73113f2828..0102bac63d 100644 --- a/plugins/input/postgis/CMakeLists.txt +++ b/plugins/input/postgis/CMakeLists.txt @@ -18,6 +18,4 @@ set_target_properties(input-postgis PROPERTIES PREFIX "") set_target_properties(input-postgis PROPERTIES OUTPUT_NAME "postgis") set_target_properties(input-postgis PROPERTIES SUFFIX ".input") -install(TARGETS input-postgis - RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} -) +mapnik_install(TARGET input-postgis IS_PLUGIN) diff --git a/plugins/input/raster/CMakeLists.txt b/plugins/input/raster/CMakeLists.txt index 548a361a21..9956b6d9b8 100644 --- a/plugins/input/raster/CMakeLists.txt +++ b/plugins/input/raster/CMakeLists.txt @@ -16,6 +16,4 @@ set_target_properties(input-raster PROPERTIES PREFIX "") set_target_properties(input-raster PROPERTIES OUTPUT_NAME "raster") set_target_properties(input-raster PROPERTIES SUFFIX ".input") -install(TARGETS input-raster - RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} -) +mapnik_install(TARGET input-raster IS_PLUGIN) diff --git a/plugins/input/shape/CMakeLists.txt b/plugins/input/shape/CMakeLists.txt index ed3a1f3659..c0a42b460d 100644 --- a/plugins/input/shape/CMakeLists.txt +++ b/plugins/input/shape/CMakeLists.txt @@ -19,6 +19,4 @@ set_target_properties(input-shape PROPERTIES PREFIX "") set_target_properties(input-shape PROPERTIES OUTPUT_NAME "shape") set_target_properties(input-shape PROPERTIES SUFFIX ".input") -install(TARGETS input-shape - RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} -) +mapnik_install(TARGET input-shape IS_PLUGIN) diff --git a/plugins/input/sqlite/CMakeLists.txt b/plugins/input/sqlite/CMakeLists.txt index 7be226609c..4d1317aa55 100644 --- a/plugins/input/sqlite/CMakeLists.txt +++ b/plugins/input/sqlite/CMakeLists.txt @@ -18,6 +18,4 @@ set_target_properties(input-sqlite PROPERTIES PREFIX "") set_target_properties(input-sqlite PROPERTIES OUTPUT_NAME "sqlite") set_target_properties(input-sqlite PROPERTIES SUFFIX ".input") -install(TARGETS input-sqlite - RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} -) +mapnik_install(TARGET input-sqlite IS_PLUGIN) diff --git a/plugins/input/topojson/CMakeLists.txt b/plugins/input/topojson/CMakeLists.txt index baefe69ee2..32cfb1bd17 100644 --- a/plugins/input/topojson/CMakeLists.txt +++ b/plugins/input/topojson/CMakeLists.txt @@ -16,6 +16,4 @@ set_target_properties(input-topojson PROPERTIES PREFIX "") set_target_properties(input-topojson PROPERTIES OUTPUT_NAME "topojson") set_target_properties(input-topojson PROPERTIES SUFFIX ".input") -install(TARGETS input-topojson - RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} -) +mapnik_install(TARGET input-topojson IS_PLUGIN) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a17e9d6b06..b0a84ae5fa 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -303,3 +303,5 @@ install(TARGETS mapnik INCLUDES DESTINATION include/ PUBLIC_HEADER DESTINATION include/ ) + +mapnik_install(TARGET mapnik ALREADY_INSTALLED) diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index 183b7c745a..e3682d31e9 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -26,9 +26,4 @@ target_include_directories(json PRIVATE ) target_link_libraries(json PRIVATE mapnik::core ${ICUU_LIB}) -install(TARGETS json - EXPORT MapnikTargets - LIBRARY DESTINATION ${MAPNIK_LIB_DIR} - ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} - RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) +mapnik_install(TARGET json) diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index 35168f669b..161fd87d42 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -18,9 +18,4 @@ target_include_directories(wkt PRIVATE ) target_link_libraries(wkt PRIVATE mapnik::core) -install(TARGETS wkt - EXPORT MapnikTargets - LIBRARY DESTINATION ${MAPNIK_LIB_DIR} - ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} - RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) +mapnik_install(TARGET wkt) diff --git a/utils/geometry_to_wkb/CMakeLists.txt b/utils/geometry_to_wkb/CMakeLists.txt index 17d8e23cb1..8aca170fec 100644 --- a/utils/geometry_to_wkb/CMakeLists.txt +++ b/utils/geometry_to_wkb/CMakeLists.txt @@ -7,9 +7,4 @@ target_link_libraries(geometry_to_wkb PRIVATE mapnik::mapnik ) -install(TARGETS geometry_to_wkb - EXPORT MapnikTargets - LIBRARY DESTINATION ${MAPNIK_LIB_DIR} - ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} - RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) +mapnik_install(TARGET geometry_to_wkb) diff --git a/utils/mapnik-index/CMakeLists.txt b/utils/mapnik-index/CMakeLists.txt index 70123b379e..7a600a8b2d 100644 --- a/utils/mapnik-index/CMakeLists.txt +++ b/utils/mapnik-index/CMakeLists.txt @@ -15,9 +15,5 @@ target_link_libraries(mapnik-index PRIVATE mapnik::wkt Boost::program_options ) -install(TARGETS mapnik-index - EXPORT MapnikTargets - LIBRARY DESTINATION ${MAPNIK_LIB_DIR} - ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} - RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) + +mapnik_install(TARGET mapnik-index) diff --git a/utils/mapnik-render/CMakeLists.txt b/utils/mapnik-render/CMakeLists.txt index 0dbc73f2a4..08c6897978 100644 --- a/utils/mapnik-render/CMakeLists.txt +++ b/utils/mapnik-render/CMakeLists.txt @@ -9,9 +9,5 @@ target_link_libraries(mapnik-render PRIVATE mapnik::mapnik Boost::program_options ) -install(TARGETS mapnik-render - EXPORT MapnikTargets - LIBRARY DESTINATION ${MAPNIK_LIB_DIR} - ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} - RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) + +mapnik_install(TARGET mapnik-render) diff --git a/utils/ogrindex/CMakeLists.txt b/utils/ogrindex/CMakeLists.txt index ad9c12e41b..afc13541bf 100644 --- a/utils/ogrindex/CMakeLists.txt +++ b/utils/ogrindex/CMakeLists.txt @@ -11,3 +11,5 @@ install(TARGETS ogrindex ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) + +mapnik_install(TARGET mapnik-ogrindex) diff --git a/utils/pgsql2sqlite/CMakeLists.txt b/utils/pgsql2sqlite/CMakeLists.txt index d57046bee7..8ff6eb1f25 100644 --- a/utils/pgsql2sqlite/CMakeLists.txt +++ b/utils/pgsql2sqlite/CMakeLists.txt @@ -17,9 +17,4 @@ target_link_libraries(pgsql2sqlite PRIVATE mapnik::mapnik ) -install(TARGETS pgsql2sqlite - EXPORT MapnikTargets - LIBRARY DESTINATION ${MAPNIK_LIB_DIR} - ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} - RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) +mapnik_install(TARGET pgsql2sqlite) diff --git a/utils/shapeindex/CMakeLists.txt b/utils/shapeindex/CMakeLists.txt index 79a9f24ff5..55621cdd56 100644 --- a/utils/shapeindex/CMakeLists.txt +++ b/utils/shapeindex/CMakeLists.txt @@ -12,9 +12,5 @@ target_link_libraries(shapeindex PRIVATE mapnik::core mapnik::mapnik ) -install(TARGETS shapeindex - EXPORT MapnikTargets - LIBRARY DESTINATION ${MAPNIK_LIB_DIR} - ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} - RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) + +mapnik_install(TARGET shapeindex) diff --git a/utils/svg2png/CMakeLists.txt b/utils/svg2png/CMakeLists.txt index 6f1a52eaba..55572f3933 100644 --- a/utils/svg2png/CMakeLists.txt +++ b/utils/svg2png/CMakeLists.txt @@ -12,9 +12,5 @@ target_link_libraries(svg2png PRIVATE mapnik::mapnik mapnik::agg ) -install(TARGETS svg2png - EXPORT MapnikTargets - LIBRARY DESTINATION ${MAPNIK_LIB_DIR} - ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} - RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) + +mapnik_install(TARGET svg2png) From f0b7ff45d266ebcc8d7c4874d021292ce5e97cd0 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Apr 2021 19:41:21 +0200 Subject: [PATCH 089/141] install dependencies only on windows and install plugins into correct dir --- cmake/MapnikInstall.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/MapnikInstall.cmake b/cmake/MapnikInstall.cmake index 38b6c687d1..6f0cfd553a 100644 --- a/cmake/MapnikInstall.cmake +++ b/cmake/MapnikInstall.cmake @@ -12,6 +12,8 @@ function(mapnik_install) ) elseif(NOT ${MAPNIK_INSTALL_ALREADY_INSTALLED} AND ${MAPNIK_INSTALL_IS_PLUGIN}) install(TARGETS ${MAPNIK_INSTALL_TARGET} + LIBRARY DESTINATION ${PLUGINS_INSTALL_DIR} + ARCHIVE DESTINATION ${PLUGINS_INSTALL_DIR} RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} ) endif() @@ -32,7 +34,7 @@ endfunction() function(mapnik_install_targets) - if(INSTALL_DEPENDENCIES) + if(INSTALL_DEPENDENCIES AND WIN32) # https://cmake.org/cmake/help/latest/policy/CMP0087.html cmake_policy(SET CMP0087 NEW) get_property(MAPNIK_INSTALLED_TARGETS GLOBAL PROPERTY TARGETS) From 2cbceacda330ecdfced6ddac98ff1b8929e59591 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 30 Jun 2021 10:33:20 +0200 Subject: [PATCH 090/141] [cmake] add folders for visual studio --- .gitignore | 1 + CMakeLists.txt | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 922bdcf218..bf3bf93e05 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,4 @@ test/unit/run test/visual/run # cmake build +.vs diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cef601130..981eb75dec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,9 +11,11 @@ project(mapnik DESCRIPTION "Mapnik is an open source toolkit for developing mapping applications" LANGUAGES CXX ) - message(STATUS "mapnik version: ${PROJECT_VERSION}") +# https://cliutils.gitlab.io/modern-cmake/chapters/features/ides.html +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(MapnikFindPackage) include(MapnikCopyDependencies) From 71ff6d6ef71a6e7d95b49f722411c2226b078327 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 2 Jul 2021 13:55:55 +0200 Subject: [PATCH 091/141] install sparsehash --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 981eb75dec..f65ca53995 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,6 +337,7 @@ install(EXPORT MapnikTargets install(DIRECTORY include/ TYPE INCLUDE) install(DIRECTORY deps/agg/include/ TYPE INCLUDE) +install(DIRECTORY deps/mapnik TYPE INCLUDE) install(DIRECTORY fonts/ DESTINATION ${FONTS_INSTALL_DIR} FILES_MATCHING PATTERN "*.py" EXCLUDE PATTERN "*") mapnik_install_targets() From a651e53f6f5c44e6a2bb9380c4a633f6717587ac Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 2 Jul 2021 16:02:30 +0200 Subject: [PATCH 092/141] try install json and wkt again --- src/json/CMakeLists.txt | 9 +++++++++ src/wkt/CMakeLists.txt | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index e3682d31e9..899293562d 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -26,4 +26,13 @@ target_include_directories(json PRIVATE ) target_link_libraries(json PRIVATE mapnik::core ${ICUU_LIB}) +install(TARGETS json + EXPORT MapnikTargets + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} + INCLUDES DESTINATION include/ + PUBLIC_HEADER DESTINATION include/ +) + mapnik_install(TARGET json) diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index 161fd87d42..5f3e9d485c 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -18,4 +18,13 @@ target_include_directories(wkt PRIVATE ) target_link_libraries(wkt PRIVATE mapnik::core) +install(TARGETS wkt + EXPORT MapnikTargets + LIBRARY DESTINATION ${MAPNIK_LIB_DIR} + ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} + RUNTIME DESTINATION ${MAPNIK_BIN_DIR} + INCLUDES DESTINATION include/ + PUBLIC_HEADER DESTINATION include/ +) + mapnik_install(TARGET wkt) From da6613827d6205d0e6ab55a0b20bd763808a0d54 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 2 Jul 2021 22:26:36 +0200 Subject: [PATCH 093/141] add packaging --- CMakeLists.txt | 12 ++++++++---- cmake/pack.cmake | 14 ++++++++++++++ src/CMakeLists.txt | 1 + src/json/CMakeLists.txt | 1 + src/wkt/CMakeLists.txt | 1 + 5 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 cmake/pack.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f65ca53995..b5b6ffca95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,12 +231,12 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ REQUIRED) - math(EXPR MAPNIK_PROJ_VERSION "${PROJ_VERSION_MAJOR}*10000 + ${PROJ_VERSION_MINOR}*100 + ${PROJ_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) + mapnik_find_package(PROJ4 REQUIRED) + math(EXPR MAPNIK_PROJ_VERSION "${PROJ4_VERSION_MAJOR}*10000 + ${PROJ4_VERSION_MINOR}*100 + ${PROJ4_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 ${PROJ_INCLUDE_DIRS}) + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ4_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) @@ -289,6 +289,7 @@ install(TARGETS core RUNTIME DESTINATION ${MAPNIK_BIN_DIR} INCLUDES DESTINATION include/ PUBLIC_HEADER DESTINATION include/ + COMPONENT mapnik ) add_subdirectory(deps) @@ -341,3 +342,6 @@ install(DIRECTORY deps/mapnik TYPE INCLUDE) install(DIRECTORY fonts/ DESTINATION ${FONTS_INSTALL_DIR} FILES_MATCHING PATTERN "*.py" EXCLUDE PATTERN "*") mapnik_install_targets() + + +include(pack) diff --git a/cmake/pack.cmake b/cmake/pack.cmake new file mode 100644 index 0000000000..eb27bda41b --- /dev/null +++ b/cmake/pack.cmake @@ -0,0 +1,14 @@ +include(InstallRequiredSystemLibraries) +set(CPACK_SOURCE_GENERATOR "TGZ") +set(CPACK_GENERATOR "TGZ") +set(CPACK_SOURCE_IGNORE_FILES + \\.git/ + build/ + ".*~$" + out/ + \\.vs/ + \\.vscode/ +) +set(CPACK_VERBATIM_VARIABLES YES) + +include(CPack) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b0a84ae5fa..efb1f9b080 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -302,6 +302,7 @@ install(TARGETS mapnik RUNTIME DESTINATION ${MAPNIK_BIN_DIR} INCLUDES DESTINATION include/ PUBLIC_HEADER DESTINATION include/ + COMPONENT mapnik ) mapnik_install(TARGET mapnik ALREADY_INSTALLED) diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index 899293562d..fa5c148f1b 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -33,6 +33,7 @@ install(TARGETS json RUNTIME DESTINATION ${MAPNIK_BIN_DIR} INCLUDES DESTINATION include/ PUBLIC_HEADER DESTINATION include/ + COMPONENT mapnik ) mapnik_install(TARGET json) diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index 5f3e9d485c..2637f2a70c 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -25,6 +25,7 @@ install(TARGETS wkt RUNTIME DESTINATION ${MAPNIK_BIN_DIR} INCLUDES DESTINATION include/ PUBLIC_HEADER DESTINATION include/ + COMPONENT mapnik ) mapnik_install(TARGET wkt) From a2161e1f524ef9aea92a8afb5d74f919033fe1dd Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 2 Jul 2021 22:43:01 +0200 Subject: [PATCH 094/141] ups. this shouldn't be commited --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5b6ffca95..9ce2fb9d52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,12 +231,12 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ4 REQUIRED) - math(EXPR MAPNIK_PROJ_VERSION "${PROJ4_VERSION_MAJOR}*10000 + ${PROJ4_VERSION_MINOR}*100 + ${PROJ4_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) + mapnik_find_package(PROJ REQUIRED) + 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 ${PROJ4_LIBRARIES}) - list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) From ab90eeed2fd542c96d54594a4687792f83867a15 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Mon, 5 Jul 2021 17:13:45 +0200 Subject: [PATCH 095/141] build plugins as modules. --- CMakeLists.txt | 8 ++++---- plugins/input/csv/CMakeLists.txt | 7 +------ plugins/input/gdal/CMakeLists.txt | 2 +- plugins/input/geobuf/CMakeLists.txt | 2 +- plugins/input/geojson/CMakeLists.txt | 2 +- plugins/input/ogr/CMakeLists.txt | 2 +- plugins/input/pgraster/CMakeLists.txt | 2 +- plugins/input/postgis/CMakeLists.txt | 2 +- plugins/input/raster/CMakeLists.txt | 2 +- plugins/input/shape/CMakeLists.txt | 2 +- plugins/input/sqlite/CMakeLists.txt | 2 +- plugins/input/topojson/CMakeLists.txt | 2 +- 12 files changed, 15 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ce2fb9d52..b5b6ffca95 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,12 +231,12 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ REQUIRED) - math(EXPR MAPNIK_PROJ_VERSION "${PROJ_VERSION_MAJOR}*10000 + ${PROJ_VERSION_MINOR}*100 + ${PROJ_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) + mapnik_find_package(PROJ4 REQUIRED) + math(EXPR MAPNIK_PROJ_VERSION "${PROJ4_VERSION_MAJOR}*10000 + ${PROJ4_VERSION_MINOR}*100 + ${PROJ4_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 ${PROJ_INCLUDE_DIRS}) + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ4_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) diff --git a/plugins/input/csv/CMakeLists.txt b/plugins/input/csv/CMakeLists.txt index 3d251a5eac..ecf4edda6e 100644 --- a/plugins/input/csv/CMakeLists.txt +++ b/plugins/input/csv/CMakeLists.txt @@ -1,6 +1,6 @@ project(input-csv) -add_library(input-csv SHARED +add_library(input-csv MODULE csv_datasource.cpp csv_featureset.cpp csv_index_featureset.cpp @@ -18,10 +18,5 @@ target_link_libraries(input-csv PRIVATE set_target_properties(input-csv PROPERTIES PREFIX "") set_target_properties(input-csv PROPERTIES OUTPUT_NAME "csv") set_target_properties(input-csv PROPERTIES SUFFIX ".input") -#install(TARGETS input-csv DESTINATION bin/plugins/input) - -install(TARGETS input-csv - RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} -) mapnik_install(TARGET input-csv IS_PLUGIN) diff --git a/plugins/input/gdal/CMakeLists.txt b/plugins/input/gdal/CMakeLists.txt index 92b3057663..0bba721cc5 100644 --- a/plugins/input/gdal/CMakeLists.txt +++ b/plugins/input/gdal/CMakeLists.txt @@ -2,7 +2,7 @@ project(input-gdal) find_package(GDAL REQUIRED) -add_library(input-gdal SHARED +add_library(input-gdal MODULE gdal_datasource.cpp gdal_featureset.cpp ) diff --git a/plugins/input/geobuf/CMakeLists.txt b/plugins/input/geobuf/CMakeLists.txt index bb5fef85e4..56a027aebd 100644 --- a/plugins/input/geobuf/CMakeLists.txt +++ b/plugins/input/geobuf/CMakeLists.txt @@ -1,6 +1,6 @@ project(input-geobuf) -add_library(input-geobuf SHARED +add_library(input-geobuf MODULE geobuf_datasource.cpp geobuf_featureset.cpp ) diff --git a/plugins/input/geojson/CMakeLists.txt b/plugins/input/geojson/CMakeLists.txt index 39b392fe56..6f830e13ba 100644 --- a/plugins/input/geojson/CMakeLists.txt +++ b/plugins/input/geojson/CMakeLists.txt @@ -1,6 +1,6 @@ project(input-geojson) -add_library(input-geojson SHARED +add_library(input-geojson MODULE geojson_datasource.cpp geojson_featureset.cpp geojson_index_featureset.cpp diff --git a/plugins/input/ogr/CMakeLists.txt b/plugins/input/ogr/CMakeLists.txt index 0791c093bc..c8fd113de3 100644 --- a/plugins/input/ogr/CMakeLists.txt +++ b/plugins/input/ogr/CMakeLists.txt @@ -2,7 +2,7 @@ project(input-ogr) find_package(GDAL REQUIRED) -add_library(input-ogr SHARED +add_library(input-ogr MODULE ogr_converter.cpp ogr_datasource.cpp ogr_featureset.cpp diff --git a/plugins/input/pgraster/CMakeLists.txt b/plugins/input/pgraster/CMakeLists.txt index 146036044c..adcb6d8f6a 100644 --- a/plugins/input/pgraster/CMakeLists.txt +++ b/plugins/input/pgraster/CMakeLists.txt @@ -2,7 +2,7 @@ project(input-pgraster) find_package(PostgreSQL REQUIRED) -add_library(input-pgraster SHARED +add_library(input-pgraster MODULE pgraster_datasource.cpp pgraster_featureset.cpp pgraster_wkb_reader.cpp diff --git a/plugins/input/postgis/CMakeLists.txt b/plugins/input/postgis/CMakeLists.txt index 0102bac63d..8437868574 100644 --- a/plugins/input/postgis/CMakeLists.txt +++ b/plugins/input/postgis/CMakeLists.txt @@ -2,7 +2,7 @@ project(input-postgis) find_package(PostgreSQL REQUIRED) -add_library(input-postgis SHARED +add_library(input-postgis MODULE postgis_datasource.cpp postgis_featureset.cpp ) diff --git a/plugins/input/raster/CMakeLists.txt b/plugins/input/raster/CMakeLists.txt index 9956b6d9b8..f4e2f0ef8b 100644 --- a/plugins/input/raster/CMakeLists.txt +++ b/plugins/input/raster/CMakeLists.txt @@ -1,6 +1,6 @@ project(input-raster) -add_library(input-raster SHARED +add_library(input-raster MODULE raster_datasource.cpp raster_featureset.cpp raster_info.cpp diff --git a/plugins/input/shape/CMakeLists.txt b/plugins/input/shape/CMakeLists.txt index c0a42b460d..2c6ec6979b 100644 --- a/plugins/input/shape/CMakeLists.txt +++ b/plugins/input/shape/CMakeLists.txt @@ -1,6 +1,6 @@ project(input-shape) -add_library(input-shape SHARED +add_library(input-shape MODULE dbfile.cpp dbf_test.cpp shape_datasource.cpp diff --git a/plugins/input/sqlite/CMakeLists.txt b/plugins/input/sqlite/CMakeLists.txt index 4d1317aa55..89e693062c 100644 --- a/plugins/input/sqlite/CMakeLists.txt +++ b/plugins/input/sqlite/CMakeLists.txt @@ -2,7 +2,7 @@ project(input-sqlite) find_package(SQLite3 REQUIRED) -add_library(input-sqlite SHARED +add_library(input-sqlite MODULE sqlite_datasource.cpp sqlite_featureset.cpp ) diff --git a/plugins/input/topojson/CMakeLists.txt b/plugins/input/topojson/CMakeLists.txt index 32cfb1bd17..966d25b850 100644 --- a/plugins/input/topojson/CMakeLists.txt +++ b/plugins/input/topojson/CMakeLists.txt @@ -1,6 +1,6 @@ project(input-topojson) -add_library(input-topojson SHARED +add_library(input-topojson MODULE topojson_datasource.cpp topojson_featureset.cpp ) From 64ec0e2c56aa28aaeccf14229d61bc9947d1e3e2 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Mon, 5 Jul 2021 21:58:53 +0200 Subject: [PATCH 096/141] hate proj4... --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b5b6ffca95..9ce2fb9d52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -231,12 +231,12 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ4 REQUIRED) - math(EXPR MAPNIK_PROJ_VERSION "${PROJ4_VERSION_MAJOR}*10000 + ${PROJ4_VERSION_MINOR}*100 + ${PROJ4_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) + mapnik_find_package(PROJ REQUIRED) + 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 ${PROJ4_LIBRARIES}) - list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) From c731f424656a518068ea3c2efa14db915bf04a00 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Tue, 6 Jul 2021 21:32:36 +0200 Subject: [PATCH 097/141] add find harfbuzz.cmake --- CMakeLists.txt | 15 ++-- cmake/FindHarfBuzz.cmake | 187 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 195 insertions(+), 7 deletions(-) create mode 100644 cmake/FindHarfBuzz.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ce2fb9d52..51f7bc2499 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,13 +113,14 @@ message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}") # Begin project configuration mapnik_find_threads() mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) -mapnik_find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex) +mapnik_find_package(Boost 1.61 REQUIRED COMPONENTS filesystem system regex) if(USE_BOOST_REGEX_ICU_WORKAROUND) set_property(TARGET Boost::regex PROPERTY INTERFACE_LINK_LIBRARIES) endif() mapnik_find_package(Freetype REQUIRED) -mapnik_find_package(harfbuzz CONFIG REQUIRED) +# we use our "own" FindHarfBuzz. See https://github.com/mapnik/mapnik/pull/4191#issuecomment-874728157 for more details +mapnik_find_package(HarfBuzz REQUIRED) if(USE_EXTERNAL_MAPBOX_GEOMETRY) # this is used to provide a way to specify include dirs with CACHE VARIABLES @@ -231,12 +232,12 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ REQUIRED) - math(EXPR MAPNIK_PROJ_VERSION "${PROJ_VERSION_MAJOR}*10000 + ${PROJ_VERSION_MINOR}*100 + ${PROJ_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) + mapnik_find_package(PROJ4 REQUIRED) + math(EXPR MAPNIK_PROJ_VERSION "${PROJ4_VERSION_MAJOR}*10000 + ${PROJ4_VERSION_MINOR}*100 + ${PROJ4_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 ${PROJ_INCLUDE_DIRS}) + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ4_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) @@ -277,7 +278,7 @@ target_link_libraries(core INTERFACE Boost::regex Boost::filesystem Freetype::Freetype - harfbuzz::harfbuzz + HarfBuzz::HarfBuzz ${MAPNIK_OPTIONAL_LIBS} ) target_compile_definitions(core INTERFACE ${MAPNIK_COMPILE_DEFS}) diff --git a/cmake/FindHarfBuzz.cmake b/cmake/FindHarfBuzz.cmake new file mode 100644 index 0000000000..a0296f3212 --- /dev/null +++ b/cmake/FindHarfBuzz.cmake @@ -0,0 +1,187 @@ +# Copyright (c) 2012, Intel Corporation +# Copyright (c) 2019 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: +# +# * Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# * 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. +# * Neither the name of Intel Corporation nor the names of its contributors may +# be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 OWNER OR 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. +# +# Try to find Harfbuzz include and library directories. +# +# After successful discovery, this will set for inclusion where needed: +# HarfBuzz_INCLUDE_DIRS - containg the HarfBuzz headers +# HarfBuzz_LIBRARIES - containg the HarfBuzz library + +#[=======================================================================[.rst: +FindHarfBuzz +-------------- + +Find HarfBuzz headers and libraries. + +Imported Targets +^^^^^^^^^^^^^^^^ + +``HarfBuzz::HarfBuzz`` + The HarfBuzz library, if found. + +``HarfBuzz::ICU`` + The HarfBuzz ICU library, if found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables in your project: + +``HarfBuzz_FOUND`` + true if (the requested version of) HarfBuzz is available. +``HarfBuzz_VERSION`` + the version of HarfBuzz. +``HarfBuzz_LIBRARIES`` + the libraries to link against to use HarfBuzz. +``HarfBuzz_INCLUDE_DIRS`` + where to find the HarfBuzz headers. +``HarfBuzz_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_HARFBUZZ QUIET harfbuzz) +set(HarfBuzz_COMPILE_OPTIONS ${PC_HARFBUZZ_CFLAGS_OTHER}) +set(HarfBuzz_VERSION ${PC_HARFBUZZ_CFLAGS_VERSION}) + +find_path(HarfBuzz_INCLUDE_DIR + NAMES hb.h + HINTS ${PC_HARFBUZZ_INCLUDEDIR} ${PC_HARFBUZZ_INCLUDE_DIRS} + PATH_SUFFIXES harfbuzz +) + +find_library(HarfBuzz_LIBRARY + NAMES ${HarfBuzz_NAMES} harfbuzz + HINTS ${PC_HARFBUZZ_LIBDIR} ${PC_HARFBUZZ_LIBRARY_DIRS} +) + +if (HarfBuzz_INCLUDE_DIR AND NOT HarfBuzz_VERSION) + if (EXISTS "${HarfBuzz_INCLUDE_DIR}/hb-version.h") + file(READ "${HarfBuzz_INCLUDE_DIR}/hb-version.h" _harfbuzz_version_content) + + string(REGEX MATCH "#define +HB_VERSION_STRING +\"([0-9]+\.[0-9]+\.[0-9]+)\"" _dummy "${_harfbuzz_version_content}") + set(HarfBuzz_VERSION "${CMAKE_MATCH_1}") + endif () +endif () + +if ("${HarfBuzz_FIND_VERSION}" VERSION_GREATER "${HarfBuzz_VERSION}") + message(FATAL_ERROR "Required version (" ${HarfBuzz_FIND_VERSION} ") is higher than found version (" ${HarfBuzz_VERSION} ")") +endif () + +# Find components +if (HarfBuzz_INCLUDE_DIR AND HarfBuzz_LIBRARY) + set(_HarfBuzz_REQUIRED_LIBS_FOUND ON) + set(HarfBuzz_LIBS_FOUND "HarfBuzz (required): ${HarfBuzz_LIBRARY}") +else () + set(_HarfBuzz_REQUIRED_LIBS_FOUND OFF) + set(HarfBuzz_LIBS_NOT_FOUND "HarfBuzz (required)") +endif () + +if ("ICU" IN_LIST HarfBuzz_FIND_COMPONENTS) + pkg_check_modules(PC_HARFBUZZ_ICU QUIET harfbuzz-icu) + set(HarfBuzz_ICU_COMPILE_OPTIONS ${PC_HARFBUZZ_ICU_CFLAGS_OTHER}) + + find_path(HarfBuzz_ICU_INCLUDE_DIR + NAMES hb-icu.h + HINTS ${PC_HARFBUZZ_ICU_INCLUDEDIR} ${PC_HARFBUZZ_ICU_INCLUDE_DIRS} + PATH_SUFFIXES harfbuzz + ) + + find_library(HarfBuzz_ICU_LIBRARY + NAMES ${HarfBuzz_ICU_NAMES} harfbuzz-icu + HINTS ${PC_HARFBUZZ_ICU_LIBDIR} ${PC_HARFBUZZ_ICU_LIBRARY_DIRS} + ) + + if (HarfBuzz_ICU_LIBRARY) + if (HarfBuzz_FIND_REQUIRED_ICU) + list(APPEND HarfBuzz_LIBS_FOUND "ICU (required): ${HarfBuzz_ICU_LIBRARY}") + else () + list(APPEND HarfBuzz_LIBS_FOUND "ICU (optional): ${HarfBuzz_ICU_LIBRARY}") + endif () + else () + if (HarfBuzz_FIND_REQUIRED_ICU) + set(_HarfBuzz_REQUIRED_LIBS_FOUND OFF) + list(APPEND HarfBuzz_LIBS_NOT_FOUND "ICU (required)") + else () + list(APPEND HarfBuzz_LIBS_NOT_FOUND "ICU (optional)") + endif () + endif () +endif () + +if (NOT HarfBuzz_FIND_QUIETLY) + if (HarfBuzz_LIBS_FOUND) + message(STATUS "Found the following HarfBuzz libraries:") + foreach (found ${HarfBuzz_LIBS_FOUND}) + message(STATUS " ${found}") + endforeach () + endif () + if (HarfBuzz_LIBS_NOT_FOUND) + message(STATUS "The following HarfBuzz libraries were not found:") + foreach (found ${HarfBuzz_LIBS_NOT_FOUND}) + message(STATUS " ${found}") + endforeach () + endif () +endif () + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(HarfBuzz + FOUND_VAR HarfBuzz_FOUND + REQUIRED_VARS HarfBuzz_INCLUDE_DIR HarfBuzz_LIBRARY _HarfBuzz_REQUIRED_LIBS_FOUND + VERSION_VAR HarfBuzz_VERSION +) + +if (HarfBuzz_LIBRARY AND NOT TARGET HarfBuzz::HarfBuzz) + add_library(HarfBuzz::HarfBuzz UNKNOWN IMPORTED GLOBAL) + set_target_properties(HarfBuzz::HarfBuzz PROPERTIES + IMPORTED_LOCATION "${HarfBuzz_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${HarfBuzz_COMPILE_OPTIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_INCLUDE_DIR}" + ) +endif () + +if (HarfBuzz_ICU_LIBRARY AND NOT TARGET HarfBuzz::ICU) + add_library(HarfBuzz::ICU UNKNOWN IMPORTED GLOBAL) + set_target_properties(HarfBuzz::ICU PROPERTIES + IMPORTED_LOCATION "${HarfBuzz_ICU_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${HarfBuzz_ICU_COMPILE_OPTIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${HarfBuzz_ICU_INCLUDE_DIR}" + ) +endif () + +mark_as_advanced( + HarfBuzz_INCLUDE_DIR + HarfBuzz_ICU_INCLUDE_DIR + HarfBuzz_LIBRARY + HarfBuzz_ICU_LIBRARY +) + +if (HarfBuzz_FOUND) + set(HarfBuzz_LIBRARIES ${HarfBuzz_LIBRARY} ${HarfBuzz_ICU_LIBRARY}) + set(HarfBuzz_INCLUDE_DIRS ${HarfBuzz_INCLUDE_DIR} ${HarfBuzz_ICU_INCLUDE_DIR}) +endif () From f7f72eaec7edd8431c034eac7b00dcc8bfc71208 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Tue, 6 Jul 2021 21:32:58 +0200 Subject: [PATCH 098/141] use proj *gr* --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 51f7bc2499..04a46cd032 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,12 +232,12 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ4 REQUIRED) - math(EXPR MAPNIK_PROJ_VERSION "${PROJ4_VERSION_MAJOR}*10000 + ${PROJ4_VERSION_MINOR}*100 + ${PROJ4_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) + mapnik_find_package(PROJ REQUIRED) + 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 ${PROJ4_LIBRARIES}) - list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) From c9082eff62be7d5609786f48a321a8a6c68a3a8e Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Tue, 6 Jul 2021 22:07:29 +0200 Subject: [PATCH 099/141] remove subsequent boost require version calls. --- test/CMakeLists.txt | 2 +- utils/mapnik-index/CMakeLists.txt | 2 +- utils/mapnik-render/CMakeLists.txt | 2 +- utils/pgsql2sqlite/CMakeLists.txt | 2 +- utils/shapeindex/CMakeLists.txt | 2 +- utils/svg2png/CMakeLists.txt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f29c53cc4e..0e57e997dc 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ project(mapnik-test) -find_package(Boost 1.74 REQUIRED COMPONENTS program_options) +find_package(Boost REQUIRED COMPONENTS program_options) find_package(PostgreSQL REQUIRED) include(FetchContent) diff --git a/utils/mapnik-index/CMakeLists.txt b/utils/mapnik-index/CMakeLists.txt index 7a600a8b2d..3ec41c401a 100644 --- a/utils/mapnik-index/CMakeLists.txt +++ b/utils/mapnik-index/CMakeLists.txt @@ -1,6 +1,6 @@ project(mapnik-index) -find_package(Boost 1.74 REQUIRED COMPONENTS program_options) +find_package(Boost REQUIRED COMPONENTS program_options) add_executable(mapnik-index mapnik-index.cpp diff --git a/utils/mapnik-render/CMakeLists.txt b/utils/mapnik-render/CMakeLists.txt index 08c6897978..b98ac86303 100644 --- a/utils/mapnik-render/CMakeLists.txt +++ b/utils/mapnik-render/CMakeLists.txt @@ -1,6 +1,6 @@ project(mapnik-render) -find_package(Boost 1.74 REQUIRED COMPONENTS program_options) +find_package(Boost REQUIRED COMPONENTS program_options) add_executable(mapnik-render mapnik-render.cpp) diff --git a/utils/pgsql2sqlite/CMakeLists.txt b/utils/pgsql2sqlite/CMakeLists.txt index 8ff6eb1f25..19883f4a99 100644 --- a/utils/pgsql2sqlite/CMakeLists.txt +++ b/utils/pgsql2sqlite/CMakeLists.txt @@ -1,5 +1,5 @@ project(pgsql2sqlite) -find_package(Boost 1.74 REQUIRED COMPONENTS program_options) +find_package(Boost REQUIRED COMPONENTS program_options) find_package(SQLite3 REQUIRED) find_package(PostgreSQL REQUIRED) diff --git a/utils/shapeindex/CMakeLists.txt b/utils/shapeindex/CMakeLists.txt index 55621cdd56..4aae25bf14 100644 --- a/utils/shapeindex/CMakeLists.txt +++ b/utils/shapeindex/CMakeLists.txt @@ -1,6 +1,6 @@ project(shapeindex) -find_package(Boost 1.74 REQUIRED COMPONENTS program_options) +find_package(Boost REQUIRED COMPONENTS program_options) add_executable(shapeindex shapeindex.cpp diff --git a/utils/svg2png/CMakeLists.txt b/utils/svg2png/CMakeLists.txt index 55572f3933..51a8baecd3 100644 --- a/utils/svg2png/CMakeLists.txt +++ b/utils/svg2png/CMakeLists.txt @@ -1,6 +1,6 @@ project(svg2png) -find_package(Boost 1.74 REQUIRED COMPONENTS program_options) +find_package(Boost REQUIRED COMPONENTS program_options) add_executable(svg2png svg2png.cpp From c235f6a93d81b708accff129a49f23176acd8420 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Tue, 6 Jul 2021 22:19:28 +0200 Subject: [PATCH 100/141] add harfbuzz minimum version and HarfBuzz::ICU target. probably fixes osx --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04a46cd032..c296307507 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -120,7 +120,7 @@ endif() mapnik_find_package(Freetype REQUIRED) # we use our "own" FindHarfBuzz. See https://github.com/mapnik/mapnik/pull/4191#issuecomment-874728157 for more details -mapnik_find_package(HarfBuzz REQUIRED) +mapnik_find_package(HarfBuzz 0.9.34 REQUIRED COMPONENTS ICU) if(USE_EXTERNAL_MAPBOX_GEOMETRY) # this is used to provide a way to specify include dirs with CACHE VARIABLES @@ -279,6 +279,7 @@ target_link_libraries(core INTERFACE Boost::filesystem Freetype::Freetype HarfBuzz::HarfBuzz + HarfBuzz::ICU ${MAPNIK_OPTIONAL_LIBS} ) target_compile_definitions(core INTERFACE ${MAPNIK_COMPILE_DEFS}) From c60691e05af27ce8ccd1faacc81e5ddaecb2840f Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Tue, 6 Jul 2021 22:46:07 +0200 Subject: [PATCH 101/141] add harfbuzz fallback --- CMakeLists.txt | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c296307507..1d2a07d989 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,6 +109,9 @@ message(STATUS "Installing plugins to ${PLUGINS_INSTALL_DIR}") set(FONTS_INSTALL_DIR ${MAPNIK_BIN_DIR}/fonts CACHE STRING "installs the fonts in the specified directory") message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}") +set(MAPNIK_COMPILE_DEFS "") +set(MAPNIK_OPTIONAL_LIBS "") +set(MAPNIK_OPTIONAL_LIBS_INCLUDE "") # Begin project configuration mapnik_find_threads() @@ -119,8 +122,19 @@ if(USE_BOOST_REGEX_ICU_WORKAROUND) endif() mapnik_find_package(Freetype REQUIRED) -# we use our "own" FindHarfBuzz. See https://github.com/mapnik/mapnik/pull/4191#issuecomment-874728157 for more details -mapnik_find_package(HarfBuzz 0.9.34 REQUIRED COMPONENTS ICU) + +# try to find harfbuzz with the native configuration and fallback to our "own" FindHarfBuzz +set(HARFBUZZ_MINIMUM_VERSION 0.9.34) +mapnik_find_package(harfbuzz CONFIG QUIET) +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") + mapnik_find_package(HarfBuzz ${HARFBUZZ_MINIMUM_VERSION} REQUIRED COMPONENTS ICU) + list(APPEND MAPNIK_OPTIONAL_LIBS HarfBuzz::HarfBuzz HarfBuzz::ICU) +endif() if(USE_EXTERNAL_MAPBOX_GEOMETRY) # this is used to provide a way to specify include dirs with CACHE VARIABLES @@ -179,9 +193,6 @@ 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 "") -set(MAPNIK_OPTIONAL_LIBS_INCLUDE "") # (used by MapnikInstall.cmake. properties are needed since "set(...)" will be out of scope set_property(GLOBAL PROPERTY TARGETS "") set_property(GLOBAL PROPERTY PLUGINS "") @@ -278,8 +289,6 @@ target_link_libraries(core INTERFACE Boost::regex Boost::filesystem Freetype::Freetype - HarfBuzz::HarfBuzz - HarfBuzz::ICU ${MAPNIK_OPTIONAL_LIBS} ) target_compile_definitions(core INTERFACE ${MAPNIK_COMPILE_DEFS}) From 3e7f8d2097adb504d1c16ba7619f087aea50e9b7 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 7 Jul 2021 21:06:59 +0200 Subject: [PATCH 102/141] TEMP: use openjpeg --- CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d2a07d989..31822e07c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,9 +218,9 @@ if(USE_PNG) endif() if(USE_JPEG) - mapnik_find_package(JPEG REQUIRED) + mapnik_find_package(OpenJPEG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG) - list(APPEND MAPNIK_OPTIONAL_LIBS JPEG::JPEG) + list(APPEND MAPNIK_OPTIONAL_LIBS openjp2) endif() if(USE_TIFF) @@ -243,12 +243,12 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ REQUIRED) - math(EXPR MAPNIK_PROJ_VERSION "${PROJ_VERSION_MAJOR}*10000 + ${PROJ_VERSION_MINOR}*100 + ${PROJ_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) + mapnik_find_package(PROJ4 REQUIRED) + math(EXPR MAPNIK_PROJ_VERSION "${PROJ4_VERSION_MAJOR}*10000 + ${PROJ4_VERSION_MINOR}*100 + ${PROJ4_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 ${PROJ_INCLUDE_DIRS}) + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ4_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) From 5de51afc3dcf346581b4d2402cd1d64ca9c7cc38 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 7 Jul 2021 21:11:28 +0200 Subject: [PATCH 103/141] still forget proj everytime... --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 31822e07c1..23584bc8f7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -243,12 +243,12 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ4 REQUIRED) - math(EXPR MAPNIK_PROJ_VERSION "${PROJ4_VERSION_MAJOR}*10000 + ${PROJ4_VERSION_MINOR}*100 + ${PROJ4_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) + mapnik_find_package(PROJ REQUIRED) + 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 ${PROJ4_LIBRARIES}) - list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) From 7893702ed027e0dac64bf7395c466c54565263d5 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 21 Jul 2021 18:16:48 +0200 Subject: [PATCH 104/141] fix some bugs when using ubuntu to build --- CMakeLists.txt | 27 +++++-- cmake/FindWebP.cmake | 166 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 189 insertions(+), 4 deletions(-) create mode 100644 cmake/FindWebP.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 23584bc8f7..4588a41526 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,10 @@ option(USE_EXTERNAL_MAPBOX_POLYLABEL "Use a external mapnik/polylabel. If off, u 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_OPENJPEG "adds openjpeg support" ON) +if(USE_JPEG AND USE_OPENJPEG) + message(FATAL_ERROR "Choose either USE_JPEG OR USE_OPENJPEG") +endif() option(USE_PNG "adds png support" ON) option(USE_TIFF "adds tiff support" ON) option(USE_WEBP "adds webp support" ON) @@ -114,6 +118,7 @@ set(MAPNIK_OPTIONAL_LIBS "") set(MAPNIK_OPTIONAL_LIBS_INCLUDE "") # Begin project configuration +mapnik_find_package(PkgConfig REQUIRED) mapnik_find_threads() mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) mapnik_find_package(Boost 1.61 REQUIRED COMPONENTS filesystem system regex) @@ -217,11 +222,16 @@ if(USE_PNG) list(APPEND MAPNIK_OPTIONAL_LIBS PNG::PNG) endif() -if(USE_JPEG) +if(USE_OPENJPEG) mapnik_find_package(OpenJPEG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG) list(APPEND MAPNIK_OPTIONAL_LIBS openjp2) endif() +if(USE_JPEG) + mapnik_find_package(JPEG REQUIRED) + list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG) + list(APPEND MAPNIK_OPTIONAL_LIBS JPEG::JPEG) +endif() if(USE_TIFF) mapnik_find_package(TIFF REQUIRED) @@ -230,9 +240,9 @@ if(USE_TIFF) endif() if(USE_WEBP) - mapnik_find_package(WebP CONFIG REQUIRED) + mapnik_find_package(WebP REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP) - list(APPEND MAPNIK_OPTIONAL_LIBS WebP::webp) + list(APPEND MAPNIK_OPTIONAL_LIBS WebP::libwebp) endif() if(USE_CAIRO) @@ -243,7 +253,16 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ REQUIRED) + mapnik_find_package(PROJ QUIET) + # currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config + if(NOT PROJ_FOUND) + message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...") + pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj) + 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() 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}) diff --git a/cmake/FindWebP.cmake b/cmake/FindWebP.cmake new file mode 100644 index 0000000000..c93e78cebe --- /dev/null +++ b/cmake/FindWebP.cmake @@ -0,0 +1,166 @@ +# Copyright (C) 2020 Sony Interactive Entertainment Inc. +# Copyright (C) 2012 Raphael Kubo da Costa +# Copyright (C) 2013 Igalia S.L. +# +# 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: +FindWebP +-------------- + +Find WebP headers and libraries. + +Imported Targets +^^^^^^^^^^^^^^^^ + +``WebP::libwebp`` + The WebP library, if found. + +``WebP::demux`` + The WebP demux library, if found. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables in your project: + +``WebP_FOUND`` + true if (the requested version of) WebP is available. +``WebP_VERSION`` + the version of WebP. +``WebP_LIBRARIES`` + the libraries to link against to use WebP. +``WebP_INCLUDE_DIRS`` + where to find the WebP headers. +``WebP_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_WEBP QUIET libwebp) +set(WebP_COMPILE_OPTIONS ${PC_WEBP_CFLAGS_OTHER}) +set(WebP_VERSION ${PC_WEBP_CFLAGS_VERSION}) + +find_path(WebP_INCLUDE_DIR + NAMES webp/decode.h + HINTS ${PC_WEBP_INCLUDEDIR} ${PC_WEBP_INCLUDE_DIRS} +) + +find_library(WebP_LIBRARY + NAMES ${WebP_NAMES} webp + HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS} +) + +# There's nothing in the WebP headers that could be used to detect the exact +# WebP version being used so don't attempt to do so. A version can only be found +# through pkg-config +if ("${WebP_FIND_VERSION}" VERSION_GREATER "${WebP_VERSION}") + if (WebP_VERSION) + message(FATAL_ERROR "Required version (" ${WebP_FIND_VERSION} ") is higher than found version (" ${WebP_VERSION} ")") + else () + message(WARNING "Cannot determine WebP version without pkg-config") + endif () +endif () + +# Find components +if (WebP_INCLUDE_DIR AND WebP_LIBRARY) + set(_WebP_REQUIRED_LIBS_FOUND ON) + set(WebP_LIBS_FOUND "WebP (required): ${WebP_LIBRARY}") +else () + set(_WebP_REQUIRED_LIBS_FOUND OFF) + set(WebP_LIBS_NOT_FOUND "WebP (required)") +endif () + +if ("demux" IN_LIST WebP_FIND_COMPONENTS) + find_library(WebP_DEMUX_LIBRARY + NAMES ${WebP_DEMUX_NAMES} webpdemux + HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS} + ) + + if (WebP_DEMUX_LIBRARY) + if (WebP_FIND_REQUIRED_demux) + list(APPEND WebP_LIBS_FOUND "demux (required): ${WebP_DEMUX_LIBRARY}") + else () + list(APPEND WebP_LIBS_FOUND "demux (optional): ${WebP_DEMUX_LIBRARY}") + endif () + else () + if (WebP_FIND_REQUIRED_demux) + set(_WebP_REQUIRED_LIBS_FOUND OFF) + list(APPEND WebP_LIBS_NOT_FOUND "demux (required)") + else () + list(APPEND WebP_LIBS_NOT_FOUND "demux (optional)") + endif () + endif () +endif () + +if (NOT WebP_FIND_QUIETLY) + if (WebP_LIBS_FOUND) + message(STATUS "Found the following WebP libraries:") + foreach (found ${WebP_LIBS_FOUND}) + message(STATUS " ${found}") + endforeach () + endif () + if (WebP_LIBS_NOT_FOUND) + message(STATUS "The following WebP libraries were not found:") + foreach (found ${WebP_LIBS_NOT_FOUND}) + message(STATUS " ${found}") + endforeach () + endif () +endif () + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(WebP + FOUND_VAR WebP_FOUND + REQUIRED_VARS WebP_INCLUDE_DIR WebP_LIBRARY _WebP_REQUIRED_LIBS_FOUND + VERSION_VAR WebP_VERSION +) + +if (WebP_LIBRARY AND NOT TARGET WebP::libwebp) + add_library(WebP::libwebp UNKNOWN IMPORTED GLOBAL) + set_target_properties(WebP::libwebp PROPERTIES + IMPORTED_LOCATION "${WebP_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${WebP_COMPILE_OPTIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR}" + ) +endif () + +if (WebP_DEMUX_LIBRARY AND NOT TARGET WebP::demux) + add_library(WebP::demux UNKNOWN IMPORTED GLOBAL) + set_target_properties(WebP::demux PROPERTIES + IMPORTED_LOCATION "${WebP_DEMUX_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${WebP_COMPILE_OPTIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR}" + ) +endif () + +mark_as_advanced( + WebP_INCLUDE_DIR + WebP_LIBRARY + WebP_DEMUX_LIBRARY +) + +if (WebP_FOUND) + set(WebP_LIBRARIES ${WebP_LIBRARY} ${WebP_DEMUX_LIBRARY}) + set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR}) +endif () From 9bac37bcae112ed51c19baa767c865c3d7cc2b4d Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 21 Jul 2021 18:24:40 +0200 Subject: [PATCH 105/141] default to jpeg. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4588a41526..fd1d463e7d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ option(USE_EXTERNAL_MAPBOX_POLYLABEL "Use a external mapnik/polylabel. If off, u 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_OPENJPEG "adds openjpeg support" ON) +option(USE_OPENJPEG "adds openjpeg support" OFF) if(USE_JPEG AND USE_OPENJPEG) message(FATAL_ERROR "Choose either USE_JPEG OR USE_OPENJPEG") endif() From 276e6aa3171e50cd9229b01d3e42d78370cd4239 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 21 Jul 2021 20:03:42 +0200 Subject: [PATCH 106/141] fix config file naming scheme. Only happens when using older cmake versions. But this was definitly an issue. Target name should be the same on the file (case sensitive) --- CMakeLists.txt | 26 ++++++++++++------- ...kConfig.cmake.in => mapnikConfig.cmake.in} | 2 +- docs/cmake-usage.md | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) rename cmake/{MapnikConfig.cmake.in => mapnikConfig.cmake.in} (88%) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd1d463e7d..db78d5357d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,27 +341,35 @@ include(CMakePackageConfigHelpers) # set the cmake targets install location set(INCLUDE_INSTALL_DIR include/) write_basic_package_version_file( - "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfigVersion.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake" VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion ) list(JOIN MAPNIK_DEPENDENCIES "\n" MAPNIK_DEPENDENCIES) -configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/MapnikConfig.cmake.in - "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfig.cmake" +configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/mapnikConfig.cmake.in + "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake" INSTALL_DESTINATION ${INSTALL_CMAKE_DIR} PATH_VARS INCLUDE_INSTALL_DIR PLUGINS_INSTALL_DIR FONTS_INSTALL_DIR MAPNIK_DEPENDENCIES ) -install(FILES - "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfig.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/MapnikConfigVersion.cmake" - DESTINATION ${INSTALL_CMAKE_DIR} +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/mapnikConfigVersion.cmake" + DESTINATION ${INSTALL_CMAKE_DIR} +) + +install( + FILES + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindCairo.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindWebP.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindHarfBuzz.cmake" + DESTINATION ${INSTALL_CMAKE_DIR}/Modules ) -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindCairo.cmake" DESTINATION ${INSTALL_CMAKE_DIR}/Modules) install(EXPORT MapnikTargets - FILE MapnikTargets.cmake + FILE mapnikTargets.cmake NAMESPACE mapnik:: DESTINATION ${INSTALL_CMAKE_DIR} ) diff --git a/cmake/MapnikConfig.cmake.in b/cmake/mapnikConfig.cmake.in similarity index 88% rename from cmake/MapnikConfig.cmake.in rename to cmake/mapnikConfig.cmake.in index 74071d4932..8e724e9ffc 100644 --- a/cmake/MapnikConfig.cmake.in +++ b/cmake/mapnikConfig.cmake.in @@ -10,6 +10,6 @@ include(CMakeFindDependencyMacro) @MAPNIK_DEPENDENCIES@ -include("${CMAKE_CURRENT_LIST_DIR}/MapnikTargets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/mapnikTargets.cmake") check_required_components(mapnik) diff --git a/docs/cmake-usage.md b/docs/cmake-usage.md index 57de8f5077..e62402c682 100644 --- a/docs/cmake-usage.md +++ b/docs/cmake-usage.md @@ -28,7 +28,7 @@ find_package(mapnik CONFIG REQUIRED) target_link_libraries(mytarget ... mapnik::core mapnik::mapnik) ``` -All mapnik executables and targets are exported within `MapnikTargets.cmake`. +All mapnik executables and targets are exported within `mapnikTargets.cmake`. The plugin dir is available in the variable `MAPNIK_PLUGINS_DIR`. The font path is is available in the variable `MAPNIK_FONTS_DIR`. From ecb27e3b4fcba02e534da8213767737376b2fb0a Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 21 Jul 2021 20:08:22 +0200 Subject: [PATCH 107/141] this fixes a bug when including a package via pkg-config: We will append the call to the config file to find the package via find_package. However this does not work when the package was included with pkg-config --- cmake/MapnikFindPackage.cmake | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmake/MapnikFindPackage.cmake b/cmake/MapnikFindPackage.cmake index a4a10ba7dd..8bcd962168 100644 --- a/cmake/MapnikFindPackage.cmake +++ b/cmake/MapnikFindPackage.cmake @@ -16,10 +16,14 @@ endmacro() macro(mapnik_find_package) find_package(${ARGN}) - set(MAPNIK_TMP_DEP ${ARGN}) - list(JOIN MAPNIK_TMP_DEP " " MAPNIK_TMP_DEP) - list(APPEND MAPNIK_DEPENDENCIES "find_dependency(${MAPNIK_TMP_DEP})") - mapnik_print_version(${ARGV0}) + if(${ARGV0}_FOUND) + set(MAPNIK_TMP_DEP ${ARGN}) + list(JOIN MAPNIK_TMP_DEP " " MAPNIK_TMP_DEP) + list(APPEND MAPNIK_DEPENDENCIES "find_dependency(${MAPNIK_TMP_DEP})") + mapnik_print_version(${ARGV0}) + else() + message(STATUS "not found: ${ARGV0}") + endif() endmacro() macro(mapnik_find_threads) From 7ae2970e87a0967fb072637377f9e080ecb3de95 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 21 Jul 2021 20:20:44 +0200 Subject: [PATCH 108/141] install mapbox headers when using NOT USE_EXTERNAL* --- CMakeLists.txt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db78d5357d..c8b4e3effa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,7 @@ if(USE_EXTERNAL_MAPBOX_GEOMETRY) else() set(MAPBOX_GEOMETRY_INCLUDE_DIRS $ + $ ) endif() if(NOT MAPBOX_GEOMETRY_INCLUDE_DIRS) @@ -164,6 +165,7 @@ if(USE_EXTERNAL_MAPBOX_POLYLABEL) else() set(MAPBOX_POLYLABEL_INCLUDE_DIRS $ + $ ) endif() if(NOT MAPBOX_POLYLABEL_INCLUDE_DIRS) @@ -178,6 +180,7 @@ if(USE_EXTERNAL_MAPBOX_PROTOZERO) else() set(MAPBOX_PROTOZERO_INCLUDE_DIRS $ + $ ) endif() if(NOT MAPBOX_PROTOZERO_INCLUDE_DIRS) @@ -192,6 +195,7 @@ if(USE_EXTERNAL_MAPBOX_VARIANT) else() set(MAPBOX_VARIANT_INCLUDE_DIRS $ + $ ) endif() if(NOT MAPBOX_VARIANT_INCLUDE_DIRS) @@ -379,7 +383,19 @@ install(DIRECTORY deps/agg/include/ TYPE INCLUDE) install(DIRECTORY deps/mapnik TYPE INCLUDE) install(DIRECTORY fonts/ DESTINATION ${FONTS_INSTALL_DIR} FILES_MATCHING PATTERN "*.py" EXCLUDE PATTERN "*") -mapnik_install_targets() +if(NOT USE_EXTERNAL_MAPBOX_GEOMETRY) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/geometry/include/ TYPE INCLUDE) +endif() +if(NOT USE_EXTERNAL_MAPBOX_POLYLABEL) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/polylabel/include/ TYPE INCLUDE) +endif() +if(NOT USE_EXTERNAL_MAPBOX_PROTOZERO) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/protozero/include/ TYPE INCLUDE) +endif() +if(NOT USE_EXTERNAL_MAPBOX_VARIANT) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/deps/mapbox/variant/include/ TYPE INCLUDE) +endif() +mapnik_install_targets() include(pack) From 38decb013257e87ad3684ef6fc2c6949ea2c2f83 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 20:17:03 +0200 Subject: [PATCH 109/141] fix gdal library variable --- plugins/input/gdal/CMakeLists.txt | 2 +- plugins/input/ogr/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/input/gdal/CMakeLists.txt b/plugins/input/gdal/CMakeLists.txt index 0bba721cc5..952485f6c3 100644 --- a/plugins/input/gdal/CMakeLists.txt +++ b/plugins/input/gdal/CMakeLists.txt @@ -12,7 +12,7 @@ target_include_directories(input-gdal PRIVATE ${GDAL_INCLUDE_DIR}) target_link_libraries(input-gdal PRIVATE mapnik::core mapnik::mapnik - ${GDAL_LIBRARY} + ${GDAL_LIBRARIES} ) set_target_properties(input-gdal PROPERTIES PREFIX "") set_target_properties(input-gdal PROPERTIES OUTPUT_NAME "gdal") diff --git a/plugins/input/ogr/CMakeLists.txt b/plugins/input/ogr/CMakeLists.txt index c8fd113de3..577a133dd2 100644 --- a/plugins/input/ogr/CMakeLists.txt +++ b/plugins/input/ogr/CMakeLists.txt @@ -14,7 +14,7 @@ target_include_directories(input-ogr PRIVATE ${GDAL_INCLUDE_DIR}) target_link_libraries(input-ogr PRIVATE mapnik::core mapnik::mapnik - ${GDAL_LIBRARY} + ${GDAL_LIBRARIES} ) set_target_properties(input-ogr PROPERTIES PREFIX "") set_target_properties(input-ogr PROPERTIES OUTPUT_NAME "ogr") From 6f5173ff6e07cd9819a222344f015e141b40c101 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 20:34:08 +0200 Subject: [PATCH 110/141] add debug postfix to wkt, json and mapnik. Mapnik can be installed with multi configuration enviroment --- CMakeLists.txt | 4 ++++ src/CMakeLists.txt | 2 ++ src/json/CMakeLists.txt | 7 +++++-- src/wkt/CMakeLists.txt | 7 +++++-- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8b4e3effa..11a6da2615 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,10 @@ 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 +# add debug postfix to the libraries +set(MAPNIK_DEBUG_POSTFIX "d" CACHE STRING "sets the debug library postfix on mapnik, wkt and json") +message(STATUS "added postfix for debug libraries: ${MAPNIK_DEBUG_POSTFIX}") + if(WIN32) set(DEFAULT_BIN_DIR bin) set(DEFAULT_LIB_DIR lib) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index efb1f9b080..b65d12ed21 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -295,6 +295,8 @@ target_link_libraries(mapnik PRIVATE mapnik::agg ) +set_target_properties(mapnik PROPERTIES DEBUG_POSTFIX ${MAPNIK_DEBUG_POSTFIX}) + install(TARGETS mapnik EXPORT MapnikTargets LIBRARY DESTINATION ${MAPNIK_LIB_DIR} diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index fa5c148f1b..2ced71b33b 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -15,8 +15,6 @@ add_library(json STATIC ) add_library(mapnik::json ALIAS json) -set_property(TARGET json PROPERTY POSITION_INDEPENDENT_CODE ON) - target_include_directories(json PRIVATE ${JPEG_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} @@ -26,6 +24,11 @@ target_include_directories(json PRIVATE ) target_link_libraries(json PRIVATE mapnik::core ${ICUU_LIB}) +set_target_properties(json PROPERTIES + DEBUG_POSTFIX ${MAPNIK_DEBUG_POSTFIX} + POSITION_INDEPENDENT_CODE ON +) + install(TARGETS json EXPORT MapnikTargets LIBRARY DESTINATION ${MAPNIK_LIB_DIR} diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index 2637f2a70c..da9c6d94bc 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -6,8 +6,6 @@ add_library(wkt STATIC ) add_library(mapnik::wkt ALIAS wkt) -set_property(TARGET wkt PROPERTY POSITION_INDEPENDENT_CODE ON) - target_include_directories(wkt PRIVATE ${MAPNIK_INCLUDE_PATH} ${JPEG_INCLUDE_DIR} @@ -18,6 +16,11 @@ target_include_directories(wkt PRIVATE ) target_link_libraries(wkt PRIVATE mapnik::core) +set_target_properties(wkt PROPERTIES + DEBUG_POSTFIX ${MAPNIK_DEBUG_POSTFIX} + POSITION_INDEPENDENT_CODE ON +) + install(TARGETS wkt EXPORT MapnikTargets LIBRARY DESTINATION ${MAPNIK_LIB_DIR} From c0efde2a9a090c6f63764aa6c5e02b80a0fa29cb Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 20:44:29 +0200 Subject: [PATCH 111/141] remove openjpeg again. was just a test. --- CMakeLists.txt | 11 ++--------- demo/c++/CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11a6da2615..54dda37ed1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,10 +33,6 @@ option(USE_EXTERNAL_MAPBOX_POLYLABEL "Use a external mapnik/polylabel. If off, u 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_OPENJPEG "adds openjpeg support" OFF) -if(USE_JPEG AND USE_OPENJPEG) - message(FATAL_ERROR "Choose either USE_JPEG OR USE_OPENJPEG") -endif() option(USE_PNG "adds png support" ON) option(USE_TIFF "adds tiff support" ON) option(USE_WEBP "adds webp support" ON) @@ -214,6 +210,7 @@ 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) @@ -224,17 +221,13 @@ if(USE_LIBXML2) list(APPEND MAPNIK_COMPILE_DEFS HAVE_LIBXML2) list(APPEND MAPNIK_OPTIONAL_LIBS LibXml2::LibXml2) endif() + if(USE_PNG) mapnik_find_package(PNG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_PNG) list(APPEND MAPNIK_OPTIONAL_LIBS PNG::PNG) endif() -if(USE_OPENJPEG) - mapnik_find_package(OpenJPEG REQUIRED) - list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG) - list(APPEND MAPNIK_OPTIONAL_LIBS openjp2) -endif() if(USE_JPEG) mapnik_find_package(JPEG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG) diff --git a/demo/c++/CMakeLists.txt b/demo/c++/CMakeLists.txt index 7b86d37f20..1ac290b6d0 100644 --- a/demo/c++/CMakeLists.txt +++ b/demo/c++/CMakeLists.txt @@ -5,6 +5,6 @@ add_executable(mapnik-demo rundemo.cpp) target_link_libraries(mapnik-demo PRIVATE mapnik::core mapnik::agg mapnik::mapnik) mapnik_install(TARGET mapnik-demo) -mapnik_copy_plugins(TARGET mapnik-demo DESTINATION plugins/input PLUGINS input-shape) +mapnik_copy_plugins(TARGET mapnik-demo DESTINATION plugins/input PLUGINS input-shape input-gdal) mapnik_require_fonts(TARGET mapnik-demo DESTINATION fonts) mapnik_copy_dependencies(TARGETS mapnik-demo PLUGINS input-shape) From 0f043a2bfe9f7b489e3f36c9c70579d483a33b0e Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 20:44:36 +0200 Subject: [PATCH 112/141] Revert "remove openjpeg again. was just a test." This reverts commit bcc66a739c2b5ce4becd559e0fc6dc5d4c0b2db4. --- CMakeLists.txt | 11 +++++++++-- demo/c++/CMakeLists.txt | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54dda37ed1..11a6da2615 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,10 @@ option(USE_EXTERNAL_MAPBOX_POLYLABEL "Use a external mapnik/polylabel. If off, u 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_OPENJPEG "adds openjpeg support" OFF) +if(USE_JPEG AND USE_OPENJPEG) + message(FATAL_ERROR "Choose either USE_JPEG OR USE_OPENJPEG") +endif() option(USE_PNG "adds png support" ON) option(USE_TIFF "adds tiff support" ON) option(USE_WEBP "adds webp support" ON) @@ -210,7 +214,6 @@ 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) @@ -221,13 +224,17 @@ if(USE_LIBXML2) list(APPEND MAPNIK_COMPILE_DEFS HAVE_LIBXML2) list(APPEND MAPNIK_OPTIONAL_LIBS LibXml2::LibXml2) endif() - if(USE_PNG) mapnik_find_package(PNG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_PNG) list(APPEND MAPNIK_OPTIONAL_LIBS PNG::PNG) endif() +if(USE_OPENJPEG) + mapnik_find_package(OpenJPEG REQUIRED) + list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG) + list(APPEND MAPNIK_OPTIONAL_LIBS openjp2) +endif() if(USE_JPEG) mapnik_find_package(JPEG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG) diff --git a/demo/c++/CMakeLists.txt b/demo/c++/CMakeLists.txt index 1ac290b6d0..7b86d37f20 100644 --- a/demo/c++/CMakeLists.txt +++ b/demo/c++/CMakeLists.txt @@ -5,6 +5,6 @@ add_executable(mapnik-demo rundemo.cpp) target_link_libraries(mapnik-demo PRIVATE mapnik::core mapnik::agg mapnik::mapnik) mapnik_install(TARGET mapnik-demo) -mapnik_copy_plugins(TARGET mapnik-demo DESTINATION plugins/input PLUGINS input-shape input-gdal) +mapnik_copy_plugins(TARGET mapnik-demo DESTINATION plugins/input PLUGINS input-shape) mapnik_require_fonts(TARGET mapnik-demo DESTINATION fonts) mapnik_copy_dependencies(TARGETS mapnik-demo PLUGINS input-shape) From 43e2473461c5044f9bf384f9710c3ab956a5777a Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 20:45:16 +0200 Subject: [PATCH 113/141] remove openjpeg again. was just a test --- CMakeLists.txt | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11a6da2615..54dda37ed1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,10 +33,6 @@ option(USE_EXTERNAL_MAPBOX_POLYLABEL "Use a external mapnik/polylabel. If off, u 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_OPENJPEG "adds openjpeg support" OFF) -if(USE_JPEG AND USE_OPENJPEG) - message(FATAL_ERROR "Choose either USE_JPEG OR USE_OPENJPEG") -endif() option(USE_PNG "adds png support" ON) option(USE_TIFF "adds tiff support" ON) option(USE_WEBP "adds webp support" ON) @@ -214,6 +210,7 @@ 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) @@ -224,17 +221,13 @@ if(USE_LIBXML2) list(APPEND MAPNIK_COMPILE_DEFS HAVE_LIBXML2) list(APPEND MAPNIK_OPTIONAL_LIBS LibXml2::LibXml2) endif() + if(USE_PNG) mapnik_find_package(PNG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_PNG) list(APPEND MAPNIK_OPTIONAL_LIBS PNG::PNG) endif() -if(USE_OPENJPEG) - mapnik_find_package(OpenJPEG REQUIRED) - list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG) - list(APPEND MAPNIK_OPTIONAL_LIBS openjp2) -endif() if(USE_JPEG) mapnik_find_package(JPEG REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_JPEG) From ba4492289b66b49a168cbdb0da0c1e118c262f0a Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 21:04:45 +0200 Subject: [PATCH 114/141] make pkg-config optionally. But fail later when we actually need pkg-config as a fallback --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54dda37ed1..35479ad2a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,7 +118,7 @@ set(MAPNIK_OPTIONAL_LIBS "") set(MAPNIK_OPTIONAL_LIBS_INCLUDE "") # Begin project configuration -mapnik_find_package(PkgConfig REQUIRED) +mapnik_find_package(PkgConfig) mapnik_find_threads() mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) mapnik_find_package(Boost 1.61 REQUIRED COMPONENTS filesystem system regex) From 8db1aa379f88647755d66b6fa4a49e8dc9d49edb Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 21:35:12 +0200 Subject: [PATCH 115/141] fix library name --- src/CMakeLists.txt | 5 ++++- src/json/CMakeLists.txt | 1 + src/wkt/CMakeLists.txt | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b65d12ed21..5de2a86e6b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -295,7 +295,10 @@ target_link_libraries(mapnik PRIVATE mapnik::agg ) -set_target_properties(mapnik PROPERTIES DEBUG_POSTFIX ${MAPNIK_DEBUG_POSTFIX}) +set_target_properties(mapnik PROPERTIES + DEBUG_POSTFIX ${MAPNIK_DEBUG_POSTFIX} + PREFIX "lib" +) install(TARGETS mapnik EXPORT MapnikTargets diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index 2ced71b33b..93f0baad72 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -27,6 +27,7 @@ target_link_libraries(json PRIVATE mapnik::core ${ICUU_LIB}) set_target_properties(json PROPERTIES DEBUG_POSTFIX ${MAPNIK_DEBUG_POSTFIX} POSITION_INDEPENDENT_CODE ON + PREFIX "libmapnik-" ) install(TARGETS json diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index da9c6d94bc..7ef2255fa2 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -19,6 +19,7 @@ target_link_libraries(wkt PRIVATE mapnik::core) set_target_properties(wkt PROPERTIES DEBUG_POSTFIX ${MAPNIK_DEBUG_POSTFIX} POSITION_INDEPENDENT_CODE ON + PREFIX "libmapnik-" ) install(TARGETS wkt From b08f805cda96f3501a5e7b7d181ee9dd9e5b595c Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 21:45:25 +0200 Subject: [PATCH 116/141] add multithreaded --- CMakeLists.txt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 35479ad2a2..456dc4be94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,7 @@ 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_PLUGIN_INPUT_CSV "adds plugin input csv" ON) option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON) @@ -81,7 +82,7 @@ set(CXX_STANDARD_REQUIRED ON) # require the specified CMAKE_CXX_STANDARD # add debug postfix to the libraries set(MAPNIK_DEBUG_POSTFIX "d" CACHE STRING "sets the debug library postfix on mapnik, wkt and json") -message(STATUS "added postfix for debug libraries: ${MAPNIK_DEBUG_POSTFIX}") +message(STATUS "postfix for debug libraries: ${MAPNIK_DEBUG_POSTFIX}") if(WIN32) set(DEFAULT_BIN_DIR bin) @@ -118,7 +119,18 @@ set(MAPNIK_OPTIONAL_LIBS "") set(MAPNIK_OPTIONAL_LIBS_INCLUDE "") # Begin project configuration -mapnik_find_package(PkgConfig) + +# 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 1.61 REQUIRED COMPONENTS filesystem system regex) From 88e28e94cd01edf05821cdc70c5d2554b2e8bd30 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 21:55:01 +0200 Subject: [PATCH 117/141] added some docs --- docs/cmake-usage.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/cmake-usage.md b/docs/cmake-usage.md index e62402c682..c1dc5b6475 100644 --- a/docs/cmake-usage.md +++ b/docs/cmake-usage.md @@ -32,3 +32,8 @@ All mapnik executables and targets are exported within `mapnikTargets.cmake`. The plugin dir is available in the variable `MAPNIK_PLUGINS_DIR`. The font path is is available in the variable `MAPNIK_FONTS_DIR`. + +## Recommendations + +If you target a specific platform, it is recommended to create a toolchain file and set all the options and library path that you would normally set via cmd line options. +If you are using a recent cmake version (>=3.19?), it is recommended to use a CMakePreset instead. https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html From 0d353395f101ecef2e8575ebfd27dbdec80568cf Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 22:06:01 +0200 Subject: [PATCH 118/141] fix gdal include dir --- plugins/input/gdal/CMakeLists.txt | 2 +- plugins/input/ogr/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/input/gdal/CMakeLists.txt b/plugins/input/gdal/CMakeLists.txt index 952485f6c3..ca0cb4d6f6 100644 --- a/plugins/input/gdal/CMakeLists.txt +++ b/plugins/input/gdal/CMakeLists.txt @@ -8,7 +8,7 @@ add_library(input-gdal MODULE ) add_library(mapnik::plugin::input::gdal ALIAS input-gdal) -target_include_directories(input-gdal PRIVATE ${GDAL_INCLUDE_DIR}) +target_include_directories(input-gdal PRIVATE ${GDAL_INCLUDE_DIRS}) target_link_libraries(input-gdal PRIVATE mapnik::core mapnik::mapnik diff --git a/plugins/input/ogr/CMakeLists.txt b/plugins/input/ogr/CMakeLists.txt index 577a133dd2..599a325a9d 100644 --- a/plugins/input/ogr/CMakeLists.txt +++ b/plugins/input/ogr/CMakeLists.txt @@ -10,7 +10,7 @@ add_library(input-ogr MODULE ) add_library(mapnik::plugin::input::ogr ALIAS input-ogr) -target_include_directories(input-ogr PRIVATE ${GDAL_INCLUDE_DIR}) +target_include_directories(input-ogr PRIVATE ${GDAL_INCLUDE_DIRS}) target_link_libraries(input-ogr PRIVATE mapnik::core mapnik::mapnik From a3a8294d95f9d09f2e6afb08d1240d3a9c7588e3 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 22:45:39 +0200 Subject: [PATCH 119/141] add presets --- .gitignore | 2 + CMakeLists.txt | 10 ++--- CMakePresets.json | 105 ++++++++++++++++++++++++++++++++++++++++++++ docs/cmake-usage.md | 59 ++++++++++++++++++++++++- 4 files changed, 170 insertions(+), 6 deletions(-) create mode 100644 CMakePresets.json diff --git a/.gitignore b/.gitignore index bf3bf93e05..9f55b20da6 100644 --- a/.gitignore +++ b/.gitignore @@ -60,3 +60,5 @@ test/visual/run # cmake build .vs + +CMakeUserPresets.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 456dc4be94..b718b25b99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -266,9 +266,9 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ QUIET) + mapnik_find_package(PROJ4 QUIET) # currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config - if(NOT PROJ_FOUND) + if(NOT PROJ4_FOUND) message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...") pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj) string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _dummy "${PROJ_VERSION}") @@ -276,11 +276,11 @@ if(USE_PROJ) set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}") set(PROJ_VERSION_PATCH "${CMAKE_MATCH_3}") endif() - math(EXPR MAPNIK_PROJ_VERSION "${PROJ_VERSION_MAJOR}*10000 + ${PROJ_VERSION_MINOR}*100 + ${PROJ_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) + math(EXPR MAPNIK_PROJ_VERSION "${PROJ4_VERSION_MAJOR}*10000 + ${PROJ4_VERSION_MINOR}*100 + ${PROJ4_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 ${PROJ_INCLUDE_DIRS}) + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ4_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000000..5477c3989e --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,105 @@ +{ + "version": 2, + "cmakeMinimumRequired": { + "major": 3, + "minor": 20, + "patch": 0 + }, + "configurePresets": [ + { + "name": "linux-clang", + "displayName": "Linux clang", + "hidden": true, + "binaryDir": "${sourceDir}/build/${presetName}", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++", + "CMAKE_CXX_FLAGS": "-stdlib=libstdc++", + "CMAKE_EXE_LINKER_FLAGS": "-stdlib=libstdc++", + "CMAKE_SHARED_LINKER_FLAGS": "-stdlib=libstdc++" + } + }, + { + "name": "linux-clang-debug", + "displayName": "Linux clang debug", + "inherits": "linux-clang", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "linux-clang-release", + "displayName": "Linux clang release", + "inherits": "linux-clang", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "linux-gcc", + "displayName": "Linux gcc", + "hidden": true, + "binaryDir": "${sourceDir}/build/${presetName}", + "cacheVariables": { + "CMAKE_C_COMPILER": "gcc", + "CMAKE_CXX_COMPILER": "g++" + } + }, + { + "name": "linux-gcc-debug", + "displayName": "Linux gcc debug", + "inherits": "linux-gcc", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "linux-gcc-release", + "displayName": "Linux gcc release", + "inherits": "linux-gcc", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "windows-default", + "displayName": "Windows x64 Debug", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}", + "architecture": { + "value": "x64", + "strategy": "external" + }, + "toolset": { + "value": "host=x64", + "strategy": "external" + }, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_C_COMPILER": "cl", + "CMAKE_CXX_COMPILER": "cl" + }, + "vendor": { + "microsoft.com/VisualStudioSettings/CMake/1.0": { + "hostOS": [ + "Windows" + ] + } + } + }, + { + "name": "windows-default-release", + "displayName": "Windows x64 Release", + "inherits": "windows-default", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + } + } + ], + "buildPresets": [ + { + "name": "default", + "configurePreset": "default" + } + ] +} diff --git a/docs/cmake-usage.md b/docs/cmake-usage.md index c1dc5b6475..cd99ff2fdc 100644 --- a/docs/cmake-usage.md +++ b/docs/cmake-usage.md @@ -36,4 +36,61 @@ The font path is is available in the variable `MAPNIK_FONTS_DIR`. ## Recommendations If you target a specific platform, it is recommended to create a toolchain file and set all the options and library path that you would normally set via cmd line options. -If you are using a recent cmake version (>=3.19?), it is recommended to use a CMakePreset instead. https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html +If you are using a recent cmake version (>=3.20), it is recommended to use a CMakePreset instead. https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html + + +## CMakePreset example + +If you are using CMakePresets and need to add vcpkg integration, just create a `CMakeUserPresets.json` file beside `CMakePresets.json. +This could look like this: +```json +{ + "version": 2, + "cmakeMinimumRequired": { + "major": 3, + "minor": 20, + "patch": 0 + }, + "configurePresets": [ + { + "name": "vcpkg-x64-win-debug", + "inherits": "windows-default", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake" + } + }, + { + "name": "vcpkg-x64-win-release", + "inherits": "windows-default-release", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake" + } + } + ] +} +``` + + +If your libraries are not in the global search paths, you could add a own `CMakeUserPresets.json` with + +```json +{ + "version": 2, + "cmakeMinimumRequired": { + "major": 3, + "minor": 20, + "patch": 0 + }, + "configurePresets": [ + { + "name": "linux-clang-debug-own", + "inherits": "linux-clang-debug", + "cacheVariables": { + "WebP_DIR": "/home/myuser/webp/cmake", + "USE_CAIRO": "OFF", + "CMAKE_INSTALL_PREFIX": "${sourceDir}/install" + } + } + ] +} +``` From 0d7af014bcf63eb82f7ff6e9dc44cac421f1fc4b Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 22:46:23 +0200 Subject: [PATCH 120/141] i really need to upgrade proj... --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b718b25b99..456dc4be94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -266,9 +266,9 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ4 QUIET) + mapnik_find_package(PROJ QUIET) # currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config - if(NOT PROJ4_FOUND) + if(NOT PROJ_FOUND) message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...") pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj) string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _dummy "${PROJ_VERSION}") @@ -276,11 +276,11 @@ if(USE_PROJ) set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}") set(PROJ_VERSION_PATCH "${CMAKE_MATCH_3}") endif() - math(EXPR MAPNIK_PROJ_VERSION "${PROJ4_VERSION_MAJOR}*10000 + ${PROJ4_VERSION_MINOR}*100 + ${PROJ4_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) + 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 ${PROJ4_LIBRARIES}) - list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) From ef5bd553a2095bb430c5fe9b7a954361428402d9 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 22:54:22 +0200 Subject: [PATCH 121/141] add MAPNIK_DEBUG when using the mapnik debug configuration --- CMakePresets.json | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 5477c3989e..1c735bb7fb 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -24,7 +24,8 @@ "displayName": "Linux clang debug", "inherits": "linux-clang", "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug" + "CMAKE_BUILD_TYPE": "Debug", + "MAPNIK_DEBUG": "ON" } }, { @@ -50,7 +51,8 @@ "displayName": "Linux gcc debug", "inherits": "linux-gcc", "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug" + "CMAKE_BUILD_TYPE": "Debug", + "MAPNIK_DEBUG": "ON" } }, { @@ -64,6 +66,7 @@ { "name": "windows-default", "displayName": "Windows x64 Debug", + "hidden": true, "generator": "Ninja", "binaryDir": "${sourceDir}/build/${presetName}", "architecture": { @@ -75,9 +78,9 @@ "strategy": "external" }, "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", "CMAKE_C_COMPILER": "cl", - "CMAKE_CXX_COMPILER": "cl" + "CMAKE_CXX_COMPILER": "cl", + "MAPNIK_DEBUG": "ON" }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { @@ -87,6 +90,14 @@ } } }, + { + "name": "windows-default-debug", + "displayName": "Windows x64 Debug", + "inherits": "windows-default", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + } + }, { "name": "windows-default-release", "displayName": "Windows x64 Release", From 0d7b659c2149a394878ca56ab5cb5d994ad5ec2b Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 22:56:00 +0200 Subject: [PATCH 122/141] fix --- CMakePresets.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 1c735bb7fb..c14827bae8 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -79,8 +79,7 @@ }, "cacheVariables": { "CMAKE_C_COMPILER": "cl", - "CMAKE_CXX_COMPILER": "cl", - "MAPNIK_DEBUG": "ON" + "CMAKE_CXX_COMPILER": "cl" }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { @@ -95,7 +94,8 @@ "displayName": "Windows x64 Debug", "inherits": "windows-default", "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug" + "CMAKE_BUILD_TYPE": "Debug", + "MAPNIK_DEBUG": "ON" } }, { From 0e95f538f6fd58c5ee6cdaed5eebd82060632622 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Thu, 22 Jul 2021 23:05:48 +0200 Subject: [PATCH 123/141] some docs --- docs/cmake-usage.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/cmake-usage.md b/docs/cmake-usage.md index cd99ff2fdc..da8f0468bd 100644 --- a/docs/cmake-usage.md +++ b/docs/cmake-usage.md @@ -54,16 +54,18 @@ This could look like this: "configurePresets": [ { "name": "vcpkg-x64-win-debug", - "inherits": "windows-default", + "inherits": "windows-default-debug", "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake" + "CMAKE_TOOLCHAIN_FILE": "D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake", + "ADDITIONAL_LIBARIES_PATHS":"D:/dev/vcpkg/x64-windows/debug/bin" } }, { "name": "vcpkg-x64-win-release", "inherits": "windows-default-release", "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake" + "CMAKE_TOOLCHAIN_FILE": "D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake", + "ADDITIONAL_LIBARIES_PATHS":"D:/dev/vcpkg/x64-windows/bin" } } ] From ad54c4ff0d841850b4df956f32ba6a140676bbf2 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 13:34:49 +0200 Subject: [PATCH 124/141] added missing options --- CMakeLists.txt | 37 +++++++++++++++++++++++++++++++++++++ CMakePresets.json | 12 +++++++++--- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 456dc4be94..a2f3945df8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,15 @@ 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) +# 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_PLUGIN_INPUT_CSV "adds plugin input csv" ON) option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON) @@ -71,6 +80,7 @@ option(BUILD_UTILITY_SHAPEINDEX "builds the utility program shapeindex" ON) 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) set(CMAKE_CXX_STANDARD 14 CACHE STRING "Sets the c++ standard. c++14 is minimum.") message(STATUS "Using c++${CMAKE_CXX_STANDARD}") @@ -135,6 +145,7 @@ mapnik_find_threads() mapnik_find_package(ICU REQUIRED COMPONENTS uc i18n data) mapnik_find_package(Boost 1.61 REQUIRED COMPONENTS filesystem system regex) if(USE_BOOST_REGEX_ICU_WORKAROUND) + message(STATUS "using boost regex workaround") set_property(TARGET Boost::regex PROPERTY INTERFACE_LINK_LIBRARIES) endif() @@ -218,6 +229,11 @@ endif() set_property(GLOBAL PROPERTY TARGETS "") set_property(GLOBAL PROPERTY PLUGINS "") +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) @@ -228,6 +244,27 @@ if(USE_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) + list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_DEFAULT_LOG_SEVERITY=${USE_LOG_SEVERITY}) +endif() + if(USE_LIBXML2) mapnik_find_package(LibXml2 REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_LIBXML2) diff --git a/CMakePresets.json b/CMakePresets.json index c14827bae8..df911080d8 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -25,7 +25,9 @@ "inherits": "linux-clang", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", - "MAPNIK_DEBUG": "ON" + "USE_DEBUG_OUTPUT": "ON", + "USE_LOG": "ON", + "USE_LOG_SEVERITY": "0" } }, { @@ -52,7 +54,9 @@ "inherits": "linux-gcc", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", - "MAPNIK_DEBUG": "ON" + "USE_DEBUG_OUTPUT": "ON", + "USE_LOG": "ON", + "USE_LOG_SEVERITY": "0" } }, { @@ -95,7 +99,9 @@ "inherits": "windows-default", "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", - "MAPNIK_DEBUG": "ON" + "USE_DEBUG_OUTPUT": "ON", + "USE_LOG": "ON", + "USE_LOG_SEVERITY": "0" } }, { From 5e2837761b6f554568e74c15b30d34f99f329cba Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 15:48:17 +0200 Subject: [PATCH 125/141] rewrite webp to add debug libraries --- CMakeLists.txt | 2 +- cmake/FindWebP.cmake | 195 +++++++++++++------------------------------ 2 files changed, 59 insertions(+), 138 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2f3945df8..36d90ecab1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -292,7 +292,7 @@ endif() if(USE_WEBP) mapnik_find_package(WebP REQUIRED) list(APPEND MAPNIK_COMPILE_DEFS HAVE_WEBP) - list(APPEND MAPNIK_OPTIONAL_LIBS WebP::libwebp) + list(APPEND MAPNIK_OPTIONAL_LIBS WebP::WebP) endif() if(USE_CAIRO) diff --git a/cmake/FindWebP.cmake b/cmake/FindWebP.cmake index c93e78cebe..d36d1879fa 100644 --- a/cmake/FindWebP.cmake +++ b/cmake/FindWebP.cmake @@ -1,166 +1,87 @@ -# Copyright (C) 2020 Sony Interactive Entertainment Inc. -# Copyright (C) 2012 Raphael Kubo da Costa -# Copyright (C) 2013 Igalia S.L. -# -# 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. +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. #[=======================================================================[.rst: FindWebP --------------- +------- -Find WebP headers and libraries. +Finds the WebP library. Imported Targets ^^^^^^^^^^^^^^^^ -``WebP::libwebp`` - The WebP library, if found. +This module provides the following imported targets, if found: -``WebP::demux`` - The WebP demux library, if found. +``WebP::WebP`` + The WebP library Result Variables ^^^^^^^^^^^^^^^^ -This will define the following variables in your project: +This will define the following variables: ``WebP_FOUND`` - true if (the requested version of) WebP is available. + True if the system has the WebP library. ``WebP_VERSION`` - the version of WebP. -``WebP_LIBRARIES`` - the libraries to link against to use WebP. + The version of the WebP library which was found. ``WebP_INCLUDE_DIRS`` - where to find the WebP headers. -``WebP_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_WEBP QUIET libwebp) -set(WebP_COMPILE_OPTIONS ${PC_WEBP_CFLAGS_OTHER}) -set(WebP_VERSION ${PC_WEBP_CFLAGS_VERSION}) - -find_path(WebP_INCLUDE_DIR - NAMES webp/decode.h - HINTS ${PC_WEBP_INCLUDEDIR} ${PC_WEBP_INCLUDE_DIRS} -) + Include directories needed to use WebP. +``WebP_LIBRARIES`` + Libraries needed to link to WebP. -find_library(WebP_LIBRARY - NAMES ${WebP_NAMES} webp - HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS} -) +Cache Variables +^^^^^^^^^^^^^^^ -# There's nothing in the WebP headers that could be used to detect the exact -# WebP version being used so don't attempt to do so. A version can only be found -# through pkg-config -if ("${WebP_FIND_VERSION}" VERSION_GREATER "${WebP_VERSION}") - if (WebP_VERSION) - message(FATAL_ERROR "Required version (" ${WebP_FIND_VERSION} ") is higher than found version (" ${WebP_VERSION} ")") - else () - message(WARNING "Cannot determine WebP version without pkg-config") - endif () -endif () +The following cache variables may also be set: -# Find components -if (WebP_INCLUDE_DIR AND WebP_LIBRARY) - set(_WebP_REQUIRED_LIBS_FOUND ON) - set(WebP_LIBS_FOUND "WebP (required): ${WebP_LIBRARY}") -else () - set(_WebP_REQUIRED_LIBS_FOUND OFF) - set(WebP_LIBS_NOT_FOUND "WebP (required)") -endif () +``WebP_INCLUDE_DIR`` + The directory containing ``decode.h``. +``WebP_LIBRARY`` + The path to the Foo library. -if ("demux" IN_LIST WebP_FIND_COMPONENTS) - find_library(WebP_DEMUX_LIBRARY - NAMES ${WebP_DEMUX_NAMES} webpdemux - HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS} - ) - - if (WebP_DEMUX_LIBRARY) - if (WebP_FIND_REQUIRED_demux) - list(APPEND WebP_LIBS_FOUND "demux (required): ${WebP_DEMUX_LIBRARY}") - else () - list(APPEND WebP_LIBS_FOUND "demux (optional): ${WebP_DEMUX_LIBRARY}") - endif () - else () - if (WebP_FIND_REQUIRED_demux) - set(_WebP_REQUIRED_LIBS_FOUND OFF) - list(APPEND WebP_LIBS_NOT_FOUND "demux (required)") - else () - list(APPEND WebP_LIBS_NOT_FOUND "demux (optional)") - endif () - endif () -endif () +#]=======================================================================] -if (NOT WebP_FIND_QUIETLY) - if (WebP_LIBS_FOUND) - message(STATUS "Found the following WebP libraries:") - foreach (found ${WebP_LIBS_FOUND}) - message(STATUS " ${found}") - endforeach () - endif () - if (WebP_LIBS_NOT_FOUND) - message(STATUS "The following WebP libraries were not found:") - foreach (found ${WebP_LIBS_NOT_FOUND}) - message(STATUS " ${found}") - endforeach () - endif () -endif () +if(NOT WebP_LIBRARY) + find_package(PkgConfig QUIET) + pkg_check_modules(PC_WebP QUIET libwebp) + find_path(WebP_INCLUDE_DIR NAMES decode.h HINTS ${PC_WebP_INCLUDEDIR} ${PC_WebP_INCLUDE_DIR} PATH_SUFFIXES webp) + find_library(WebP_LIBRARY_RELEASE NAMES ${WebP_NAMES} webp HINTS ${PC_WebP_LIBDIR} ${PC_WebP_LIBRARY_DIRS}) + find_library(WebP_LIBRARY_DEBUG NAMES ${WebP_NAMES} webpd HINTS ${PC_WebP_LIBDIR} ${PC_WebP_LIBRARY_DIRS}) + include(SelectLibraryConfigurations) + select_library_configurations(WebP) +else() + file(TO_CMAKE_PATH "${WebP_LIBRARY}" WebP_LIBRARY) +endif() include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(WebP - FOUND_VAR WebP_FOUND - REQUIRED_VARS WebP_INCLUDE_DIR WebP_LIBRARY _WebP_REQUIRED_LIBS_FOUND - VERSION_VAR WebP_VERSION -) - -if (WebP_LIBRARY AND NOT TARGET WebP::libwebp) - add_library(WebP::libwebp UNKNOWN IMPORTED GLOBAL) - set_target_properties(WebP::libwebp PROPERTIES - IMPORTED_LOCATION "${WebP_LIBRARY}" - INTERFACE_COMPILE_OPTIONS "${WebP_COMPILE_OPTIONS}" - INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR}" - ) -endif () - -if (WebP_DEMUX_LIBRARY AND NOT TARGET WebP::demux) - add_library(WebP::demux UNKNOWN IMPORTED GLOBAL) - set_target_properties(WebP::demux PROPERTIES - IMPORTED_LOCATION "${WebP_DEMUX_LIBRARY}" - INTERFACE_COMPILE_OPTIONS "${WebP_COMPILE_OPTIONS}" - INTERFACE_INCLUDE_DIRECTORIES "${WebP_INCLUDE_DIR}" - ) -endif () - -mark_as_advanced( - WebP_INCLUDE_DIR +find_package_handle_standard_args(WebP + REQUIRED_VARS WebP_LIBRARY - WebP_DEMUX_LIBRARY + WebP_INCLUDE_DIR ) +mark_as_advanced(WebP_INCLUDE_DIR WebP_LIBRARY) if (WebP_FOUND) - set(WebP_LIBRARIES ${WebP_LIBRARY} ${WebP_DEMUX_LIBRARY}) - set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR}) + set(WebP_LIBRARIES ${WebP_LIBRARY}) + set(WebP_INCLUDE_DIRS ${WebP_INCLUDE_DIR}) + if(NOT TARGET WebP::WebP) + add_library(WebP::WebP UNKNOWN IMPORTED) + set_target_properties(WebP::WebP PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${WebP_INCLUDE_DIR} + IMPORTED_LINK_INTERFACE_LANGUAGES C) + + if(WebP_LIBRARY_RELEASE) + set_property(TARGET WebP::WebP APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(WebP::WebP PROPERTIES IMPORTED_LOCATION_RELEASE "${WebP_LIBRARY_RELEASE}") + endif() + + if(WebP_LIBRARY_DEBUG) + set_property(TARGET WebP::WebP APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(WebP::WebP PROPERTIES IMPORTED_LOCATION_DEBUG "${WebP_LIBRARY_DEBUG}") + endif() + + if(NOT WebP_LIBRARY_RELEASE AND NOT WebP_LIBRARY_DEBUG) + set_target_properties(WebP::WebP PROPERTIES IMPORTED_LOCATION "${WebP_LIBRARY}") + endif() + endif() endif () From 2b72a8f2861538bdaf96302773916ee263a68169 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 15:54:51 +0200 Subject: [PATCH 126/141] add version again to FindWebP --- cmake/FindWebP.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cmake/FindWebP.cmake b/cmake/FindWebP.cmake index d36d1879fa..6967f03052 100644 --- a/cmake/FindWebP.cmake +++ b/cmake/FindWebP.cmake @@ -44,6 +44,7 @@ The following cache variables may also be set: if(NOT WebP_LIBRARY) find_package(PkgConfig QUIET) pkg_check_modules(PC_WebP QUIET libwebp) + set(WebP_VERSION ${PC_WebP_VERSION}) find_path(WebP_INCLUDE_DIR NAMES decode.h HINTS ${PC_WebP_INCLUDEDIR} ${PC_WebP_INCLUDE_DIR} PATH_SUFFIXES webp) find_library(WebP_LIBRARY_RELEASE NAMES ${WebP_NAMES} webp HINTS ${PC_WebP_LIBDIR} ${PC_WebP_LIBRARY_DIRS}) find_library(WebP_LIBRARY_DEBUG NAMES ${WebP_NAMES} webpd HINTS ${PC_WebP_LIBDIR} ${PC_WebP_LIBRARY_DIRS}) @@ -53,11 +54,20 @@ else() file(TO_CMAKE_PATH "${WebP_LIBRARY}" WebP_LIBRARY) endif() +if ("${WebP_FIND_VERSION}" VERSION_GREATER "${WebP_VERSION}") + if (WebP_VERSION) + message(FATAL_ERROR "Required version (" ${WebP_FIND_VERSION} ") is higher than found version (" ${PC_WebP_VERSION} ")") + else () + message(WARNING "Cannot determine WebP version without pkg-config") + endif () +endif () + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(WebP REQUIRED_VARS WebP_LIBRARY WebP_INCLUDE_DIR + WebP_VERSION ) mark_as_advanced(WebP_INCLUDE_DIR WebP_LIBRARY) From 0f16e2ab65dbb31319cce99f945f75221d23a121 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 16:04:25 +0200 Subject: [PATCH 127/141] fixed some var refs --- cmake/MapnikInstall.cmake | 6 +++--- utils/ogrindex/CMakeLists.txt | 10 +--------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/cmake/MapnikInstall.cmake b/cmake/MapnikInstall.cmake index 6f0cfd553a..5e9cd1349a 100644 --- a/cmake/MapnikInstall.cmake +++ b/cmake/MapnikInstall.cmake @@ -4,20 +4,20 @@ function(mapnik_install) set(multiValueArgs) cmake_parse_arguments(MAPNIK_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - if(NOT ${MAPNIK_INSTALL_ALREADY_INSTALLED} AND NOT ${MAPNIK_INSTALL_IS_PLUGIN}) + if(NOT MAPNIK_INSTALL_ALREADY_INSTALLED AND NOT MAPNIK_INSTALL_IS_PLUGIN) install(TARGETS ${MAPNIK_INSTALL_TARGET} LIBRARY DESTINATION ${MAPNIK_LIB_DIR} ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} RUNTIME DESTINATION ${MAPNIK_BIN_DIR} ) - elseif(NOT ${MAPNIK_INSTALL_ALREADY_INSTALLED} AND ${MAPNIK_INSTALL_IS_PLUGIN}) + elseif(NOT MAPNIK_INSTALL_ALREADY_INSTALLED AND MAPNIK_INSTALL_IS_PLUGIN) install(TARGETS ${MAPNIK_INSTALL_TARGET} LIBRARY DESTINATION ${PLUGINS_INSTALL_DIR} ARCHIVE DESTINATION ${PLUGINS_INSTALL_DIR} RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} ) endif() - if(NOT ${MAPNIK_INSTALL_IS_PLUGIN}) + if(NOT MAPNIK_INSTALL_IS_PLUGIN) message(STATUS "${MAPNIK_INSTALL_TARGET}") get_target_property(TARGET_TYPE "${MAPNIK_INSTALL_TARGET}" TYPE) if (TARGET_TYPE STREQUAL "EXECUTABLE") diff --git a/utils/ogrindex/CMakeLists.txt b/utils/ogrindex/CMakeLists.txt index afc13541bf..771b2c5923 100644 --- a/utils/ogrindex/CMakeLists.txt +++ b/utils/ogrindex/CMakeLists.txt @@ -2,14 +2,6 @@ project(ogrindex) add_executable(ogrindex ogrindex.cpp) - target_link_libraries(ogrindex PRIVATE mapnik::core mapnik::mapnik) -install(TARGETS ogrindex - EXPORT MapnikTargets - LIBRARY DESTINATION ${MAPNIK_LIB_DIR} - ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} - RUNTIME DESTINATION ${MAPNIK_BIN_DIR} -) - -mapnik_install(TARGET mapnik-ogrindex) +mapnik_install(TARGET ogrindex) From 2c7dab1f5d22489cdb06edc39aa03b1805265957 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 16:10:35 +0200 Subject: [PATCH 128/141] add MAPNIK_STATS --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 36d90ecab1..ef7bb19af5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,7 @@ option(USE_LOG "enables logging output. See log severity level." OFF) # 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) option(USE_PLUGIN_INPUT_CSV "adds plugin input csv" ON) option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON) @@ -261,8 +262,12 @@ endif() if(USE_LOG) message(STATUS "logging enabled with level ${USE_LOG_SEVERITY}") - list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_LOG) - list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_DEFAULT_LOG_SEVERITY=${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() if(USE_LIBXML2) From 11467e3628d9af6cf3f7f601872cfcc6669f52dd Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 16:41:28 +0200 Subject: [PATCH 129/141] add missing generator to CMakePresets --- CMakePresets.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index df911080d8..8f3d84f0d0 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -11,6 +11,7 @@ "displayName": "Linux clang", "hidden": true, "binaryDir": "${sourceDir}/build/${presetName}", + "generator": "Ninja", "cacheVariables": { "CMAKE_C_COMPILER": "clang", "CMAKE_CXX_COMPILER": "clang++", @@ -43,6 +44,7 @@ "displayName": "Linux gcc", "hidden": true, "binaryDir": "${sourceDir}/build/${presetName}", + "generator": "Ninja", "cacheVariables": { "CMAKE_C_COMPILER": "gcc", "CMAKE_CXX_COMPILER": "g++" @@ -115,8 +117,12 @@ ], "buildPresets": [ { - "name": "default", - "configurePreset": "default" + "name": "windows-default", + "configurePreset": "windows-default-debug" + }, + { + "name": "linux-default", + "configurePreset": "linux-clang-debug" } ] } From 1494a0ffeee2d65fefe6411e69470ff05f00777a Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 17:06:24 +0200 Subject: [PATCH 130/141] enable qt6 or qt5 for mapnik-viewer. android could be dropped --- demo/viewer/CMakeLists.txt | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index 01fab3db86..790bcb33be 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -1,8 +1,9 @@ project(mapnik-viewer) -find_package(Qt5 COMPONENTS Widgets REQUIRED) +find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED) +find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED) -add_executable(mapnik-viewer +set(PROJECT_SOURCES about_dialog.cpp info_dialog.cpp layerdelegate.cpp @@ -19,6 +20,23 @@ add_executable(mapnik-viewer mapnik_viewer.qrc ) +if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) + qt_add_executable(mapnik-viewer + MANUAL_FINALIZATION + ${PROJECT_SOURCES} + ) +else() + if(ANDROID) + add_library(mapnik-viewer SHARED + ${PROJECT_SOURCES} + ) + else() + add_executable(mapnik-viewer + ${PROJECT_SOURCES} + ) + endif() +endif() + set_target_properties(mapnik-viewer PROPERTIES AUTOUIC_SEARCH_PATHS forms AUTORCC ON @@ -26,18 +44,23 @@ set_target_properties(mapnik-viewer PROPERTIES AUTOMOC ON ) - target_link_libraries(mapnik-viewer PRIVATE - Qt5::Widgets + Qt${QT_VERSION_MAJOR}::Widgets mapnik::core mapnik::agg mapnik::mapnik ) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini "[mapnik] plugins_dir=${PLUGINS_INSTALL_DIR} fonts/1/dir=${FONTS_INSTALL_DIR}" ) + +if(QT_VERSION_MAJOR EQUAL 6) + qt_finalize_executable(mapnik-viewer) +endif() + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini DESTINATION bin) mapnik_install(TARGET mapnik-viewer) From 692da9dc00cb3e2a0758db18ec8e27b358d01682 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 18:14:37 +0200 Subject: [PATCH 131/141] delete clang toolchain(replaced by CMakePresets) --- cmake/clang.cmake | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 cmake/clang.cmake diff --git a/cmake/clang.cmake b/cmake/clang.cmake deleted file mode 100644 index 93aa0c73f4..0000000000 --- a/cmake/clang.cmake +++ /dev/null @@ -1,6 +0,0 @@ -set(CMAKE_C_COMPILER clang) -set(CMAKE_CXX_COMPILER clang++) - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++") -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++") From 7770f64ce65800aeec1a2c9775d2356074e6635d Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 19:34:17 +0200 Subject: [PATCH 132/141] link with correct lib (clang) --- CMakePresets.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 8f3d84f0d0..06a43f1929 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,9 +15,9 @@ "cacheVariables": { "CMAKE_C_COMPILER": "clang", "CMAKE_CXX_COMPILER": "clang++", - "CMAKE_CXX_FLAGS": "-stdlib=libstdc++", - "CMAKE_EXE_LINKER_FLAGS": "-stdlib=libstdc++", - "CMAKE_SHARED_LINKER_FLAGS": "-stdlib=libstdc++" + "CMAKE_CXX_FLAGS": "-stdlib=libc++", + "CMAKE_EXE_LINKER_FLAGS": "-stdlib=libc++", + "CMAKE_SHARED_LINKER_FLAGS": "-stdlib=libc++" } }, { From f6ca2bca38ab02c585e3d0feab47eabf086cfd3f Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 18:39:42 +0200 Subject: [PATCH 133/141] some fixes for FindWebP --- cmake/FindWebP.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/FindWebP.cmake b/cmake/FindWebP.cmake index 6967f03052..e966a0cf81 100644 --- a/cmake/FindWebP.cmake +++ b/cmake/FindWebP.cmake @@ -64,10 +64,11 @@ endif () include(FindPackageHandleStandardArgs) find_package_handle_standard_args(WebP + FOUND_VAR WebP_FOUND REQUIRED_VARS WebP_LIBRARY WebP_INCLUDE_DIR - WebP_VERSION + VERSION_VAR WebP_VERSION ) mark_as_advanced(WebP_INCLUDE_DIR WebP_LIBRARY) From bfcf1f68de726e4d930abcb10cf9b45bc5c18a5e Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 18:40:57 +0200 Subject: [PATCH 134/141] found var was deprecated. --- CMakeLists.txt | 10 +++++----- cmake/FindWebP.cmake | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef7bb19af5..6a4db8e44c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -308,9 +308,9 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ QUIET) + mapnik_find_package(PROJ4 QUIET) # currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config - if(NOT PROJ_FOUND) + if(NOT PROJ4_FOUND) message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...") pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj) string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _dummy "${PROJ_VERSION}") @@ -318,11 +318,11 @@ if(USE_PROJ) set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}") set(PROJ_VERSION_PATCH "${CMAKE_MATCH_3}") endif() - math(EXPR MAPNIK_PROJ_VERSION "${PROJ_VERSION_MAJOR}*10000 + ${PROJ_VERSION_MINOR}*100 + ${PROJ_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) + math(EXPR MAPNIK_PROJ_VERSION "${PROJ4_VERSION_MAJOR}*10000 + ${PROJ4_VERSION_MINOR}*100 + ${PROJ4_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 ${PROJ_INCLUDE_DIRS}) + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ4_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) diff --git a/cmake/FindWebP.cmake b/cmake/FindWebP.cmake index e966a0cf81..57c9e94e93 100644 --- a/cmake/FindWebP.cmake +++ b/cmake/FindWebP.cmake @@ -63,8 +63,7 @@ if ("${WebP_FIND_VERSION}" VERSION_GREATER "${WebP_VERSION}") endif () include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(WebP - FOUND_VAR WebP_FOUND +find_package_handle_standard_args(WebP REQUIRED_VARS WebP_LIBRARY WebP_INCLUDE_DIR From e5a22e1dd23e88305da22ca4092fd6ef852e311d Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 18:41:07 +0200 Subject: [PATCH 135/141] Revert "found var was deprecated." This reverts commit 6b5e4dcec23ee6671d94b65b7b9bd19bf4d79647. --- CMakeLists.txt | 10 +++++----- cmake/FindWebP.cmake | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a4db8e44c..ef7bb19af5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -308,9 +308,9 @@ endif() if(USE_PROJ) #https://proj.org/development/cmake.html - mapnik_find_package(PROJ4 QUIET) + mapnik_find_package(PROJ QUIET) # currently the cmake files are not installed, when installing proj via apt-get. So search via pkg-config - if(NOT PROJ4_FOUND) + if(NOT PROJ_FOUND) message(STATUS "PROJ not found via FindPROJ. Searching via pkg-config...") pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj) string(REGEX MATCH "([0-9]+)\.([0-9]+)\.([0-9]+)" _dummy "${PROJ_VERSION}") @@ -318,11 +318,11 @@ if(USE_PROJ) set(PROJ_VERSION_MINOR "${CMAKE_MATCH_2}") set(PROJ_VERSION_PATCH "${CMAKE_MATCH_3}") endif() - math(EXPR MAPNIK_PROJ_VERSION "${PROJ4_VERSION_MAJOR}*10000 + ${PROJ4_VERSION_MINOR}*100 + ${PROJ4_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL) + 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 ${PROJ4_LIBRARIES}) - list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ4_INCLUDE_DIRS}) + list(APPEND MAPNIK_OPTIONAL_LIBS ${PROJ_LIBRARIES}) + list(APPEND MAPNIK_OPTIONAL_LIBS_INCLUDE ${PROJ_INCLUDE_DIRS}) endif() if(USE_GRID_RENDERER) diff --git a/cmake/FindWebP.cmake b/cmake/FindWebP.cmake index 57c9e94e93..e966a0cf81 100644 --- a/cmake/FindWebP.cmake +++ b/cmake/FindWebP.cmake @@ -63,7 +63,8 @@ if ("${WebP_FIND_VERSION}" VERSION_GREATER "${WebP_VERSION}") endif () include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(WebP +find_package_handle_standard_args(WebP + FOUND_VAR WebP_FOUND REQUIRED_VARS WebP_LIBRARY WebP_INCLUDE_DIR From b446686edc778063cdff5ea7c22c5391bd6f3ab5 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 23 Jul 2021 18:41:30 +0200 Subject: [PATCH 136/141] [FindWebP] FOUND_VAR is deprecated --- cmake/FindWebP.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/FindWebP.cmake b/cmake/FindWebP.cmake index e966a0cf81..860dc3dfec 100644 --- a/cmake/FindWebP.cmake +++ b/cmake/FindWebP.cmake @@ -64,7 +64,6 @@ endif () include(FindPackageHandleStandardArgs) find_package_handle_standard_args(WebP - FOUND_VAR WebP_FOUND REQUIRED_VARS WebP_LIBRARY WebP_INCLUDE_DIR From 3e8857119bc9b366cb3debfbc1b55a23aa286568 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 24 Jul 2021 00:58:28 +0200 Subject: [PATCH 137/141] remove not needed include of --- include/mapnik/css/css_color_grammar_x3_def.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/mapnik/css/css_color_grammar_x3_def.hpp b/include/mapnik/css/css_color_grammar_x3_def.hpp index e42c024701..5db0d9c921 100644 --- a/include/mapnik/css/css_color_grammar_x3_def.hpp +++ b/include/mapnik/css/css_color_grammar_x3_def.hpp @@ -430,7 +430,6 @@ auto const css_color_def = hsla_color ; -#include MAPNIK_DISABLE_WARNING_PUSH #include BOOST_SPIRIT_DEFINE( From 2a6b12a9ae19dfc5950e18d2c1fdb6b4d4ad1c1c Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 13 Aug 2021 17:21:46 +0200 Subject: [PATCH 138/141] update cmake docs --- docs/cmake-usage.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/cmake-usage.md b/docs/cmake-usage.md index da8f0468bd..22ff340863 100644 --- a/docs/cmake-usage.md +++ b/docs/cmake-usage.md @@ -56,16 +56,16 @@ This could look like this: "name": "vcpkg-x64-win-debug", "inherits": "windows-default-debug", "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake", - "ADDITIONAL_LIBARIES_PATHS":"D:/dev/vcpkg/x64-windows/debug/bin" + "CMAKE_TOOLCHAIN_FILE": "/scripts/buildsystems/vcpkg.cmake", + "ADDITIONAL_LIBARIES_PATHS":"/installed/x64-windows/debug/bin" } }, { "name": "vcpkg-x64-win-release", "inherits": "windows-default-release", "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": "D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake", - "ADDITIONAL_LIBARIES_PATHS":"D:/dev/vcpkg/x64-windows/bin" + "CMAKE_TOOLCHAIN_FILE": "/scripts/buildsystems/vcpkg.cmake", + "ADDITIONAL_LIBARIES_PATHS":"/installed/x64-windows/bin" } } ] From 9599b18d321d13aba6557bd13a6ee23d430fff0f Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Fri, 13 Aug 2021 20:41:30 +0200 Subject: [PATCH 139/141] copy all plugins to the viewer build dir --- demo/viewer/CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index 790bcb33be..9f866d7077 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -70,3 +70,10 @@ mapnik_copy_dependencies( PLUGINS input-csv input-gdal input-geobuf input-geojson input-ogr input-pgraster input-postgis input-raster input-shape input-sqlite input-topojson ) + +mapnik_copy_plugins(TARGET mapnik-viewer + DESTINATION + ${PLUGINS_INSTALL_DIR} + PLUGINS + input-csv input-gdal input-geobuf input-geojson input-ogr input-pgraster input-postgis input-raster input-shape input-sqlite input-topojson +) From 2bd0939f9b5a0a82dcddebcc282ede1e8a68990a Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 25 Aug 2021 16:41:57 +0200 Subject: [PATCH 140/141] some last minor improvements --- CMakeLists.txt | 2 +- CMakePresets.json | 152 ++++++++++++++++++++++++++-------------- docs/cmake-usage.md | 6 ++ src/CMakeLists.txt | 15 ++-- src/json/CMakeLists.txt | 3 +- src/wkt/CMakeLists.txt | 3 +- 6 files changed, 121 insertions(+), 60 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef7bb19af5..4c6ba296b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ 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" ON) +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) diff --git a/CMakePresets.json b/CMakePresets.json index 06a43f1929..5f2a874f09 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -7,11 +7,41 @@ }, "configurePresets": [ { - "name": "linux-clang", - "displayName": "Linux clang", + "name": "use-ninja", + "hidden": true, + "generator": "Ninja" + }, + { + "name": "default-build-dir", + "hidden": true, + "binaryDir": "${sourceDir}/build/${presetName}" + }, + { + "name": "debug-build", "hidden": true, - "binaryDir": "${sourceDir}/build/${presetName}", - "generator": "Ninja", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "USE_DEBUG_OUTPUT": "ON", + "USE_LOG": "ON", + "USE_LOG_SEVERITY": "0" + } + }, + { + "name": "release-build", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release", + "USE_DEBUG_OUTPUT": "OFF", + "USE_LOG": "OFF" + } + }, + { + "name": "use-clang", + "hidden": true, + "inherits": [ + "default-build-dir", + "use-ninja" + ], "cacheVariables": { "CMAKE_C_COMPILER": "clang", "CMAKE_CXX_COMPILER": "clang++", @@ -21,60 +51,76 @@ } }, { - "name": "linux-clang-debug", - "displayName": "Linux clang debug", - "inherits": "linux-clang", + "name": "use-gcc", + "hidden": true, + "inherits": [ + "default-build-dir", + "use-ninja" + ], "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "USE_DEBUG_OUTPUT": "ON", - "USE_LOG": "ON", - "USE_LOG_SEVERITY": "0" + "CMAKE_C_COMPILER": "gcc", + "CMAKE_CXX_COMPILER": "g++" } }, { - "name": "linux-clang-release", - "displayName": "Linux clang release", - "inherits": "linux-clang", + "name": "use-msvc-cl", + "hidden": true, + "inherits": [ + "default-build-dir", + "use-ninja" + ], "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" + "CMAKE_C_COMPILER": "cl", + "CMAKE_CXX_COMPILER": "cl" } }, { - "name": "linux-gcc", - "displayName": "Linux gcc", + "name": "use-msvc-clang-cl", "hidden": true, - "binaryDir": "${sourceDir}/build/${presetName}", - "generator": "Ninja", + "inherits": [ + "default-build-dir", + "use-ninja" + ], "cacheVariables": { - "CMAKE_C_COMPILER": "gcc", - "CMAKE_CXX_COMPILER": "g++" + "CMAKE_C_COMPILER": "clang-cl", + "CMAKE_CXX_COMPILER": "clang-cl" } }, + { + "name": "linux-clang-debug", + "displayName": "Linux clang debug", + "inherits": [ + "use-clang", + "debug-build" + ] + }, + { + "name": "linux-clang-release", + "displayName": "Linux clang release", + "inherits": [ + "use-clang", + "release-build" + ] + }, { "name": "linux-gcc-debug", "displayName": "Linux gcc debug", - "inherits": "linux-gcc", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "USE_DEBUG_OUTPUT": "ON", - "USE_LOG": "ON", - "USE_LOG_SEVERITY": "0" - } + "inherits": [ + "use-gcc", + "debug-build" + ] }, { "name": "linux-gcc-release", "displayName": "Linux gcc release", - "inherits": "linux-gcc", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" - } + "inherits": [ + "use-gcc", + "release-build" + ] }, { - "name": "windows-default", - "displayName": "Windows x64 Debug", + "name": "windows-arch-x64", "hidden": true, - "generator": "Ninja", - "binaryDir": "${sourceDir}/build/${presetName}", "architecture": { "value": "x64", "strategy": "external" @@ -82,11 +128,16 @@ "toolset": { "value": "host=x64", "strategy": "external" - }, - "cacheVariables": { - "CMAKE_C_COMPILER": "cl", - "CMAKE_CXX_COMPILER": "cl" - }, + } + }, + { + "name": "windows-default", + "displayName": "Windows x64 Debug", + "hidden": true, + "inherits": [ + "use-msvc-cl", + "windows-arch-x64" + ], "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { "hostOS": [ @@ -98,21 +149,18 @@ { "name": "windows-default-debug", "displayName": "Windows x64 Debug", - "inherits": "windows-default", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Debug", - "USE_DEBUG_OUTPUT": "ON", - "USE_LOG": "ON", - "USE_LOG_SEVERITY": "0" - } + "inherits": [ + "windows-default", + "debug-build" + ] }, { "name": "windows-default-release", "displayName": "Windows x64 Release", - "inherits": "windows-default", - "cacheVariables": { - "CMAKE_BUILD_TYPE": "Release" - } + "inherits": [ + "windows-default", + "release-build" + ] } ], "buildPresets": [ diff --git a/docs/cmake-usage.md b/docs/cmake-usage.md index 22ff340863..f3cfbcf05c 100644 --- a/docs/cmake-usage.md +++ b/docs/cmake-usage.md @@ -96,3 +96,9 @@ If your libraries are not in the global search paths, you could add a own `CMake ] } ``` + +Build with: +``` +$ cmake --preset +$ cmake --build --preset +``` diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5de2a86e6b..c2679f065e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,10 +1,6 @@ add_subdirectory(json) add_subdirectory(wkt) -if(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") -endif() - set(MAPNIK_SOURCES cairo_io.cpp color_factory.cpp @@ -296,10 +292,19 @@ target_link_libraries(mapnik PRIVATE ) set_target_properties(mapnik PROPERTIES - DEBUG_POSTFIX ${MAPNIK_DEBUG_POSTFIX} + DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}" + OUTPUT_NAME "mapnik" PREFIX "lib" ) +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() + install(TARGETS mapnik EXPORT MapnikTargets LIBRARY DESTINATION ${MAPNIK_LIB_DIR} diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index 93f0baad72..0748d20433 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -25,8 +25,9 @@ target_include_directories(json PRIVATE target_link_libraries(json PRIVATE mapnik::core ${ICUU_LIB}) set_target_properties(json PROPERTIES - DEBUG_POSTFIX ${MAPNIK_DEBUG_POSTFIX} POSITION_INDEPENDENT_CODE ON + DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}" + OUTPUT_NAME "json" PREFIX "libmapnik-" ) diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index 7ef2255fa2..9c0934290a 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -17,8 +17,9 @@ target_include_directories(wkt PRIVATE target_link_libraries(wkt PRIVATE mapnik::core) set_target_properties(wkt PROPERTIES - DEBUG_POSTFIX ${MAPNIK_DEBUG_POSTFIX} POSITION_INDEPENDENT_CODE ON + DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}" + OUTPUT_NAME "wkt" PREFIX "libmapnik-" ) From dde791c0ff249d69ddfb008c03391129ac03287d Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 25 Aug 2021 17:25:23 +0200 Subject: [PATCH 141/141] update to latest catch2 --- test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0e57e997dc..a187203061 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -9,7 +9,7 @@ include(CopyDllsForDebug) FetchContent_Declare( Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v2.13.3) + GIT_TAG v2.13.7) FetchContent_MakeAvailable(Catch2) # Prepare "Catch" library for other executables @@ -193,7 +193,7 @@ mapnik_copy_dependencies( file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test) file(COPY data-visual DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test) -ParseAndAddCatchTests(mapnik-test-unit) +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)