[CMake] move all build artifacts into same dir to remove the need of copy_dlls (except for plugins)

[CMake] improve BUILD_TESTING and use pkgconf for cairo on linux

[CMake] add Threads dependency to -Config
This commit is contained in:
Mathis Logemann 2021-10-25 18:58:55 +02:00
parent 4eb38c1051
commit f0940c2075
31 changed files with 188 additions and 185 deletions

View file

@ -21,8 +21,8 @@ include(FeatureSummary)
include(MapnikOption)
include(MapnikMinimumVersions)
include(MapnikFindPackage)
include(MapnikCopyDependencies)
include(MapnikInstall)
include(CTest)
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")
mapnik_option(COPY_LIBRARIES_FOR_EXECUTABLES "copies required shared libaries (only windows) to the executable build directory" OFF)
@ -30,7 +30,7 @@ mapnik_option(COPY_FONTS_AND_PLUGINS_FOR_EXECUTABLES "copies required plugins an
mapnik_option(INSTALL_DEPENDENCIES "if ON, all dependencies (eg. required dlls) will be copied into CMAKE_INSTALL_PREFIX/MAPNIK_BIN_DIR." ON)
mapnik_option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON)
mapnik_option(BUILD_TEST "builds the tests" ON)
add_feature_info(BUILD_TESTING BUILD_TESTING "Adds tests")
mapnik_option(USE_EXTERNAL_MAPBOX_GEOMETRY "Use a external mapnik/geometry.hpp. If off, use the submodule" OFF)
mapnik_option(USE_EXTERNAL_MAPBOX_POLYLABEL "Use a external mapnik/polylabel. If off, use the submodule" OFF)
mapnik_option(USE_EXTERNAL_MAPBOX_PROTOZERO "Use a external mapnik/protozero. If off, use the submodule" OFF)
@ -109,7 +109,7 @@ set(MAPNIK_ARCHIVE_DIR ${CMAKE_INSTALL_LIBDIR} CACHE STRING "Install directory f
set(MAPNIK_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE STRING "Install directory for the headers")
set(MAPNIK_CMAKE_DIR ${MAPNIK_LIB_DIR}/cmake/mapnik CACHE STRING "Install directory of the cmake targets")
set(MAPNIK_PKGCONF_DIR ${MAPNIK_LIB_DIR}/pkgconfig CACHE STRING "Install directory for the .pc files for pkg-config")
set(MAPNIK_OUTPUT_DIR "${CMAKE_BINARY_DIR}/out")
if(WIN32)
set(DEFAULT_PLUGINS_INSTALL_DIR ${MAPNIK_BIN_DIR}/mapnik/input)
else()
@ -296,9 +296,14 @@ if(USE_WEBP)
endif()
if(USE_CAIRO)
mapnik_find_package(Cairo REQUIRED)
if(WIN32)
mapnik_find_package(Cairo REQUIRED)
list(APPEND MAPNIK_OPTIONAL_LIBS Cairo::Cairo)
else()
pkg_check_modules(Cairo REQUIRED IMPORTED_TARGET cairo)
list(APPEND MAPNIK_OPTIONAL_LIBS PkgConfig::Cairo)
endif()
list(APPEND MAPNIK_COMPILE_DEFS HAVE_CAIRO)
list(APPEND MAPNIK_OPTIONAL_LIBS Cairo::Cairo)
endif()
if(USE_PROJ)
@ -372,10 +377,10 @@ add_subdirectory(demo)
if(BUILD_BENCHMARK)
add_subdirectory(benchmark)
endif()
if(BUILD_TEST)
enable_testing()
if(BUILD_TESTING)
add_subdirectory(test)
endif()
file(COPY fonts DESTINATION "${MAPNIK_OUTPUT_DIR}")
feature_summary(FILENAME "${CMAKE_CURRENT_BINARY_DIR}/packages.log" WHAT PACKAGES_FOUND PACKAGES_NOT_FOUND INCLUDE_QUIET_PACKAGES)

View file

@ -32,24 +32,13 @@ function(mapnik_create_benchmark)
add_executable(${TARGET_NAME} ${ARGV0})
target_include_directories(${TARGET_NAME} PRIVATE include)
target_link_libraries(${TARGET_NAME} PRIVATE mapnik::agg mapnik::mapnik)
mapnik_copy_dependencies(TARGETS ${TARGET_NAME})
set_target_properties(${TARGET_NAME} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
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
)

View file

@ -1,38 +0,0 @@
# 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)
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)
set(options)
set(oneValueArgs)
set(multiValueArgs TARGETS LIBS DIRS)
cmake_parse_arguments(MAPNIK_COPY_DLLS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(WIN32)
foreach(_target IN LISTS MAPNIK_COPY_DLLS_TARGETS)
add_custom_command(
TARGET ${_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -DRUN_IT:BOOL=ON -DTO_FIXUP_FILE="$<TARGET_FILE:${_target}>" -DTO_FIXUP_LIBS:STRING="${MAPNIK_COPY_DLLS_LIBS}" -DTO_FIXUP_DIRS="${MAPNIK_COPY_DLLS_DIRS}" -P "${THIS_FILE}"
COMMENT "Fixing up dependencies for ${_target}"
)
endforeach()
endif(WIN32)
endfunction()
endif()

View file

@ -1,61 +0,0 @@
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 "$<TARGET_FILE:mapnik::mapnik>" ${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 "$<TARGET_FILE:${PLUGIN}>")
endif()
endforeach()
copy_dlls_for_debug(TARGETS ${MAPNIK_CP_DEPS_TARGETS} LIBS ${LIBS} DIRS ${ADDITIONAL_LIBARIES_PATHS})
endif()
endfunction()
function(mapnik_copy_plugins)
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 "$<TARGET_FILE:${PLUGIN}>" ${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)
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}/)
endif()
endfunction()

