diff --git a/CMakeLists.txt b/CMakeLists.txt index 79aa279ea..debac47e5 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 000000000..fc1191739 --- /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