add initial test support

This commit is contained in:
Mathis Logemann 2020-11-21 13:20:04 +01:00
parent 9a132080b5
commit f447cad781
2 changed files with 37 additions and 1 deletions

View file

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

31
test/CMakeLists.txt Normal file
View file

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