View file

@ -59,8 +59,6 @@ function(mapnik_install_utility _target)
set_property(GLOBAL APPEND PROPERTY MAPNIK_UTILITIES ${_target})
endfunction()
function(mapnik_install_targets)
if(INSTALL_DEPENDENCIES AND WIN32)
# https://cmake.org/cmake/help/latest/policy/CMP0087.html
@ -93,5 +91,4 @@ function(mapnik_install_targets)
fixup_bundle(\"${_internal_executables}\" \"${_internal_libraries}\" \"${ADDITIONAL_LIBARIES_PATHS}\")
" COMPONENT MapnikRuntime)
endif()
endfunction()

View file

@ -6,6 +6,8 @@ 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)
find_dependency(Threads REQUIRED)
@MAPNIK_DEPENDENCIES@
include("${CMAKE_CURRENT_LIST_DIR}/mapnikTargets.cmake")

View file

@ -1,9 +1,10 @@
project(mapnik-demo)
add_executable(mapnik-demo rundemo.cpp)
set_target_properties(mapnik-demo PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(mapnik-demo PRIVATE mapnik::agg mapnik::mapnik)
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)

View file

@ -42,6 +42,9 @@ set_target_properties(mapnik-viewer PROPERTIES
AUTORCC ON
AUTOUIC ON
AUTOMOC ON
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(mapnik-viewer PRIVATE
@ -62,17 +65,3 @@ endif()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini DESTINATION bin)
mapnik_install_utility(mapnik-viewer)
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
)
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
)

View file

@ -1,36 +1,71 @@
set(_plugin_prefix "")
set(_plugin_suffix ".input")
# add a list with all build plugins so the copy dependencies command can wait for all build events
set(m_build_plugins "")
if(USE_PLUGIN_INPUT_CSV)
add_subdirectory(csv)
list(APPEND m_build_plugins input-csv)
endif()
if(USE_PLUGIN_INPUT_GDAL)
add_subdirectory(gdal)
list(APPEND m_build_plugins input-gdal)
endif()
if(USE_PLUGIN_INPUT_GEOBUF)
add_subdirectory(geobuf)
list(APPEND m_build_plugins input-geobuf)
endif()
if(USE_PLUGIN_INPUT_GEOJSON)
add_subdirectory(geojson)
list(APPEND m_build_plugins input-geojson)
endif()
if(USE_PLUGIN_INPUT_OGR)
add_subdirectory(ogr)
list(APPEND m_build_plugins input-ogr)
endif()
if(USE_PLUGIN_INPUT_PGRASTER)
add_subdirectory(pgraster)
list(APPEND m_build_plugins input-pgraster)
endif()
if(USE_PLUGIN_INPUT_POSTGIS)
add_subdirectory(postgis)
list(APPEND m_build_plugins input-postgis)
endif()
if(USE_PLUGIN_INPUT_RASTER)
add_subdirectory(raster)
list(APPEND m_build_plugins input-raster)
endif()
if(USE_PLUGIN_INPUT_SHAPE)
add_subdirectory(shape)
list(APPEND m_build_plugins input-shape)
endif()
if(USE_PLUGIN_INPUT_SQLITE)
add_subdirectory(sqlite)
list(APPEND m_build_plugins input-sqlite)
endif()
if(USE_PLUGIN_INPUT_TOPOJSON)
add_subdirectory(topojson)
list(APPEND m_build_plugins input-topojson)
endif()
#
# Copy all plugin dlls, so that these are in the main output dir, since cmake copies those into ${MAPNIK_OUTPUT_DIR}/plugins/input, too.
#
if(WIN32)
string(CONFIGURE
[[
file(GLOB m_deps "./*.dll")
message(STATUS "plugin deps: ${m_deps}")
file(COPY ${m_deps} DESTINATION "@MAPNIK_OUTPUT_DIR@")
]] m_copy_dlls_str @ONLY
)
file (GENERATE OUTPUT "copy_dlls_$<CONFIG>.cmake"
CONTENT "${m_copy_dlls_str}"
)
add_custom_target(copy_plugin_dependencies ALL
COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/copy_dlls_$<CONFIG>.cmake"
WORKING_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
COMMENT "copying plugin dlls into build dir"
)
add_dependencies(copy_plugin_dependencies ${m_build_plugins})
endif()

