Skip to content

Added cmake and ported to current mapnik master version #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
.vscode
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.15)
project(hello-world-input-plugin)

option(BUILD_TEST "builds the tests" ON)

find_package(mapnik CONFIG REQUIRED)

add_library(hello-world-input-plugin SHARED
hello_datasource.cpp
hello_featureset.cpp
)

target_link_libraries(hello-world-input-plugin PRIVATE mapnik::mapnik)

set_target_properties(hello-world-input-plugin PROPERTIES
PREFIX ""
OUTPUT_NAME "hello"
SUFFIX ".input"
)

if(BUILD_TEST)
enable_testing()
add_subdirectory(test)
endif()

install(TARGETS hello-world-input-plugin RUNTIME DESTINATION bin/plugins)
38 changes: 0 additions & 38 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion hello_datasource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <mapnik/params.hpp>
#include <mapnik/query.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/box2d.hpp>
#include <mapnik/geometry/box2d.hpp>
#include <mapnik/coord.hpp>
#include <mapnik/feature_layer_desc.hpp>

Expand Down
10 changes: 5 additions & 5 deletions hello_featureset.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// mapnik
#include <mapnik/feature_factory.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/value/types.hpp>

// boost

Expand Down Expand Up @@ -56,10 +56,10 @@ mapnik::feature_ptr hello_featureset::next()
// to dynamically generate a fake line
mapnik::geometry::line_string<double> line;
line.reserve(4);
line.add_coord(box_.minx(),box_.maxy());
line.add_coord(box_.maxx(),box_.maxy());
line.add_coord(box_.maxx(),box_.miny());
line.add_coord(box_.minx(),box_.miny());
line.push_back({box_.minx(),box_.maxy()});
line.push_back({box_.maxx(),box_.maxy()});
line.push_back({box_.maxx(),box_.miny()});
line.push_back({box_.minx(),box_.miny()});
feature->set_geometry(std::move(line));
return feature;
}
Expand Down
28 changes: 28 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Include(FetchContent)

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()


FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.7
)
FetchContent_MakeAvailable(Catch2)

add_executable(input-test unit.cpp)
target_link_libraries(input-test PRIVATE
Catch2::Catch2
mapnik::mapnik
)
set_target_properties(input-test PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}
)

include(CTest)
include("${catch2_SOURCE_DIR}/contrib/Catch.cmake")
catch_discover_tests(input-test)
Loading