summaryrefslogtreecommitdiff
path: root/cmake/node.cmake
blob: 0c2f556b7dc14a1c1521c516489253650e5c0d3c (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
# Load Node.js
include(cmake/NodeJS.cmake)
nodejs_init()

add_nodejs_module(mbgl-node
    platform/node/src/node_mapbox_gl_native.cpp
)

# NodeJS.cmake forces C++11.
# https://github.com/cjntaylor/node-cmake/issues/18
set_target_properties("mbgl-node" PROPERTIES CXX_STANDARD 14)

target_sources(mbgl-node
    PRIVATE platform/node/src/node_logging.hpp
    PRIVATE platform/node/src/node_logging.cpp
    PRIVATE platform/node/src/node_conversion.hpp
    PRIVATE platform/node/src/node_map.hpp
    PRIVATE platform/node/src/node_map.cpp
    PRIVATE platform/node/src/node_request.hpp
    PRIVATE platform/node/src/node_request.cpp
    PRIVATE platform/node/src/node_feature.hpp
    PRIVATE platform/node/src/node_feature.cpp
    PRIVATE platform/node/src/node_thread_pool.hpp
    PRIVATE platform/node/src/node_thread_pool.cpp
    PRIVATE platform/node/src/node_expression.hpp
    PRIVATE platform/node/src/node_expression.cpp
    PRIVATE platform/node/src/util/async_queue.hpp
)

target_include_directories(mbgl-node
    PRIVATE platform/default
)

# Use node-provided uv.h. This is not part of loop-uv.cmake because loop-uv.cmake is also
# used by linux/config.cmake, where we need to use headers provided by mason's libuv.
target_include_directories(mbgl-loop-uv PUBLIC ${NODEJS_INCLUDE_DIRS})

target_link_libraries(mbgl-node
    PRIVATE mbgl-core
    PRIVATE mbgl-loop-uv
)

target_add_mason_package(mbgl-node PRIVATE geojson)

add_custom_command(
    TARGET mbgl-node
    POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:mbgl-node> ${CMAKE_SOURCE_DIR}/lib/mapbox_gl_native.node
)

mbgl_platform_node()

create_source_groups(mbgl-node)

initialize_xcode_cxx_build_settings(mbgl-node)

xcode_create_scheme(
    TARGET mbgl-node
)

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

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

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

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

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