View file

@ -16,6 +16,8 @@ set_target_properties(input-csv PROPERTIES
OUTPUT_NAME "csv"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-csv)

View file

@ -15,6 +15,8 @@ set_target_properties(input-gdal PROPERTIES
OUTPUT_NAME "gdal"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-gdal)

View file

@ -9,6 +9,8 @@ set_target_properties(input-geobuf PROPERTIES
OUTPUT_NAME "geobuf"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-geobuf)

View file

@ -14,6 +14,8 @@ set_target_properties(input-geojson PROPERTIES
OUTPUT_NAME "geojson"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-geojson)

View file

@ -17,6 +17,8 @@ set_target_properties(input-ogr PROPERTIES
OUTPUT_NAME "ogr"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-ogr)

View file

@ -15,5 +15,8 @@ set_target_properties(input-pgraster PROPERTIES
OUTPUT_NAME "pgraster"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-pgraster)

View file

@ -14,6 +14,8 @@ set_target_properties(input-postgis PROPERTIES
OUTPUT_NAME "postgis"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-postgis)

View file

@ -10,6 +10,8 @@ set_target_properties(input-raster PROPERTIES
OUTPUT_NAME "raster"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-raster)

View file

@ -13,6 +13,8 @@ set_target_properties(input-shape PROPERTIES
OUTPUT_NAME "shape"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-shape)

View file

@ -15,6 +15,8 @@ set_target_properties(input-sqlite PROPERTIES
OUTPUT_NAME "sqlite"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-sqlite)

View file

