Merge pull request #4266 from mathisloge/cmake_improvments

[CMake] improve build structure
This commit is contained in:
Artem Pavlenko 2021-11-15 14:21:13 +00:00 committed by GitHub
commit 14f913d6ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
33 changed files with 214 additions and 246 deletions

View file

@ -21,16 +21,14 @@ include(FeatureSummary)
include(MapnikOption)
include(MapnikMinimumVersions)
include(MapnikFindPackage)
include(MapnikCopyDependencies)
include(MapnikInstall)
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)
mapnik_option(COPY_FONTS_AND_PLUGINS_FOR_EXECUTABLES "copies required plugins and fonts into the executable build directory" ON)
include(CTest)
add_feature_info(BUILD_TESTING BUILD_TESTING "Adds tests")
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)
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 +107,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 +294,14 @@ if(USE_WEBP)
endif()
if(USE_CAIRO)
if(WIN32)
mapnik_find_package(Cairo REQUIRED)
list(APPEND MAPNIK_COMPILE_DEFS HAVE_CAIRO)
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)
endif()
if(USE_PROJ)
@ -372,10 +375,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

@ -150,7 +150,7 @@
}
},
{
"name": "windows-default-debug",
"name": "windows-debug",
"displayName": "Windows x64 Debug",
"inherits": [
"windows-default",
@ -158,7 +158,7 @@
]
},
{
"name": "windows-default-release",
"name": "windows-release",
"displayName": "Windows x64 Release",
"inherits": [
"windows-default",
@ -168,12 +168,28 @@
],
"buildPresets": [
{
"name": "windows-default",
"configurePreset": "windows-default-debug"
"name": "windows-debug",
"configurePreset": "windows-debug"
},
{
"name": "linux-default",
"name": "windows-release",
"configurePreset": "windows-release"
},
{
"name": "linux-clang-debug",
"configurePreset": "linux-clang-debug"
},
{
"name": "linux-clang-release",
"configurePreset": "linux-clang-release"
},
{
"name": "linux-gcc-debug",
"configurePreset": "linux-gcc-debug"
},
{
"name": "linux-gcc-release",
"configurePreset": "linux-gcc-release"
}
]
}

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,8 @@
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

@ -1,5 +1,3 @@
project(mapnik-viewer)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
@ -42,6 +40,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 +63,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

@ -13,9 +13,9 @@ Make sure that all dependencies are installed.
All available cmake options are listed at the top of [CMakeLists.txt](../CMakeLists.txt).
Pass your options while configuring e.g.: `cmake -DBUILD_DEMO_VIEWER=OFF ..` to disable the build of the demo viewer application.
To quickstart open a console in the root mapnik dir and execute the following commands: (Pass all options and dependency dirs after `-DBUILD_TEST=OFF`)
To quickstart open a console in the root mapnik dir and execute the following commands: (Pass all options and dependency dirs after `-DBUILD_TESTING=OFF`)
```
> cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TEST=OFF
> cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=OFF
> cmake --build build --target install
```
@ -64,20 +64,19 @@ This could look like this:
},
"configurePresets": [
{
"name": "vcpkg-x64-win-debug",
"inherits": "windows-default-debug",
"name": "vcpkg",
"hidden": true,
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "<path-to-vcpkg>/scripts/buildsystems/vcpkg.cmake",
"ADDITIONAL_LIBARIES_PATHS":"<path-to-vcpkg>/installed/x64-windows/debug/bin"
"CMAKE_TOOLCHAIN_FILE": "<path-to-vcpkg>/scripts/buildsystems/vcpkg.cmake"
}
}
{
"name": "vcpkg-x64-win-debug",
"inherits": ["vcpkg", "windows-default-debug"]
},
{
"name": "vcpkg-x64-win-release",
"inherits": "windows-default-release",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "<path-to-vcpkg>/scripts/buildsystems/vcpkg.cmake",
"ADDITIONAL_LIBARIES_PATHS":"<path-to-vcpkg>/installed/x64-windows/bin"
}
"inherits": ["vcpkg", "windows-default-release"]
}
]
}

