summaryrefslogtreecommitdiff
path: root/cmake/node.cmake
blob: 218b7548f6e9c7f3df092da9601c48fdbf8f8115 (plain)
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
# Load Node.js
set(NODE_MODULE_CACHE_DIR "${CMAKE_SOURCE_DIR}/build/headers")
include(node_modules/@mapbox/cmake-node-module/module.cmake)

add_library(mbgl-loop-node INTERFACE)

target_sources(mbgl-loop-node INTERFACE
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/default/async_task.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/default/run_loop.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/default/timer.cpp
)

target_include_directories(mbgl-loop-node INTERFACE
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${CMAKE_CURRENT_SOURCE_DIR}/src
)

create_source_groups(mbgl-loop-node)


add_node_module(mbgl-node
    INSTALL_PATH "lib/{node_abi}/mbgl.node"
    NAN_VERSION "2.10.0"
    
    # Don't build for Node 4.x, 5.x, 7.x, or 9.x
    # See https://nodejs.org/en/download/releases/ for mapping of Node version to ABI number.
    # Changes to this property should happen in tandem with updates to the version targets
    # in platform/node/scripts/publish.sh and the "node" engines property in package.json.
    EXCLUDE_NODE_ABIS 46 47 51 59
)

target_sources(mbgl-node INTERFACE
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_mapbox_gl_native.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_mapbox_gl_native.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_logging.hpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_logging.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_conversion.hpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_map.hpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_map.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_request.hpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_request.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_feature.hpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_feature.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_thread_pool.hpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_thread_pool.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_expression.hpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/node_expression.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/node/src/util/async_queue.hpp
)

target_include_directories(mbgl-node INTERFACE
    ${CMAKE_CURRENT_SOURCE_DIR}/platform/default
)

target_link_libraries(mbgl-node INTERFACE
    mbgl-core
    mbgl-loop-node
)

target_add_mason_package(mbgl-node INTERFACE geojson)

add_custom_target(mbgl-node.active DEPENDS mbgl-node.abi-${NodeJS_ABI})

mbgl_platform_node()

create_source_groups(mbgl-node)

foreach(ABI IN LISTS mbgl-node::abis)
    initialize_xcode_cxx_build_settings(mbgl-node.abi-${ABI})
    xcode_create_scheme(
        TARGET mbgl-node.abi-${ABI}
        NAME "mbgl-node (ABI ${ABI})"
    )
endforeach()

xcode_create_scheme(
    TARGET mbgl-node.active
    TYPE library
    NAME "mbgl-node (Active ABI)"
)

xcode_create_scheme(
    TARGET mbgl-node.all
    TYPE library
    NAME "mbgl-node (All ABIs)"
)

xcode_create_scheme(
    TARGET mbgl-node.active
    TYPE node
    NAME "node tests (Active ABI)"
    ARGS
        "node_modules/.bin/tape platform/node/test/js/**/*.test.js"
)

xcode_create_scheme(
    TARGET mbgl-node.active
    TYPE node
    NAME "node render tests (Active ABI)"
    ARGS
        "platform/node/test/render.test.js"
    OPTIONAL_ARGS
        "group"
        "test"
)

xcode_create_scheme(
    TARGET mbgl-node.active
    TYPE node
    NAME "node query tests (Active ABI)"
    ARGS
        "platform/node/test/query.test.js"
    OPTIONAL_ARGS
        "group"
        "test"
)

xcode_create_scheme(
    TARGET mbgl-node.active
    TYPE node
    NAME "node expression tests (Active ABI)"
    ARGS
        "platform/node/test/expression.test.js"
    OPTIONAL_ARGS
        "group"
        "test"
)

xcode_create_scheme(
    TARGET mbgl-node.active
    TYPE node
    NAME "node-benchmark (Active ABI)"
    ARGS
        "platform/node/test/benchmark.js"
    OPTIONAL_ARGS
        "group"
        "test"
)