install dependencies. Required for windows (and ?macos?). Needs testing on linux.

This commit is contained in:
Mathis Logemann 2021-04-10 14:36:22 +02:00
parent 1929fbc0ba
commit e1fa32f21f
26 changed files with 113 additions and 101 deletions

View file

@ -17,10 +17,12 @@ message(STATUS "mapnik version: ${PROJECT_VERSION}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(MapnikFindPackage) include(MapnikFindPackage)
include(MapnikCopyDependencies) 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") 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")
option(COPY_LIBRARIES_FOR_EXECUTABLES "copies required shared libaries (only windows) to the executable build directory" ON) option(COPY_LIBRARIES_FOR_EXECUTABLES "copies required shared libaries (only windows) to the executable build directory" ON)
option(COPY_FONTS_AND_PLUGINS_FOR_EXECUTABLES "copies required plugins and fonts into the executable build directory" ON) option(COPY_FONTS_AND_PLUGINS_FOR_EXECUTABLES "copies required plugins and fonts into the executable build directory" ON)
option(INSTALL_DEPENDENCIES "if ON, all dependencies (eg. required dlls) will be copied into CMAKE_INSTALL_PREFIX/MAPNIK_BIN_DIR." ON)
option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON) option(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" ON)
option(BUILD_TEST "builds the tests" ON) option(BUILD_TEST "builds the tests" ON)
@ -177,6 +179,9 @@ endif()
set(MAPNIK_COMPILE_DEFS "") set(MAPNIK_COMPILE_DEFS "")
set(MAPNIK_OPTIONAL_LIBS "") set(MAPNIK_OPTIONAL_LIBS "")
set(MAPNIK_OPTIONAL_LIBS_INCLUDE "") set(MAPNIK_OPTIONAL_LIBS_INCLUDE "")
# (used by MapnikInstall.cmake. properties are needed since "set(...)" will be out of scope
set_property(GLOBAL PROPERTY TARGETS "")
set_property(GLOBAL PROPERTY PLUGINS "")
if(USE_BIGINT) if(USE_BIGINT)
message(STATUS "uses BIGINT") message(STATUS "uses BIGINT")
@ -331,3 +336,5 @@ install(EXPORT MapnikTargets
install(DIRECTORY include/ TYPE INCLUDE) install(DIRECTORY include/ TYPE INCLUDE)
install(DIRECTORY deps/agg/include/ TYPE INCLUDE) install(DIRECTORY deps/agg/include/ TYPE INCLUDE)
install(DIRECTORY fonts/ DESTINATION ${FONTS_INSTALL_DIR} FILES_MATCHING PATTERN "*.py" EXCLUDE PATTERN "*") install(DIRECTORY fonts/ DESTINATION ${FONTS_INSTALL_DIR} FILES_MATCHING PATTERN "*.py" EXCLUDE PATTERN "*")
mapnik_install_targets()

View file

@ -33,20 +33,23 @@ function(mapnik_create_benchmark)
target_include_directories(${TARGET_NAME} PRIVATE include) target_include_directories(${TARGET_NAME} PRIVATE include)
target_link_libraries(${TARGET_NAME} PRIVATE mapnik::core mapnik::agg mapnik::mapnik) target_link_libraries(${TARGET_NAME} PRIVATE mapnik::core mapnik::agg mapnik::mapnik)
# it might be possible that some buildsystems generate different directories. So invoke the scripts for all benchmarks mapnik_copy_dependencies(TARGETS ${TARGET_NAME})
mapnik_copy_plugins(TARGET ${TARGET_NAME}
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 ${TARGET_NAME} mapnik-test-unit DESTINATION fonts)
mapnik_copy_dependencies(TARGETS ${TARGET_NAME}
PLUGINS
input-csv input-gdal input-geobuf input-geojson input-ogr input-pgraster input-postgis input-raster input-shape input-sqlite input-topojson
)
endfunction() endfunction()
foreach(benchmark ${BENCHMARK_SRCS}) foreach(benchmark ${BENCHMARK_SRCS})
mapnik_create_benchmark(${benchmark}) mapnik_create_benchmark(${benchmark})
endforeach() 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
)

61
cmake/MapnikInstall.cmake Normal file
View file

@ -0,0 +1,61 @@
function(mapnik_install)
set(options ALREADY_INSTALLED IS_PLUGIN)
set(oneValueArgs TARGET)
set(multiValueArgs)
cmake_parse_arguments(MAPNIK_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT ${MAPNIK_INSTALL_ALREADY_INSTALLED} AND NOT ${MAPNIK_INSTALL_IS_PLUGIN})
install(TARGETS ${MAPNIK_INSTALL_TARGET}
LIBRARY DESTINATION ${MAPNIK_LIB_DIR}
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
)
elseif(NOT ${MAPNIK_INSTALL_ALREADY_INSTALLED} AND ${MAPNIK_INSTALL_IS_PLUGIN})
install(TARGETS ${MAPNIK_INSTALL_TARGET}
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
)
endif()
if(NOT ${MAPNIK_INSTALL_IS_PLUGIN})
message(STATUS "${MAPNIK_INSTALL_TARGET}")
get_target_property(TARGET_TYPE "${MAPNIK_INSTALL_TARGET}" TYPE)
if (TARGET_TYPE STREQUAL "EXECUTABLE")
get_property(MAPNIK_INSTALLED_TARGETS GLOBAL PROPERTY TARGETS)
list(APPEND MAPNIK_INSTALLED_TARGETS ${MAPNIK_INSTALL_TARGET})
set_property(GLOBAL PROPERTY TARGETS ${MAPNIK_INSTALLED_TARGETS})
endif()
else()
get_property(MAPNIK_INSTALLED_PLUGINS GLOBAL PROPERTY PLUGINS)
list(APPEND MAPNIK_INSTALLED_PLUGINS ${MAPNIK_INSTALL_TARGET})
set_property(GLOBAL PROPERTY PLUGINS ${MAPNIK_INSTALLED_PLUGINS})
endif()
endfunction()
function(mapnik_install_targets)
if(INSTALL_DEPENDENCIES)
# https://cmake.org/cmake/help/latest/policy/CMP0087.html
cmake_policy(SET CMP0087 NEW)
get_property(MAPNIK_INSTALLED_TARGETS GLOBAL PROPERTY TARGETS)
get_property(MAPNIK_INSTALLED_PLUGINS GLOBAL PROPERTY PLUGINS)
set(INTERNAL_TARGETS "")
set(INTERNAL_PLUGINS "")
foreach(_target IN LISTS MAPNIK_INSTALLED_TARGETS)
list(APPEND INTERNAL_TARGETS "${CMAKE_INSTALL_PREFIX}/${MAPNIK_BIN_DIR}/$<TARGET_FILE_NAME:${_target}>")
endforeach()
foreach(_target IN LISTS MAPNIK_INSTALLED_PLUGINS)
list(APPEND INTERNAL_PLUGINS "${CMAKE_INSTALL_PREFIX}/${PLUGINS_INSTALL_DIR}/$<TARGET_FILE_NAME:${_target}>")
endforeach()
# all other executables get auto detected and fixed.
list(GET INTERNAL_TARGETS 0 INTERNAL_TARGETS)
INSTALL(CODE "
message(STATUS \"${INTERNAL_TARGETS}\")
message(STATUS \"${INTERNAL_PLUGINS}\")
include(BundleUtilities)
fixup_bundle(\"${INTERNAL_TARGETS}\" \"${INTERNAL_PLUGINS}\" \"${ADDITIONAL_LIBARIES_PATHS}\")
" COMPONENT Runtime)
endif()
endfunction()

View file

@ -4,12 +4,7 @@ add_executable(mapnik-demo rundemo.cpp)
target_link_libraries(mapnik-demo PRIVATE mapnik::core mapnik::agg mapnik::mapnik) target_link_libraries(mapnik-demo PRIVATE mapnik::core mapnik::agg mapnik::mapnik)
install(TARGETS mapnik-demo mapnik_install(TARGET mapnik-demo)
LIBRARY DESTINATION ${MAPNIK_LIB_DIR}
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
)
mapnik_copy_plugins(TARGET mapnik-demo DESTINATION plugins/input PLUGINS input-shape) mapnik_copy_plugins(TARGET mapnik-demo DESTINATION plugins/input PLUGINS input-shape)
mapnik_require_fonts(TARGET mapnik-demo DESTINATION fonts) mapnik_require_fonts(TARGET mapnik-demo DESTINATION fonts)
mapnik_copy_dependencies(TARGETS mapnik-demo PLUGINS input-shape) mapnik_copy_dependencies(TARGETS mapnik-demo PLUGINS input-shape)

View file

@ -39,11 +39,7 @@ plugins_dir=${PLUGINS_INSTALL_DIR}
fonts/1/dir=${FONTS_INSTALL_DIR}" fonts/1/dir=${FONTS_INSTALL_DIR}"
) )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini DESTINATION bin) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini DESTINATION bin)
install(TARGETS mapnik-viewer mapnik_install(TARGET mapnik-viewer)
LIBRARY DESTINATION ${MAPNIK_LIB_DIR}
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
)
mapnik_copy_dependencies( mapnik_copy_dependencies(
TARGETS TARGETS

View file

@ -23,3 +23,5 @@ set_target_properties(input-csv PROPERTIES SUFFIX ".input")
install(TARGETS input-csv install(TARGETS input-csv
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
) )
mapnik_install(TARGET input-csv IS_PLUGIN)

View file

@ -18,6 +18,4 @@ set_target_properties(input-gdal PROPERTIES PREFIX "")
set_target_properties(input-gdal PROPERTIES OUTPUT_NAME "gdal") set_target_properties(input-gdal PROPERTIES OUTPUT_NAME "gdal")
set_target_properties(input-gdal PROPERTIES SUFFIX ".input") set_target_properties(input-gdal PROPERTIES SUFFIX ".input")
install(TARGETS input-gdal mapnik_install(TARGET input-gdal IS_PLUGIN)
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
)

View file

@ -14,6 +14,4 @@ set_target_properties(input-geobuf PROPERTIES PREFIX "")
set_target_properties(input-geobuf PROPERTIES OUTPUT_NAME "geobuf") set_target_properties(input-geobuf PROPERTIES OUTPUT_NAME "geobuf")
set_target_properties(input-geobuf PROPERTIES SUFFIX ".input") set_target_properties(input-geobuf PROPERTIES SUFFIX ".input")
install(TARGETS input-geobuf mapnik_install(TARGET input-geobuf IS_PLUGIN)
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
)

View file

@ -18,6 +18,4 @@ set_target_properties(input-geojson PROPERTIES PREFIX "")
set_target_properties(input-geojson PROPERTIES OUTPUT_NAME "geojson") set_target_properties(input-geojson PROPERTIES OUTPUT_NAME "geojson")
set_target_properties(input-geojson PROPERTIES SUFFIX ".input") set_target_properties(input-geojson PROPERTIES SUFFIX ".input")
install(TARGETS input-geojson mapnik_install(TARGET input-geojson IS_PLUGIN)
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
)

View file

@ -20,6 +20,4 @@ set_target_properties(input-ogr PROPERTIES PREFIX "")
set_target_properties(input-ogr PROPERTIES OUTPUT_NAME "ogr") set_target_properties(input-ogr PROPERTIES OUTPUT_NAME "ogr")
set_target_properties(input-ogr PROPERTIES SUFFIX ".input") set_target_properties(input-ogr PROPERTIES SUFFIX ".input")
install(TARGETS input-ogr mapnik_install(TARGET input-ogr IS_PLUGIN)
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
)

View file

@ -19,6 +19,4 @@ set_target_properties(input-pgraster PROPERTIES PREFIX "")
set_target_properties(input-pgraster PROPERTIES OUTPUT_NAME "pgraster") set_target_properties(input-pgraster PROPERTIES OUTPUT_NAME "pgraster")
set_target_properties(input-pgraster PROPERTIES SUFFIX ".input") set_target_properties(input-pgraster PROPERTIES SUFFIX ".input")
install(TARGETS input-pgraster mapnik_install(TARGET input-pgraster IS_PLUGIN)
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
)

View file

@ -18,6 +18,4 @@ set_target_properties(input-postgis PROPERTIES PREFIX "")
set_target_properties(input-postgis PROPERTIES OUTPUT_NAME "postgis") set_target_properties(input-postgis PROPERTIES OUTPUT_NAME "postgis")
set_target_properties(input-postgis PROPERTIES SUFFIX ".input") set_target_properties(input-postgis PROPERTIES SUFFIX ".input")
install(TARGETS input-postgis mapnik_install(TARGET input-postgis IS_PLUGIN)
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
)

View file

@ -16,6 +16,4 @@ set_target_properties(input-raster PROPERTIES PREFIX "")
set_target_properties(input-raster PROPERTIES OUTPUT_NAME "raster") set_target_properties(input-raster PROPERTIES OUTPUT_NAME "raster")
set_target_properties(input-raster PROPERTIES SUFFIX ".input") set_target_properties(input-raster PROPERTIES SUFFIX ".input")
install(TARGETS input-raster mapnik_install(TARGET input-raster IS_PLUGIN)
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
)

View file

@ -19,6 +19,4 @@ set_target_properties(input-shape PROPERTIES PREFIX "")
set_target_properties(input-shape PROPERTIES OUTPUT_NAME "shape") set_target_properties(input-shape PROPERTIES OUTPUT_NAME "shape")
set_target_properties(input-shape PROPERTIES SUFFIX ".input") set_target_properties(input-shape PROPERTIES SUFFIX ".input")
install(TARGETS input-shape mapnik_install(TARGET input-shape IS_PLUGIN)
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
)

View file

@ -18,6 +18,4 @@ set_target_properties(input-sqlite PROPERTIES PREFIX "")
set_target_properties(input-sqlite PROPERTIES OUTPUT_NAME "sqlite") set_target_properties(input-sqlite PROPERTIES OUTPUT_NAME "sqlite")
set_target_properties(input-sqlite PROPERTIES SUFFIX ".input") set_target_properties(input-sqlite PROPERTIES SUFFIX ".input")
install(TARGETS input-sqlite mapnik_install(TARGET input-sqlite IS_PLUGIN)
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
)

View file

@ -16,6 +16,4 @@ set_target_properties(input-topojson PROPERTIES PREFIX "")
set_target_properties(input-topojson PROPERTIES OUTPUT_NAME "topojson") set_target_properties(input-topojson PROPERTIES OUTPUT_NAME "topojson")
set_target_properties(input-topojson PROPERTIES SUFFIX ".input") set_target_properties(input-topojson PROPERTIES SUFFIX ".input")
install(TARGETS input-topojson mapnik_install(TARGET input-topojson IS_PLUGIN)
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
)

View file

@ -303,3 +303,5 @@ install(TARGETS mapnik
INCLUDES DESTINATION include/ INCLUDES DESTINATION include/
PUBLIC_HEADER DESTINATION include/ PUBLIC_HEADER DESTINATION include/
) )
mapnik_install(TARGET mapnik ALREADY_INSTALLED)

View file

@ -26,9 +26,4 @@ target_include_directories(json PRIVATE
) )
target_link_libraries(json PRIVATE mapnik::core ${ICUU_LIB}) target_link_libraries(json PRIVATE mapnik::core ${ICUU_LIB})
install(TARGETS json mapnik_install(TARGET json)
EXPORT MapnikTargets
LIBRARY DESTINATION ${MAPNIK_LIB_DIR}
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
)

View file

@ -18,9 +18,4 @@ target_include_directories(wkt PRIVATE
) )
target_link_libraries(wkt PRIVATE mapnik::core) target_link_libraries(wkt PRIVATE mapnik::core)
install(TARGETS wkt mapnik_install(TARGET wkt)
EXPORT MapnikTargets
LIBRARY DESTINATION ${MAPNIK_LIB_DIR}
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
)