View file

@ -1,36 +1,74 @@
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)
list(LENGTH m_build_plugins m_number_plugins)
if(m_number_plugins GREATER 0)
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()
endif()

View file

@ -1,5 +1,3 @@
project(input-csv)
add_library(input-csv MODULE
csv_datasource.cpp
csv_featureset.cpp
@ -16,6 +14,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

@ -1,5 +1,3 @@
project(input-gdal)
find_package(GDAL REQUIRED)
add_library(input-gdal MODULE
@ -15,6 +13,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

@ -1,5 +1,3 @@
project(input-geobuf)
add_library(input-geobuf MODULE
geobuf_datasource.cpp
geobuf_featureset.cpp
@ -9,6 +7,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

@ -1,5 +1,3 @@
project(input-geojson)
add_library(input-geojson MODULE
geojson_datasource.cpp
geojson_featureset.cpp
@ -14,6 +12,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

@ -1,5 +1,3 @@
project(input-ogr)
find_package(GDAL REQUIRED)
add_library(input-ogr MODULE
@ -17,6 +15,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

@ -1,5 +1,3 @@
project(input-pgraster)
find_package(PostgreSQL REQUIRED)
add_library(input-pgraster MODULE
@ -15,5 +13,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

@ -1,5 +1,3 @@
project(input-postgis)
find_package(PostgreSQL REQUIRED)
add_library(input-postgis MODULE
@ -14,6 +12,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

@ -1,5 +1,3 @@
project(input-raster)
add_library(input-raster MODULE
raster_datasource.cpp
raster_featureset.cpp
@ -10,6 +8,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

@ -1,5 +1,3 @@
project(input-shape)
add_library(input-shape MODULE
dbfile.cpp
dbf_test.cpp
@ -13,6 +11,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

@ -1,5 +1,3 @@
project(input-sqlite)
find_package(SQLite3 REQUIRED)
add_library(input-sqlite MODULE
@ -15,6 +13,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

@ -1,5 +1,3 @@
project(input-topojson)
add_library(input-topojson MODULE
topojson_datasource.cpp
topojson_featureset.cpp
@ -13,6 +11,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

@ -1,5 +1,3 @@
project(mapnik-test)
find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options)
find_package(PostgreSQL REQUIRED)
@ -100,6 +98,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 +117,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 +131,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 +144,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 +159,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 +178,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
@ -164,44 +192,28 @@ target_link_libraries(mapnik-test-visual PRIVATE
)
target_include_directories(mapnik-test-visual PRIVATE "${catch2_SOURCE_DIR}/single_include/catch2" ${CMAKE_CURRENT_BINARY_DIR})
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)
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}"
)
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

@ -1,7 +1,9 @@
project(geometry_to_wkb)
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

@ -1,5 +1,3 @@
project(mapnik-index)
find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options)
add_executable(mapnik-index
@ -15,4 +13,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

@ -1,5 +1,3 @@
project(mapnik-render)
find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options)
add_executable(mapnik-render mapnik-render.cpp)
@ -9,4 +7,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

@ -1,7 +1,9 @@
project(ogrindex)
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

@ -1,4 +1,3 @@
project(pgsql2sqlite)
find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options)
find_package(SQLite3 REQUIRED)
find_package(PostgreSQL REQUIRED)
@ -16,4 +15,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

@ -1,5 +1,3 @@
project(shapeindex)
find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options)
add_executable(shapeindex
@ -12,4 +10,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

@ -1,5 +1,3 @@
project(svg2png)
find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options)
add_executable(svg2png
@ -12,4 +10,8 @@ target_link_libraries(svg2png PRIVATE
mapnik::agg
)
set_target_properties(svg2png PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}"
)
mapnik_install_utility(svg2png)