windows: copy all dlls. optional library dir if some dlls are not found.

This commit is contained in:
Mathis Logemann 2021-01-27 00:41:54 +01:00
parent 247ceff7a7
commit a7c9f5b941
4 changed files with 25 additions and 9 deletions

View file

@ -8,6 +8,8 @@ project(mapnik
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set(ADDITIONAL_LIBARIES_PATHS "" CACHE STRING "currently 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(BUILD_SHARED_LIBS "build mapnik dynamic(ON) or static(OFF)" 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)
@ -79,7 +81,6 @@ message(STATUS "Installing plugins to ${PLUGINS_INSTALL_DIR}")
set(FONTS_INSTALL_DIR ${MAPNIK_BIN_DIR}/fonts CACHE STRING "installs the fonts in the specified directory")
message(STATUS "Installing fonts to ${FONTS_INSTALL_DIR}")
find_package(Boost 1.74 REQUIRED COMPONENTS filesystem system regex)
find_package(ICU REQUIRED COMPONENTS uc)
find_package(Freetype REQUIRED)

View file

@ -16,16 +16,17 @@ if(RUN_IT)
else()
set(THIS_FILE ${CMAKE_CURRENT_LIST_FILE})
function(copy_dlls_for_debug _target _libs _dirs)
function(copy_dlls_for_debug _targets _libs _dirs)
if(WIN32)
add_custom_command(
TARGET ${_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -DRUN_IT:BOOL=ON -DTO_FIXUP_FILE=$<TARGET_FILE:${_target}> -DTO_FIXUP_LIBS=${_libs} -DTO_FIXUP_DIRS=${_dirs} -P ${THIS_FILE}
COMMENT "Fixing up dependencies for ${_target}"
VERBATIM
)
foreach(_target ${_targets})
add_custom_command(
TARGET ${_target} POST_BUILD
COMMAND ${CMAKE_COMMAND} -DRUN_IT:BOOL=ON -DTO_FIXUP_FILE=$<TARGET_FILE:${_target}> -DTO_FIXUP_LIBS=${_libs} -DTO_FIXUP_DIRS=${_dirs} -P ${THIS_FILE}
COMMENT "Fixing up dependencies for ${_target}"
VERBATIM
)
endforeach()
endif(WIN32)
endfunction()
endif()

View file

@ -44,3 +44,10 @@ install(TARGETS mapnik-viewer
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
)
if(WIN32)
include(CopyDllsForDebug)
add_custom_command(TARGET mapnik-viewer POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:mapnik::mapnik>" ${CMAKE_CURRENT_BINARY_DIR})
copy_dlls_for_debug(mapnik-viewer \"\" \"${ADDITIONAL_LIBARIES_PATHS}\")
endif()

View file

@ -168,6 +168,13 @@ include(CTest)
include(${catch2_SOURCE_DIR}/contrib/Catch.cmake)
include(${catch2_SOURCE_DIR}/contrib/ParseAndAddCatchTests.cmake)
if(WIN32)
include(CopyDllsForDebug)
add_custom_command(TARGET mapnik-test-unit POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE:mapnik::mapnik>" ${CMAKE_CURRENT_BINARY_DIR})
set(APPS mapnik-test-unit agg_rasterizer_integer_overflow_test datasource_registration_test font_registration_test map_xml_test mapnik-test-visual)
copy_dlls_for_debug(${APPS} \"\" \"${ADDITIONAL_LIBARIES_PATHS}\")
endif()
file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test)
file(COPY data-visual DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/test)