[CMake] refactor mapnik_install

This commit is contained in:
Mathis Logemann 2021-09-22 19:52:39 +02:00
parent d57f0ac93a
commit 35ea6f2a56
26 changed files with 114 additions and 126 deletions

View file

@ -356,7 +356,7 @@ target_link_libraries(core INTERFACE
)
target_compile_definitions(core INTERFACE ${MAPNIK_COMPILE_DEFS})
mapnik_install(TARGET core)
mapnik_install(core)
add_subdirectory(deps)
add_subdirectory(src)

View file

@ -1,11 +1,5 @@
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}
function(mapnik_install _target)
install(TARGETS ${_target}
EXPORT MapnikTargets
INCLUDES DESTINATION ${MAPNIK_INCLUDE_DIR}
RUNTIME DESTINATION ${MAPNIK_BIN_DIR}
@ -16,8 +10,16 @@ function(mapnik_install)
ARCHIVE DESTINATION ${MAPNIK_ARCHIVE_DIR}
COMPONENT MapnikDevelopment
)
elseif(NOT MAPNIK_INSTALL_ALREADY_INSTALLED AND MAPNIK_INSTALL_IS_PLUGIN)
install(TARGETS ${MAPNIK_INSTALL_TARGET}
get_target_property(TARGET_TYPE "${_target}" TYPE)
if (TARGET_TYPE STREQUAL "EXECUTABLE")
get_property(MAPNIK_INSTALLED_TARGETS GLOBAL PROPERTY TARGETS)
list(APPEND MAPNIK_INSTALLED_TARGETS ${_target})
set_property(GLOBAL PROPERTY TARGETS ${MAPNIK_INSTALLED_TARGETS})
endif()
endfunction()
function(mapnik_install_plugin _target)
install(TARGETS ${_target}
RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR}
COMPONENT MapnikPluginRuntime
LIBRARY DESTINATION ${PLUGINS_INSTALL_DIR}
@ -26,19 +28,9 @@ function(mapnik_install)
ARCHIVE DESTINATION ${PLUGINS_INSTALL_DIR}
COMPONENT MapnikPluginDevelopment
)
endif()
if(NOT MAPNIK_INSTALL_IS_PLUGIN)
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})
list(APPEND MAPNIK_INSTALLED_PLUGINS ${_target})
set_property(GLOBAL PROPERTY PLUGINS ${MAPNIK_INSTALLED_PLUGINS})
endif()
endfunction()

View file

@ -4,7 +4,7 @@ add_executable(mapnik-demo rundemo.cpp)
target_link_libraries(mapnik-demo PRIVATE mapnik::agg mapnik::mapnik)
mapnik_install(TARGET mapnik-demo)
mapnik_install(mapnik-demo)
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)

View file

