diff --git a/CMakeLists.txt b/CMakeLists.txt index 47bbaa15d..0ce7fe86f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 3a69241d7..60c4ff85f 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -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 -) diff --git a/cmake/CopyDllsForDebug.cmake b/cmake/CopyDllsForDebug.cmake deleted file mode 100644 index 3c0e118a6..000000000 --- a/cmake/CopyDllsForDebug.cmake +++ /dev/null @@ -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="$" -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() diff --git a/cmake/MapnikCopyDependencies.cmake b/cmake/MapnikCopyDependencies.cmake deleted file mode 100644 index 4d14174a7..000000000 --- a/cmake/MapnikCopyDependencies.cmake +++ /dev/null @@ -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 "$" ${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 "$") - 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 "$" ${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() diff --git a/cmake/MapnikInstall.cmake b/cmake/MapnikInstall.cmake index 4d1d0bb4d..eb343032d 100644 --- a/cmake/MapnikInstall.cmake +++ b/cmake/MapnikInstall.cmake @@ -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() diff --git a/cmake/mapnikConfig.cmake.in b/cmake/mapnikConfig.cmake.in index 942321e17..e0aee8778 100644 --- a/cmake/mapnikConfig.cmake.in +++ b/cmake/mapnikConfig.cmake.in @@ -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") diff --git a/demo/c++/CMakeLists.txt b/demo/c++/CMakeLists.txt index ffa2cb1a8..36e36d634 100644 --- a/demo/c++/CMakeLists.txt +++ b/demo/c++/CMakeLists.txt @@ -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) diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index 445d5fa78..dcd4c5a58 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -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 -) diff --git a/plugins/input/CMakeLists.txt b/plugins/input/CMakeLists.txt index 598f77f91..9a6f3cb0f 100644 --- a/plugins/input/CMakeLists.txt +++ b/plugins/input/CMakeLists.txt @@ -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_$.cmake" + CONTENT "${m_copy_dlls_str}" + ) + add_custom_target(copy_plugin_dependencies ALL + COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_BINARY_DIR}/copy_dlls_$.cmake" + WORKING_DIRECTORY "${MAPNIK_OUTPUT_DIR}/plugins/input" + COMMENT "copying plugin dlls into build dir" + ) + add_dependencies(copy_plugin_dependencies ${m_build_plugins}) endif() diff --git a/plugins/input/csv/CMakeLists.txt b/plugins/input/csv/CMakeLists.txt index 636f5f147..846870eb9 100644 --- a/plugins/input/csv/CMakeLists.txt +++ b/plugins/input/csv/CMakeLists.txt @@ -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) diff --git a/plugins/input/gdal/CMakeLists.txt b/plugins/input/gdal/CMakeLists.txt index 6ae6336a4..ece9db01c 100644 --- a/plugins/input/gdal/CMakeLists.txt +++ b/plugins/input/gdal/CMakeLists.txt @@ -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) diff --git a/plugins/input/geobuf/CMakeLists.txt b/plugins/input/geobuf/CMakeLists.txt index 6406d528f..faf9a0ef1 100644 --- a/plugins/input/geobuf/CMakeLists.txt +++ b/plugins/input/geobuf/CMakeLists.txt @@ -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) diff --git a/plugins/input/geojson/CMakeLists.txt b/plugins/input/geojson/CMakeLists.txt index e04b7a768..60f5db98d 100644 --- a/plugins/input/geojson/CMakeLists.txt +++ b/plugins/input/geojson/CMakeLists.txt @@ -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) diff --git a/plugins/input/ogr/CMakeLists.txt b/plugins/input/ogr/CMakeLists.txt index b149bd893..87917a9f0 100644 --- a/plugins/input/ogr/CMakeLists.txt +++ b/plugins/input/ogr/CMakeLists.txt @@ -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) diff --git a/plugins/input/pgraster/CMakeLists.txt b/plugins/input/pgraster/CMakeLists.txt index 7e6cb4dc7..5fdd60208 100644 --- a/plugins/input/pgraster/CMakeLists.txt +++ b/plugins/input/pgraster/CMakeLists.txt @@ -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) diff --git a/plugins/input/postgis/CMakeLists.txt b/plugins/input/postgis/CMakeLists.txt index 667cfbd67..18d2ebf05 100644 --- a/plugins/input/postgis/CMakeLists.txt +++ b/plugins/input/postgis/CMakeLists.txt @@ -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) diff --git a/plugins/input/raster/CMakeLists.txt b/plugins/input/raster/CMakeLists.txt index 9b44540d3..c7bcc4c73 100644 --- a/plugins/input/raster/CMakeLists.txt +++ b/plugins/input/raster/CMakeLists.txt @@ -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) diff --git a/plugins/input/shape/CMakeLists.txt b/plugins/input/shape/CMakeLists.txt index 1db71db7b..bc2f6c438 100644 --- a/plugins/input/shape/CMakeLists.txt +++ b/plugins/input/shape/CMakeLists.txt @@ -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) diff --git a/plugins/input/sqlite/CMakeLists.txt b/plugins/input/sqlite/CMakeLists.txt index dedf98c3a..682978347 100644 --- a/plugins/input/sqlite/CMakeLists.txt +++ b/plugins/input/sqlite/CMakeLists.txt @@ -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) diff --git a/plugins/input/topojson/CMakeLists.txt b/plugins/input/topojson/CMakeLists.txt index bd6f2cc67..3ff00894c 100644 --- a/plugins/input/topojson/CMakeLists.txt +++ b/plugins/input/topojson/CMakeLists.txt @@ -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) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 343a6d540..831563072 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index e427561d9..b35e0183a 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -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) diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index ff22be452..8e42bef69 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -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) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0705ddce1..4d28b9cc9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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=\$;$;$ENV{PATH}>,\\\\\\\\\;>" - ) + set(m_test_path "\$;$;$ENV{PATH}>,\\\\\\\\\;>") else() - catch_discover_tests(mapnik-test-unit PROPERTIES - ENVIRONMENT "PATH=$;$;$ENV{PATH}>" - ) + set(m_test_path "$;$;$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}") diff --git a/utils/geometry_to_wkb/CMakeLists.txt b/utils/geometry_to_wkb/CMakeLists.txt index 7266f72c6..09b395bff 100644 --- a/utils/geometry_to_wkb/CMakeLists.txt +++ b/utils/geometry_to_wkb/CMakeLists.txt @@ -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) diff --git a/utils/mapnik-index/CMakeLists.txt b/utils/mapnik-index/CMakeLists.txt index 22925e1b5..fb3e2ae05 100644 --- a/utils/mapnik-index/CMakeLists.txt +++ b/utils/mapnik-index/CMakeLists.txt @@ -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) diff --git a/utils/mapnik-render/CMakeLists.txt b/utils/mapnik-render/CMakeLists.txt index b5e8fa1a5..09ff8d744 100644 --- a/utils/mapnik-render/CMakeLists.txt +++ b/utils/mapnik-render/CMakeLists.txt @@ -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) diff --git a/utils/ogrindex/CMakeLists.txt b/utils/ogrindex/CMakeLists.txt index 20ee5cf4e..b3c750dca 100644 --- a/utils/ogrindex/CMakeLists.txt +++ b/utils/ogrindex/CMakeLists.txt @@ -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) diff --git a/utils/pgsql2sqlite/CMakeLists.txt b/utils/pgsql2sqlite/CMakeLists.txt index 7d7679987..e4540f37f 100644 --- a/utils/pgsql2sqlite/CMakeLists.txt +++ b/utils/pgsql2sqlite/CMakeLists.txt @@ -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) diff --git a/utils/shapeindex/CMakeLists.txt b/utils/shapeindex/CMakeLists.txt index 3a8febb16..eef6169d0 100644 --- a/utils/shapeindex/CMakeLists.txt +++ b/utils/shapeindex/CMakeLists.txt @@ -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) diff --git a/utils/svg2png/CMakeLists.txt b/utils/svg2png/CMakeLists.txt index ba2e9c89b..1f95d2827 100644 --- a/utils/svg2png/CMakeLists.txt +++ b/utils/svg2png/CMakeLists.txt @@ -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)