From a7c9f5b9411b2fe7cb3944fb04135dd0090cebff Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Wed, 27 Jan 2021 00:41:54 +0100 Subject: [PATCH] windows: copy all dlls. optional library dir if some dlls are not found. --- CMakeLists.txt | 3 ++- cmake/CopyDllsForDebug.cmake | 17 +++++++++-------- demo/viewer/CMakeLists.txt | 7 +++++++ test/CMakeLists.txt | 7 +++++++ 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c2c1f4fd..1c533e282 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/CopyDllsForDebug.cmake b/cmake/CopyDllsForDebug.cmake index f2f2b153b..7f668868a 100644 --- a/cmake/CopyDllsForDebug.cmake +++ b/cmake/CopyDllsForDebug.cmake @@ -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=$ -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=$ -DTO_FIXUP_LIBS=${_libs} -DTO_FIXUP_DIRS=${_dirs} -P ${THIS_FILE} + COMMENT "Fixing up dependencies for ${_target}" + VERBATIM + ) + endforeach() endif(WIN32) endfunction() endif() - diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index 45604e28d..599255d9f 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -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 "$" ${CMAKE_CURRENT_BINARY_DIR}) + copy_dlls_for_debug(mapnik-viewer \"\" \"${ADDITIONAL_LIBARIES_PATHS}\") +endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 63a0da82c..05cdfbe99 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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 "$" ${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)