-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
143 lines (130 loc) · 4.38 KB
/
CMakeLists.txt
File metadata and controls
143 lines (130 loc) · 4.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
cmake_minimum_required(VERSION 3.15)
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
project(node-mapnik)
set(MAPBOX_WAGYU_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/deps/wagyu/include" CACHE INTERNAL "wagyu include dir")
set(BUILD_TESTING OFF)
set(MAPNIK_VECTOR_TILE_ENABLE_INSTALL OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(Threads REQUIRED)
find_package(PkgConfig)
pkg_check_modules(Cairo REQUIRED IMPORTED_TARGET cairo)
pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET proj)
find_package(Protobuf REQUIRED)
find_package(mapnik CONFIG REQUIRED COMPONENTS shapeindex mapnik-index)
include(FetchContent)
FetchContent_Declare(
napi_modules
GIT_REPOSITORY https://github.com/mathisloge/cmake-napi.git
GIT_TAG cdc5203c12f7e44ccb260b315256590d54b574af
)
FetchContent_Declare(
mapnik_vector_tile
GIT_REPOSITORY https://github.com/mathisloge/mapnik-vector-tile.git
GIT_TAG 4ad96069d5241a592d326ee0eca1ce89cf33372f
GIT_SUBMODULES "src" # https://gitlab.kitware.com/cmake/cmake/-/issues/20579
)
FetchContent_MakeAvailable(mapnik_vector_tile napi_modules)
FetchContent_GetProperties(napi_modules SOURCE_DIR napi_src)
list(APPEND CMAKE_MODULE_PATH "${napi_src}/modules")
include(napi-gyp)
execute_process(COMMAND node -p "require('node-addon-api').include"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE NODE_ADDON_API_DIR
)
string(REPLACE "\n" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
string(REPLACE "\"" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
add_subdirectory(deps)
mapnik_find_plugin_dir(MAPNIK_PLUGINS_DIR)
message(STATUS "Using plugins from ${MAPNIK_PLUGINS_DIR}")
add_library(node-mapnik MODULE
src/mapnik_logger.cpp
src/node_mapnik.cpp
src/blend.cpp
src/mapnik_map.cpp
src/mapnik_map_load.cpp
src/mapnik_map_from_string.cpp
src/mapnik_map_render.cpp
src/mapnik_map_query_point.cpp
src/mapnik_color.cpp
src/mapnik_geometry.cpp
src/mapnik_feature.cpp
src/mapnik_image.cpp
src/mapnik_image_encode.cpp
src/mapnik_image_open.cpp
src/mapnik_image_fill.cpp
src/mapnik_image_save.cpp
src/mapnik_image_from_bytes.cpp
src/mapnik_image_from_svg.cpp
src/mapnik_image_solid.cpp
src/mapnik_image_multiply.cpp
src/mapnik_image_clear.cpp
src/mapnik_image_copy.cpp
src/mapnik_image_resize.cpp
src/mapnik_image_compositing.cpp
src/mapnik_image_filter.cpp
src/mapnik_image_view.cpp
src/mapnik_grid.cpp
src/mapnik_grid_view.cpp
src/mapnik_palette.cpp
src/mapnik_projection.cpp
src/mapnik_layer.cpp
src/mapnik_datasource.cpp
src/mapnik_featureset.cpp
src/mapnik_expression.cpp
src/mapnik_cairo_surface.cpp
src/mapnik_vector_tile.cpp
src/mapnik_vector_tile_data.cpp
src/mapnik_vector_tile_query.cpp
src/mapnik_vector_tile_json.cpp
src/mapnik_vector_tile_info.cpp
src/mapnik_vector_tile_simple_valid.cpp
src/mapnik_vector_tile_render.cpp
src/mapnik_vector_tile_clear.cpp
src/mapnik_vector_tile_image.cpp
src/mapnik_vector_tile_composite.cpp
)
set_target_properties(node-mapnik PROPERTIES PREFIX "" OUTPUT_NAME "mapnik" SUFFIX ".node")
target_include_directories(node-mapnik PRIVATE
${NODE_ADDON_API_DIR}
)
target_compile_definitions(node-mapnik PRIVATE
_USE_MATH_DEFINES
MAPNIK_GIT_REVISION=1
)
if(MSVC)
target_compile_definitions(node-mapnik PRIVATE /wd4068)
endif()
target_link_libraries(node-mapnik
mapnik::core
mapnik::json
mapnik::wkt
mapnik::mapnik
mapbox-geometry
mapbox-wagyu
mapbox-protozero
node::napi
mapnik::mapnik-vector-tile
)
# post build
file(GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>_copy.cmake"
INPUT "${CMAKE_CURRENT_SOURCE_DIR}/cmake/post_build.cmake"
)
# installation
macro(install_variable var)
install(CODE "set(${var} \"${${var}}\")")
endmacro()
install(TARGETS node-mapnik
RUNTIME_DEPENDENCY_SET node-mapnik-deps
RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}"
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}"
)
install_variable(MAPNIK_FONTS_DIR)
install_variable(MAPNIK_PLUGINS_DIR)
install_variable(VCPKG_INSTALLED_DIR)
install_variable(VCPKG_TARGET_TRIPLET)
install(CODE "set(SOURCE_DIR \"${CMAKE_CURRENT_SOURCE_DIR}\")")
install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>_copy.cmake)