From f0940c2075fb0c3e522d4f53cfce1be365d50e20 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Mon, 25 Oct 2021 18:58:55 +0200 Subject: [PATCH 1/4] [CMake] move all build artifacts into same dir to remove the need of copy_dlls (except for plugins) [CMake] improve BUILD_TESTING and use pkgconf for cairo on linux [CMake] add Threads dependency to -Config --- CMakeLists.txt | 19 +++--- benchmark/CMakeLists.txt | 21 ++----- cmake/CopyDllsForDebug.cmake | 38 ------------ cmake/MapnikCopyDependencies.cmake | 61 ------------------- cmake/MapnikInstall.cmake | 3 - cmake/mapnikConfig.cmake.in | 2 + demo/c++/CMakeLists.txt | 9 +-- demo/viewer/CMakeLists.txt | 17 +----- plugins/input/CMakeLists.txt | 35 +++++++++++ plugins/input/csv/CMakeLists.txt | 4 +- plugins/input/gdal/CMakeLists.txt | 4 +- plugins/input/geobuf/CMakeLists.txt | 4 +- plugins/input/geojson/CMakeLists.txt | 4 +- plugins/input/ogr/CMakeLists.txt | 4 +- plugins/input/pgraster/CMakeLists.txt | 3 + plugins/input/postgis/CMakeLists.txt | 4 +- plugins/input/raster/CMakeLists.txt | 4 +- plugins/input/shape/CMakeLists.txt | 4 +- plugins/input/sqlite/CMakeLists.txt | 4 +- plugins/input/topojson/CMakeLists.txt | 4 +- src/CMakeLists.txt | 3 + src/json/CMakeLists.txt | 3 + src/wkt/CMakeLists.txt | 3 + test/CMakeLists.txt | 88 +++++++++++++++++---------- utils/geometry_to_wkb/CMakeLists.txt | 4 ++ utils/mapnik-index/CMakeLists.txt | 4 ++ utils/mapnik-render/CMakeLists.txt | 4 ++ utils/ogrindex/CMakeLists.txt | 4 ++ utils/pgsql2sqlite/CMakeLists.txt | 4 ++ utils/shapeindex/CMakeLists.txt | 4 ++ utils/svg2png/CMakeLists.txt | 4 ++ 31 files changed, 188 insertions(+), 185 deletions(-) delete mode 100644 cmake/CopyDllsForDebug.cmake delete mode 100644 cmake/MapnikCopyDependencies.cmake 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) From 7a7a8125a9865c5cdff722ad7a81bb00737d0523 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sun, 14 Nov 2021 23:37:21 +0100 Subject: [PATCH 2/4] [CMake] remove obsolete statements/improve docs [CMake] remove obsolete variables and improve docs [CMake] remove proj env var --- CMakeLists.txt | 8 +++----- demo/c++/CMakeLists.txt | 2 -- demo/viewer/CMakeLists.txt | 2 -- docs/cmake-usage.md | 21 ++++++++++----------- plugins/input/csv/CMakeLists.txt | 2 -- plugins/input/gdal/CMakeLists.txt | 2 -- plugins/input/geobuf/CMakeLists.txt | 2 -- plugins/input/geojson/CMakeLists.txt | 2 -- plugins/input/ogr/CMakeLists.txt | 2 -- plugins/input/pgraster/CMakeLists.txt | 2 -- plugins/input/postgis/CMakeLists.txt | 2 -- plugins/input/raster/CMakeLists.txt | 2 -- plugins/input/shape/CMakeLists.txt | 2 -- plugins/input/sqlite/CMakeLists.txt | 2 -- plugins/input/topojson/CMakeLists.txt | 2 -- test/CMakeLists.txt | 12 ------------ utils/geometry_to_wkb/CMakeLists.txt | 2 -- utils/mapnik-index/CMakeLists.txt | 2 -- utils/mapnik-render/CMakeLists.txt | 2 -- utils/ogrindex/CMakeLists.txt | 2 -- utils/pgsql2sqlite/CMakeLists.txt | 1 - utils/shapeindex/CMakeLists.txt | 2 -- utils/svg2png/CMakeLists.txt | 2 -- 23 files changed, 13 insertions(+), 67 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ce7fe86f..6d76303d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,15 +22,13 @@ include(MapnikOption) include(MapnikMinimumVersions) include(MapnikFindPackage) 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) -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) -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) diff --git a/demo/c++/CMakeLists.txt b/demo/c++/CMakeLists.txt index 36e36d634..ee9e79af5 100644 --- a/demo/c++/CMakeLists.txt +++ b/demo/c++/CMakeLists.txt @@ -1,5 +1,3 @@ -project(mapnik-demo) - add_executable(mapnik-demo rundemo.cpp) set_target_properties(mapnik-demo PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${MAPNIK_OUTPUT_DIR}" diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index dcd4c5a58..cbe348291 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -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) diff --git a/docs/cmake-usage.md b/docs/cmake-usage.md index 2c646b2d3..20f9144be 100644 --- a/docs/cmake-usage.md +++ b/docs/cmake-usage.md @@ -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": "/scripts/buildsystems/vcpkg.cmake", - "ADDITIONAL_LIBARIES_PATHS":"/installed/x64-windows/debug/bin" + "CMAKE_TOOLCHAIN_FILE": "/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": "/scripts/buildsystems/vcpkg.cmake", - "ADDITIONAL_LIBARIES_PATHS":"/installed/x64-windows/bin" - } + "inherits": ["vcpkg", "windows-default-release"] } ] } diff --git a/plugins/input/csv/CMakeLists.txt b/plugins/input/csv/CMakeLists.txt index 846870eb9..dcc966157 100644 --- a/plugins/input/csv/CMakeLists.txt +++ b/plugins/input/csv/CMakeLists.txt @@ -1,5 +1,3 @@ -project(input-csv) - add_library(input-csv MODULE csv_datasource.cpp csv_featureset.cpp diff --git a/plugins/input/gdal/CMakeLists.txt b/plugins/input/gdal/CMakeLists.txt index ece9db01c..746953a3c 100644 --- a/plugins/input/gdal/CMakeLists.txt +++ b/plugins/input/gdal/CMakeLists.txt @@ -1,5 +1,3 @@ -project(input-gdal) - find_package(GDAL REQUIRED) add_library(input-gdal MODULE diff --git a/plugins/input/geobuf/CMakeLists.txt b/plugins/input/geobuf/CMakeLists.txt index faf9a0ef1..870b603d9 100644 --- a/plugins/input/geobuf/CMakeLists.txt +++ b/plugins/input/geobuf/CMakeLists.txt @@ -1,5 +1,3 @@ -project(input-geobuf) - add_library(input-geobuf MODULE geobuf_datasource.cpp geobuf_featureset.cpp diff --git a/plugins/input/geojson/CMakeLists.txt b/plugins/input/geojson/CMakeLists.txt index 60f5db98d..e32dcfcb1 100644 --- a/plugins/input/geojson/CMakeLists.txt +++ b/plugins/input/geojson/CMakeLists.txt @@ -1,5 +1,3 @@ -project(input-geojson) - add_library(input-geojson MODULE geojson_datasource.cpp geojson_featureset.cpp diff --git a/plugins/input/ogr/CMakeLists.txt b/plugins/input/ogr/CMakeLists.txt index 87917a9f0..f460eb033 100644 --- a/plugins/input/ogr/CMakeLists.txt +++ b/plugins/input/ogr/CMakeLists.txt @@ -1,5 +1,3 @@ -project(input-ogr) - find_package(GDAL REQUIRED) add_library(input-ogr MODULE diff --git a/plugins/input/pgraster/CMakeLists.txt b/plugins/input/pgraster/CMakeLists.txt index 5fdd60208..f7ac4ff66 100644 --- a/plugins/input/pgraster/CMakeLists.txt +++ b/plugins/input/pgraster/CMakeLists.txt @@ -1,5 +1,3 @@ -project(input-pgraster) - find_package(PostgreSQL REQUIRED) add_library(input-pgraster MODULE diff --git a/plugins/input/postgis/CMakeLists.txt b/plugins/input/postgis/CMakeLists.txt index 18d2ebf05..796e0c90e 100644 --- a/plugins/input/postgis/CMakeLists.txt +++ b/plugins/input/postgis/CMakeLists.txt @@ -1,5 +1,3 @@ -project(input-postgis) - find_package(PostgreSQL REQUIRED) add_library(input-postgis MODULE diff --git a/plugins/input/raster/CMakeLists.txt b/plugins/input/raster/CMakeLists.txt index c7bcc4c73..c7426ea3a 100644 --- a/plugins/input/raster/CMakeLists.txt +++ b/plugins/input/raster/CMakeLists.txt @@ -1,5 +1,3 @@ -project(input-raster) - add_library(input-raster MODULE raster_datasource.cpp raster_featureset.cpp diff --git a/plugins/input/shape/CMakeLists.txt b/plugins/input/shape/CMakeLists.txt index bc2f6c438..6d9a9a7d1 100644 --- a/plugins/input/shape/CMakeLists.txt +++ b/plugins/input/shape/CMakeLists.txt @@ -1,5 +1,3 @@ -project(input-shape) - add_library(input-shape MODULE dbfile.cpp dbf_test.cpp diff --git a/plugins/input/sqlite/CMakeLists.txt b/plugins/input/sqlite/CMakeLists.txt index 682978347..984bdfd1b 100644 --- a/plugins/input/sqlite/CMakeLists.txt +++ b/plugins/input/sqlite/CMakeLists.txt @@ -1,5 +1,3 @@ -project(input-sqlite) - find_package(SQLite3 REQUIRED) add_library(input-sqlite MODULE diff --git a/plugins/input/topojson/CMakeLists.txt b/plugins/input/topojson/CMakeLists.txt index 3ff00894c..fd2b4994b 100644 --- a/plugins/input/topojson/CMakeLists.txt +++ b/plugins/input/topojson/CMakeLists.txt @@ -1,5 +1,3 @@ -project(input-topojson) - add_library(input-topojson MODULE topojson_datasource.cpp topojson_featureset.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4d28b9cc9..847511f49 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,5 +1,3 @@ -project(mapnik-test) - find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options) find_package(PostgreSQL REQUIRED) @@ -194,7 +192,6 @@ 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") @@ -204,14 +201,6 @@ 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) set(m_test_path "\$;$;$ENV{PATH}>,\\\\\\\\\;>") else() @@ -223,7 +212,6 @@ catch_discover_tests(mapnik-test-unit 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}") diff --git a/utils/geometry_to_wkb/CMakeLists.txt b/utils/geometry_to_wkb/CMakeLists.txt index 09b395bff..518f4ac9a 100644 --- a/utils/geometry_to_wkb/CMakeLists.txt +++ b/utils/geometry_to_wkb/CMakeLists.txt @@ -1,5 +1,3 @@ -project(geometry_to_wkb) - add_executable(geometry_to_wkb main.cpp) target_link_libraries(geometry_to_wkb PRIVATE mapnik::mapnik) diff --git a/utils/mapnik-index/CMakeLists.txt b/utils/mapnik-index/CMakeLists.txt index fb3e2ae05..ec6ce97eb 100644 --- a/utils/mapnik-index/CMakeLists.txt +++ b/utils/mapnik-index/CMakeLists.txt @@ -1,5 +1,3 @@ -project(mapnik-index) - find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options) add_executable(mapnik-index diff --git a/utils/mapnik-render/CMakeLists.txt b/utils/mapnik-render/CMakeLists.txt index 09ff8d744..27ccfbe8d 100644 --- a/utils/mapnik-render/CMakeLists.txt +++ b/utils/mapnik-render/CMakeLists.txt @@ -1,5 +1,3 @@ -project(mapnik-render) - find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options) add_executable(mapnik-render mapnik-render.cpp) diff --git a/utils/ogrindex/CMakeLists.txt b/utils/ogrindex/CMakeLists.txt index b3c750dca..69f27cdd6 100644 --- a/utils/ogrindex/CMakeLists.txt +++ b/utils/ogrindex/CMakeLists.txt @@ -1,5 +1,3 @@ -project(ogrindex) - add_executable(ogrindex ogrindex.cpp) target_link_libraries(ogrindex PRIVATE mapnik::mapnik) diff --git a/utils/pgsql2sqlite/CMakeLists.txt b/utils/pgsql2sqlite/CMakeLists.txt index e4540f37f..6def100c0 100644 --- a/utils/pgsql2sqlite/CMakeLists.txt +++ b/utils/pgsql2sqlite/CMakeLists.txt @@ -1,4 +1,3 @@ -project(pgsql2sqlite) find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options) find_package(SQLite3 REQUIRED) find_package(PostgreSQL REQUIRED) diff --git a/utils/shapeindex/CMakeLists.txt b/utils/shapeindex/CMakeLists.txt index eef6169d0..d39ca3f04 100644 --- a/utils/shapeindex/CMakeLists.txt +++ b/utils/shapeindex/CMakeLists.txt @@ -1,5 +1,3 @@ -project(shapeindex) - find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options) add_executable(shapeindex diff --git a/utils/svg2png/CMakeLists.txt b/utils/svg2png/CMakeLists.txt index 1f95d2827..dc239cd2b 100644 --- a/utils/svg2png/CMakeLists.txt +++ b/utils/svg2png/CMakeLists.txt @@ -1,5 +1,3 @@ -project(svg2png) - find_package(Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS program_options) add_executable(svg2png From fbb0ae1489ae92c3078e19221d63361529fb0dc9 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Mon, 15 Nov 2021 00:50:47 +0100 Subject: [PATCH 3/4] [CMake] fix building with zero plugins [Cmake] fix null plugins fix null --- plugins/input/CMakeLists.txt | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/plugins/input/CMakeLists.txt b/plugins/input/CMakeLists.txt index 9a6f3cb0f..5f89249ec 100644 --- a/plugins/input/CMakeLists.txt +++ b/plugins/input/CMakeLists.txt @@ -52,20 +52,23 @@ 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}) + 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_$.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() endif() From a911e33d7b80c4a337ad4feb81a3a76766479ee3 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Mon, 15 Nov 2021 10:39:40 +0100 Subject: [PATCH 4/4] [CMake] add more build presets [CMake] rename windows presets Revert "[CMake] rename windows presets" This reverts commit 381dcd606c0c8f4281a482ede0c8c4a9a6d912fa. [CMake] rename windows presets --- CMakePresets.json | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 1206a07b8..dbf9dac33 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -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" } ] }