[CMake] add the search paths for the build executables automatically for ctest.; depend completly on the external catch2
This commit is contained in:
parent
a73d2f7d94
commit
05c2278893
1 changed files with 32 additions and 20 deletions
|
@ -4,7 +4,6 @@ find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options)
|
||||||
find_package(PostgreSQL REQUIRED)
|
find_package(PostgreSQL REQUIRED)
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
include(CopyDllsForDebug)
|
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
Catch2
|
Catch2
|
||||||
|
@ -12,18 +11,12 @@ FetchContent_Declare(
|
||||||
GIT_TAG v2.13.7)
|
GIT_TAG v2.13.7)
|
||||||
FetchContent_MakeAvailable(Catch2)
|
FetchContent_MakeAvailable(Catch2)
|
||||||
|
|
||||||
# Prepare "Catch" library for other executables
|
|
||||||
set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
add_library(Catch INTERFACE)
|
|
||||||
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
|
|
||||||
|
|
||||||
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19.0")
|
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.19.0")
|
||||||
# for cmake 3.19+ https://cmake.org/cmake/help/git-stage/policy/CMP0110.html
|
# for cmake 3.19+ https://cmake.org/cmake/help/git-stage/policy/CMP0110.html
|
||||||
# might not be needed if catch updates its cmakes
|
# might not be needed if catch updates its cmakes
|
||||||
cmake_policy(SET CMP0110 OLD)
|
cmake_policy(SET CMP0110 OLD)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
add_executable(mapnik-test-unit
|
add_executable(mapnik-test-unit
|
||||||
unit/run.cpp
|
unit/run.cpp
|
||||||
unit/color/css_color.cpp
|
unit/color/css_color.cpp
|
||||||
|
@ -108,45 +101,53 @@ add_executable(mapnik-test-unit
|
||||||
unit/vertex_adapter/vertex_adapter.cpp
|
unit/vertex_adapter/vertex_adapter.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(mapnik-test-unit PUBLIC
|
target_link_libraries(mapnik-test-unit PUBLIC
|
||||||
Catch
|
Catch2::Catch2
|
||||||
mapnik::agg
|
mapnik::agg
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
mapnik::json
|
mapnik::json
|
||||||
mapnik::wkt
|
mapnik::wkt
|
||||||
PostgreSQL::PostgreSQL
|
PostgreSQL::PostgreSQL
|
||||||
)
|
)
|
||||||
|
# workaround since the "offical" include dir would be <catch2/catch.hpp>
|
||||||
|
file(COPY_FILE catch_ext.hpp "${CMAKE_CURRENT_BINARY_DIR}/catch_ext.hpp")
|
||||||
|
file(COPY_FILE cleanup.hpp "${CMAKE_CURRENT_BINARY_DIR}/cleanup.hpp")
|
||||||
|
target_include_directories(mapnik-test-unit PRIVATE "${catch2_SOURCE_DIR}/single_include/catch2" ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
|
||||||
add_executable(agg_rasterizer_integer_overflow_test standalone/agg_rasterizer_integer_overflow_test.cpp)
|
add_executable(agg_rasterizer_integer_overflow_test standalone/agg_rasterizer_integer_overflow_test.cpp)
|
||||||
target_link_libraries(agg_rasterizer_integer_overflow_test PUBLIC
|
target_link_libraries(agg_rasterizer_integer_overflow_test PUBLIC
|
||||||
Catch
|
Catch2::Catch2
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
mapnik::agg
|
mapnik::agg
|
||||||
mapnik::json
|
mapnik::json
|
||||||
)
|
)
|
||||||
|
target_include_directories(agg_rasterizer_integer_overflow_test PRIVATE "${catch2_SOURCE_DIR}/single_include/catch2" ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_executable(datasource_registration_test standalone/datasource_registration_test.cpp)
|
add_executable(datasource_registration_test standalone/datasource_registration_test.cpp)
|
||||||
target_link_libraries(datasource_registration_test PUBLIC
|
target_link_libraries(datasource_registration_test PUBLIC
|
||||||
Catch
|
Catch2::Catch2
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
mapnik::agg
|
mapnik::agg
|
||||||
)
|
)
|
||||||
|
target_include_directories(datasource_registration_test PRIVATE "${catch2_SOURCE_DIR}/single_include/catch2" ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_executable(font_registration_test standalone/font_registration_test.cpp)
|
add_executable(font_registration_test standalone/font_registration_test.cpp)
|
||||||
target_link_libraries(font_registration_test PUBLIC
|
target_link_libraries(font_registration_test PUBLIC
|
||||||
Catch
|
Catch2::Catch2
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
mapnik::agg
|
mapnik::agg
|
||||||
mapnik::json
|
mapnik::json
|
||||||
)
|
)
|
||||||
|
target_include_directories(font_registration_test PRIVATE "${catch2_SOURCE_DIR}/single_include/catch2" ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
#not workable since boost::filesystem native returns a wstring and the function taskes a std::string
|
#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)
|
add_executable(map_xml_test standalone/map_xml_test.cpp)
|
||||||
target_link_libraries(map_xml_test PUBLIC
|
target_link_libraries(map_xml_test PUBLIC
|
||||||
Catch
|
Catch2::Catch2
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
mapnik::agg
|
mapnik::agg
|
||||||
mapnik::json
|
mapnik::json
|
||||||
)
|
)
|
||||||
|
target_include_directories(map_xml_test PRIVATE "${catch2_SOURCE_DIR}/single_include/catch2" ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_executable(mapnik-test-visual
|
add_executable(mapnik-test-visual
|
||||||
visual/parse_map_sizes.cpp
|
visual/parse_map_sizes.cpp
|
||||||
|
@ -154,18 +155,18 @@ add_executable(mapnik-test-visual
|
||||||
visual/runner.cpp
|
visual/runner.cpp
|
||||||
visual/run.cpp
|
visual/run.cpp
|
||||||
)
|
)
|
||||||
target_link_libraries(
|
target_link_libraries(mapnik-test-visual PRIVATE
|
||||||
mapnik-test-visual PRIVATE
|
Catch2::Catch2
|
||||||
Catch
|
|
||||||
Boost::program_options
|
Boost::program_options
|
||||||
Boost::filesystem
|
Boost::filesystem
|
||||||
mapnik::mapnik
|
mapnik::mapnik
|
||||||
mapnik::agg
|
mapnik::agg
|
||||||
)
|
)
|
||||||
|
target_include_directories(mapnik-test-visual PRIVATE "${catch2_SOURCE_DIR}/single_include/catch2" ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
include(${catch2_SOURCE_DIR}/contrib/Catch.cmake)
|
include("${catch2_SOURCE_DIR}/contrib/Catch.cmake")
|
||||||
include(${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake)
|
include("${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake")
|
||||||
|
|
||||||
# use only mapnik-test-unit since it has the same build path
|
# use only mapnik-test-unit since it has the same build path
|
||||||
mapnik_copy_plugins(
|
mapnik_copy_plugins(
|
||||||
|
@ -184,10 +185,21 @@ mapnik_copy_dependencies(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test)
|
file(COPY data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/test")
|
||||||
file(COPY data-visual DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test)
|
file(COPY data-visual DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/test")
|
||||||
|
file(COPY "${mapnik_SOURCE_DIR}/demo/data" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/demo")
|
||||||
|
add_dependencies(mapnik-test-unit mapnik-index shapeindex)
|
||||||
|
if(WIN32)
|
||||||
|
catch_discover_tests(mapnik-test-unit
|
||||||
|
PROPERTIES ENVIRONMENT "PATH=\$<JOIN:\$<SHELL_PATH:$<TARGET_FILE_DIR:mapnik-index>;$<TARGET_FILE_DIR:shapeindex>;$ENV{PATH}>,\\\\\\\\\;>"
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
catch_discover_tests(mapnik-test-unit PROPERTIES
|
||||||
|
ENVIRONMENT "DYLD_LIBRARY_PATH=$<SHELL_PATH:$<TARGET_FILE_DIR:shapeindex>;$<TARGET_FILE_DIR:mapnik-index>;$ENV{DYLD_LIBRARY_PATH}>"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
catch_discover_tests(mapnik-test-unit)
|
|
||||||
catch_discover_tests(agg_rasterizer_integer_overflow_test)
|
catch_discover_tests(agg_rasterizer_integer_overflow_test)
|
||||||
catch_discover_tests(datasource_registration_test)
|
catch_discover_tests(datasource_registration_test)
|
||||||
catch_discover_tests(font_registration_test)
|
catch_discover_tests(font_registration_test)
|
||||||
|
|
Loading…
Reference in a new issue