@ -61,7 +61,7 @@ if(QT_VERSION_MAJOR EQUAL 6)
endif()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini DESTINATION bin)
mapnik_install(TARGET mapnik-viewer)
mapnik_install(mapnik-viewer)
mapnik_copy_dependencies(
TARGETS

View file

@ -1,3 +1,6 @@
set(_plugin_prefix "")
set(_plugin_suffix ".input")
if(USE_PLUGIN_INPUT_CSV)
message(STATUS "using input plugin csv")
add_subdirectory(csv)

View file

@ -7,15 +7,15 @@ add_library(input-csv MODULE
csv_inline_featureset.cpp
csv_utils.cpp
)
add_library(mapnik::plugin::input::csv ALIAS input-csv)
target_link_libraries(input-csv PRIVATE
mapnik::mapnik
mapnik::wkt
mapnik::json
)
set_target_properties(input-csv PROPERTIES PREFIX "")
set_target_properties(input-csv PROPERTIES OUTPUT_NAME "csv")
set_target_properties(input-csv PROPERTIES SUFFIX ".input")
set_target_properties(input-csv PROPERTIES
OUTPUT_NAME "csv"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
)
mapnik_install(TARGET input-csv IS_PLUGIN)
mapnik_install_plugin(input-csv)

View file

@ -6,15 +6,15 @@ add_library(input-gdal MODULE
gdal_datasource.cpp
gdal_featureset.cpp
)
add_library(mapnik::plugin::input::gdal ALIAS input-gdal)
target_include_directories(input-gdal PRIVATE ${GDAL_INCLUDE_DIRS})
target_link_libraries(input-gdal PRIVATE
mapnik::mapnik
${GDAL_LIBRARIES}
)
set_target_properties(input-gdal PROPERTIES PREFIX "")
set_target_properties(input-gdal PROPERTIES OUTPUT_NAME "gdal")
set_target_properties(input-gdal PROPERTIES SUFFIX ".input")
set_target_properties(input-gdal PROPERTIES
OUTPUT_NAME "gdal"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
)
mapnik_install(TARGET input-gdal IS_PLUGIN)
mapnik_install_plugin(input-gdal)

View file

@ -4,12 +4,11 @@ add_library(input-geobuf MODULE
geobuf_datasource.cpp
geobuf_featureset.cpp
)
add_library(mapnik::plugin::input::geobuf ALIAS input-geobuf)
target_link_libraries(input-geobuf PRIVATE mapnik::mapnik)
set_target_properties(input-geobuf PROPERTIES
OUTPUT_NAME "geobuf"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
)
set_target_properties(input-geobuf PROPERTIES PREFIX "")
set_target_properties(input-geobuf PROPERTIES OUTPUT_NAME "geobuf")
set_target_properties(input-geobuf PROPERTIES SUFFIX ".input")
mapnik_install(TARGET input-geobuf IS_PLUGIN)
mapnik_install_plugin(input-geobuf)

View file

@ -6,15 +6,14 @@ add_library(input-geojson MODULE
geojson_index_featureset.cpp
geojson_memory_index_featureset.cpp
)
add_library(mapnik::plugin::input::geojson ALIAS input-geojson)
target_link_libraries(input-geojson PRIVATE
mapnik::mapnik
mapnik::json
)
set_target_properties(input-geojson PROPERTIES
OUTPUT_NAME "geojson"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
)
set_target_properties(input-geojson PROPERTIES PREFIX "")
set_target_properties(input-geojson PROPERTIES OUTPUT_NAME "geojson")
set_target_properties(input-geojson PROPERTIES SUFFIX ".input")
mapnik_install(TARGET input-geojson IS_PLUGIN)
mapnik_install_plugin(input-geojson)

View file

@ -8,15 +8,15 @@ add_library(input-ogr MODULE
ogr_featureset.cpp
ogr_index_featureset.cpp
)
add_library(mapnik::plugin::input::ogr ALIAS input-ogr)
target_include_directories(input-ogr PRIVATE ${GDAL_INCLUDE_DIRS})
target_link_libraries(input-ogr PRIVATE
mapnik::mapnik
${GDAL_LIBRARIES}
)
set_target_properties(input-ogr PROPERTIES PREFIX "")
set_target_properties(input-ogr PROPERTIES OUTPUT_NAME "ogr")
set_target_properties(input-ogr PROPERTIES SUFFIX ".input")
set_target_properties(input-ogr PROPERTIES
OUTPUT_NAME "ogr"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
)
mapnik_install(TARGET input-ogr IS_PLUGIN)
mapnik_install_plugin(input-ogr)

View file

@ -7,15 +7,13 @@ add_library(input-pgraster MODULE
pgraster_featureset.cpp
pgraster_wkb_reader.cpp
)
add_library(mapnik::plugin::input::pgraster ALIAS input-pgraster)
target_link_libraries(input-pgraster PRIVATE
mapnik::mapnik
PostgreSQL::PostgreSQL
)
set_target_properties(input-pgraster PROPERTIES PREFIX "")
set_target_properties(input-pgraster PROPERTIES OUTPUT_NAME "pgraster")
set_target_properties(input-pgraster PROPERTIES SUFFIX ".input")
mapnik_install(TARGET input-pgraster IS_PLUGIN)
set_target_properties(input-pgraster PROPERTIES
OUTPUT_NAME "pgraster"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
)
mapnik_install_plugin(input-pgraster)

View file

@ -6,15 +6,14 @@ add_library(input-postgis MODULE
postgis_datasource.cpp
postgis_featureset.cpp
)
add_library(mapnik::plugin::input::postgis ALIAS input-postgis)
target_link_libraries(input-postgis PRIVATE
mapnik::mapnik
PostgreSQL::PostgreSQL
)
set_target_properties(input-postgis PROPERTIES
OUTPUT_NAME "postgis"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
)
set_target_properties(input-postgis PROPERTIES PREFIX "")
set_target_properties(input-postgis PROPERTIES OUTPUT_NAME "postgis")
set_target_properties(input-postgis PROPERTIES SUFFIX ".input")
mapnik_install(TARGET input-postgis IS_PLUGIN)
mapnik_install_plugin(input-postgis)

View file

@ -5,12 +5,11 @@ add_library(input-raster MODULE
raster_featureset.cpp
raster_info.cpp
)
add_library(mapnik::plugin::input::raster ALIAS input-raster)
target_link_libraries(input-raster PRIVATE mapnik::mapnik)
set_target_properties(input-raster PROPERTIES
OUTPUT_NAME "raster"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
)
set_target_properties(input-raster PROPERTIES PREFIX "")
set_target_properties(input-raster PROPERTIES OUTPUT_NAME "raster")
set_target_properties(input-raster PROPERTIES SUFFIX ".input")
mapnik_install(TARGET input-raster IS_PLUGIN)
mapnik_install_plugin(input-raster)

View file

@ -8,12 +8,11 @@ add_library(input-shape MODULE
shape_index_featureset.cpp
shape_io.cpp shape_utils.cpp
)
add_library(mapnik::plugin::input::shape ALIAS input-shape)
target_link_libraries(input-shape PRIVATE mapnik::mapnik)
set_target_properties(input-shape PROPERTIES
OUTPUT_NAME "shape"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
)
set_target_properties(input-shape PROPERTIES PREFIX "")
set_target_properties(input-shape PROPERTIES OUTPUT_NAME "shape")
set_target_properties(input-shape PROPERTIES SUFFIX ".input")
mapnik_install(TARGET input-shape IS_PLUGIN)
mapnik_install_plugin(input-shape)

View file

@ -7,14 +7,14 @@ add_library(input-sqlite MODULE
sqlite_featureset.cpp
)
add_library(mapnik::plugin::input::sqlite ALIAS input-sqlite)
target_link_libraries(input-sqlite PRIVATE
mapnik::mapnik
SQLite::SQLite3
)
set_target_properties(input-sqlite PROPERTIES
OUTPUT_NAME "sqlite"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
)
set_target_properties(input-sqlite PROPERTIES PREFIX "")
set_target_properties(input-sqlite PROPERTIES OUTPUT_NAME "sqlite")
set_target_properties(input-sqlite PROPERTIES SUFFIX ".input")
mapnik_install(TARGET input-sqlite IS_PLUGIN)
mapnik_install_plugin(input-sqlite)

View file

@ -5,14 +5,14 @@ add_library(input-topojson MODULE
topojson_featureset.cpp
)
add_library(mapnik::plugin::input::topojson ALIAS input-topojson)
target_link_libraries(input-topojson PRIVATE
mapnik::mapnik
mapnik::json
)
set_target_properties(input-topojson PROPERTIES
OUTPUT_NAME "topojson"
PREFIX "${_plugin_prefix}"
SUFFIX "${_plugin_suffix}"
)
set_target_properties(input-topojson PROPERTIES PREFIX "")
set_target_properties(input-topojson PROPERTIES OUTPUT_NAME "topojson")
set_target_properties(input-topojson PROPERTIES SUFFIX ".input")
mapnik_install(TARGET input-topojson IS_PLUGIN)
mapnik_install_plugin(input-topojson)

View file

@ -303,4 +303,4 @@ if(MSVC)
target_compile_options(mapnik PUBLIC "/bigobj" "/wd4068" "/wd4661" "/wd4910")
endif()
mapnik_install(TARGET mapnik)
mapnik_install(mapnik)

View file

@ -31,4 +31,4 @@ set_target_properties(json PROPERTIES
PREFIX "libmapnik-"
)
mapnik_install(TARGET json)
mapnik_install(json)

View file

@ -23,4 +23,4 @@ set_target_properties(wkt PROPERTIES
PREFIX "libmapnik-"
)
mapnik_install(TARGET wkt)
mapnik_install(wkt)

View file

@ -4,4 +4,4 @@ add_executable(geometry_to_wkb main.cpp)
target_link_libraries(geometry_to_wkb PRIVATE mapnik::mapnik)
mapnik_install(TARGET geometry_to_wkb)
mapnik_install(geometry_to_wkb)

View file

@ -15,4 +15,4 @@ target_link_libraries(mapnik-index PRIVATE
Boost::program_options
)
mapnik_install(TARGET mapnik-index)
mapnik_install(mapnik-index)

View file

@ -9,4 +9,4 @@ target_link_libraries(mapnik-render PRIVATE
Boost::program_options
)
mapnik_install(TARGET mapnik-render)
mapnik_install(mapnik-render)

View file

@ -4,4 +4,4 @@ add_executable(ogrindex ogrindex.cpp)
target_link_libraries(ogrindex PRIVATE mapnik::mapnik)
mapnik_install(TARGET ogrindex)
mapnik_install(ogrindex)

View file

@ -16,4 +16,4 @@ target_link_libraries(pgsql2sqlite PRIVATE
mapnik::mapnik
)
mapnik_install(TARGET pgsql2sqlite)
mapnik_install(pgsql2sqlite)

View file

@ -12,4 +12,4 @@ target_link_libraries(shapeindex PRIVATE
mapnik::mapnik
)
mapnik_install(TARGET shapeindex)
mapnik_install(shapeindex)

View file

@ -12,4 +12,4 @@ target_link_libraries(svg2png PRIVATE
mapnik::agg
)
mapnik_install(TARGET svg2png)
mapnik_install(svg2png)