@ -13,6 +13,8 @@ set_target_properties(input-topojson PROPERTIES
OUTPUT_NAME "topojson"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install_plugin(input-topojson)

View file

@ -19,6 +19,9 @@ set_target_properties(mapnik PROPERTIES
VERSION ${MAPNIK_VERSION}
# see https://github.com/mapnik/mapnik/pull/4248#issuecomment-925596509 => ABI compability only with the full version
SOVERSION ${MAPNIK_VERSION}
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
if(MSVC)

View file

@ -33,6 +33,9 @@ set_target_properties(json PROPERTIES
VERSION ${MAPNIK_VERSION}
# see mapnik target for explanation
SOVERSION ${MAPNIK_VERSION}
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install(json)

View file

@ -25,6 +25,9 @@ set_target_properties(wkt PROPERTIES
VERSION ${MAPNIK_VERSION}
# see mapnik target for explanation
SOVERSION ${MAPNIK_VERSION}
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
mapnik_install(wkt)

View file

@ -100,6 +100,11 @@ add_executable(mapnik-test-unit
unit/vertex_adapter/transform_path_adapter.cpp
unit/vertex_adapter/vertex_adapter.cpp
)
set_target_properties(mapnik-test-unit PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(mapnik-test-unit PUBLIC
Catch2::Catch2
mapnik::agg
@ -114,6 +119,11 @@ file(COPY cleanup.hpp DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
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)
set_target_properties(agg_rasterizer_integer_overflow_test PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(agg_rasterizer_integer_overflow_test PUBLIC
Catch2::Catch2
mapnik::mapnik
@ -123,6 +133,11 @@ target_link_libraries(agg_rasterizer_integer_overflow_test PUBLIC
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)
set_target_properties(datasource_registration_test PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(datasource_registration_test PUBLIC
Catch2::Catch2
mapnik::mapnik
@ -131,6 +146,11 @@ target_link_libraries(datasource_registration_test PUBLIC
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)
set_target_properties(font_registration_test PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(font_registration_test PUBLIC
Catch2::Catch2
mapnik::mapnik
@ -141,6 +161,11 @@ target_include_directories(font_registration_test PRIVATE "${catch2_SOURCE_DIR}/
#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)
set_target_properties(map_xml_test PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(map_xml_test PUBLIC
Catch2::Catch2
mapnik::mapnik
@ -155,6 +180,11 @@ add_executable(mapnik-test-visual
visual/runner.cpp
visual/run.cpp
)
set_target_properties(mapnik-test-visual PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
ARCHIVE_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}/lib"
)
target_link_libraries(mapnik-test-visual PRIVATE
Catch2::Catch2
Boost::program_options
@ -168,40 +198,34 @@ include(CTest)
include("${catch2_SOURCE_DIR}/contrib/Catch.cmake")
include("${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake")
# 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")
file(COPY unit/data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/test/unit")
file(COPY "${mapnik_SOURCE_DIR}/demo/data" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/demo")
file(COPY data DESTINATION "${MAPNIK_OUTPUT_DIR}/test")
file(COPY data-visual DESTINATION "${MAPNIK_OUTPUT_DIR}/test")
file(COPY unit/data DESTINATION "${MAPNIK_OUTPUT_DIR}/test/unit")
file(COPY "${mapnik_SOURCE_DIR}/demo/data" DESTINATION "${MAPNIK_OUTPUT_DIR}/demo")
add_dependencies(mapnik-test-unit mapnik-index shapeindex)
set(m_proj_test_env "")
if(DEFINED PROJ_LIB)
set(m_proj_test_env "PROJ_LIB=${PROJ_LIB}")
elseif(DEFINED ENV{PROJ_LIB})
set(m_proj_test_env "PROJ_LIB=$ENV{PROJ_LIB}")
endif()
message(STATUS "using proj lib for unit tests: ${m_proj_test_env}")
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}>,\\\\\\\\\;>"
)
set(m_test_path "\$<JOIN:\$<SHELL_PATH:$<TARGET_FILE_DIR:mapnik-index>;$<TARGET_FILE_DIR:shapeindex>;$ENV{PATH}>,\\\\\\\\\;>")
else()
catch_discover_tests(mapnik-test-unit PROPERTIES
ENVIRONMENT "PATH=$<SHELL_PATH:$<TARGET_FILE_DIR:shapeindex>;$<TARGET_FILE_DIR:mapnik-index>;$ENV{PATH}>"
)
set(m_test_path "$<SHELL_PATH:$<TARGET_FILE_DIR:shapeindex>;$<TARGET_FILE_DIR:mapnik-index>;$ENV{PATH}>")
endif()
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)
catch_discover_tests(mapnik-test-unit
WORKING_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
PROPERTIES
ENVIRONMENT
"PATH=${m_test_path}"
${m_proj_test_env}
)
catch_discover_tests(agg_rasterizer_integer_overflow_test WORKING_DIRECTORY "${MAPNIK_OUTPUT_DIR}")
catch_discover_tests(datasource_registration_test WORKING_DIRECTORY "${MAPNIK_OUTPUT_DIR}")
catch_discover_tests(font_registration_test WORKING_DIRECTORY "${MAPNIK_OUTPUT_DIR}")
catch_discover_tests(map_xml_test WORKING_DIRECTORY "${MAPNIK_OUTPUT_DIR}")

View file

@ -4,4 +4,8 @@ add_executable(geometry_to_wkb main.cpp)
target_link_libraries(geometry_to_wkb PRIVATE mapnik::mapnik)
set_target_properties(geometry_to_wkb PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)
mapnik_install_utility(geometry_to_wkb)

View file

@ -15,4 +15,8 @@ target_link_libraries(mapnik-index PRIVATE
Boost::program_options
)
set_target_properties(mapnik-index PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)
mapnik_install_utility(mapnik-index)

View file

@ -9,4 +9,8 @@ target_link_libraries(mapnik-render PRIVATE
Boost::program_options
)
set_target_properties(mapnik-render PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)
mapnik_install_utility(mapnik-render)

View file

@ -4,4 +4,8 @@ add_executable(ogrindex ogrindex.cpp)
target_link_libraries(ogrindex PRIVATE mapnik::mapnik)
set_target_properties(ogrindex PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)
mapnik_install_utility(ogrindex)

View file

@ -16,4 +16,8 @@ target_link_libraries(pgsql2sqlite PRIVATE
mapnik::mapnik
)
set_target_properties(pgsql2sqlite PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)
mapnik_install_utility(pgsql2sqlite)

View file

@ -12,4 +12,8 @@ target_link_libraries(shapeindex PRIVATE
mapnik::mapnik
)
set_target_properties(shapeindex PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)
mapnik_install_utility(shapeindex)

View file

@ -12,4 +12,8 @@ target_link_libraries(svg2png PRIVATE
mapnik::agg
)
set_target_properties(svg2png PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)
mapnik_install_utility(svg2png)