View file

@ -7,9 +7,4 @@ target_link_libraries(geometry_to_wkb PRIVATE
mapnik::mapnik mapnik::mapnik
) )
install(TARGETS geometry_to_wkb mapnik_install(TARGET geometry_to_wkb)
EXPORT MapnikTargets
LIBRARY DESTINATION ${MAPNIK_LIB_DIR}
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
)

View file

@ -15,9 +15,5 @@ target_link_libraries(mapnik-index PRIVATE
mapnik::wkt mapnik::wkt
Boost::program_options Boost::program_options
) )
install(TARGETS mapnik-index
EXPORT MapnikTargets mapnik_install(TARGET mapnik-index)
LIBRARY DESTINATION ${MAPNIK_LIB_DIR}
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
)

View file

@ -9,9 +9,5 @@ target_link_libraries(mapnik-render PRIVATE
mapnik::mapnik mapnik::mapnik
Boost::program_options Boost::program_options
) )
install(TARGETS mapnik-render
EXPORT MapnikTargets mapnik_install(TARGET mapnik-render)
LIBRARY DESTINATION ${MAPNIK_LIB_DIR}
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
)

View file

@ -11,3 +11,5 @@ install(TARGETS ogrindex
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR} ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR} RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
) )
mapnik_install(TARGET mapnik-ogrindex)

View file

@ -17,9 +17,4 @@ target_link_libraries(pgsql2sqlite PRIVATE
mapnik::mapnik mapnik::mapnik
) )
install(TARGETS pgsql2sqlite mapnik_install(TARGET pgsql2sqlite)
EXPORT MapnikTargets
LIBRARY DESTINATION ${MAPNIK_LIB_DIR}
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
)

View file

@ -12,9 +12,5 @@ target_link_libraries(shapeindex PRIVATE
mapnik::core mapnik::core
mapnik::mapnik mapnik::mapnik
) )
install(TARGETS shapeindex
EXPORT MapnikTargets mapnik_install(TARGET shapeindex)
LIBRARY DESTINATION ${MAPNIK_LIB_DIR}
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
)

View file

@ -12,9 +12,5 @@ target_link_libraries(svg2png PRIVATE
mapnik::mapnik mapnik::mapnik
mapnik::agg mapnik::agg
) )
install(TARGETS svg2png
EXPORT MapnikTargets mapnik_install(TARGET svg2png)
LIBRARY DESTINATION ${MAPNIK_LIB_DIR}
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
)