summaryrefslogtreecommitdiff
path: root/cmake/node.cmake
blob: 081b158d411acff5e547177683937d1671bf0986 (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
if(NOT EXISTS ${CMAKE_SOURCE_DIR}/node_modules/node-cmake/FindNodeJS.cmake)
    message(FATAL_ERROR "Can't find node-cmake")
endif()

set(NodeJS_CXX_STANDARD 14 CACHE INTERNAL "Use C++14" FORCE)
set(NodeJS_DOWNLOAD ON CACHE INTERNAL "Download node.js sources" FORCE)
set(NodeJS_USE_CLANG_STDLIB OFF CACHE BOOL "Don't use libc++ by default" FORCE)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/node_modules/node-cmake)
find_package(NodeJS)

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

target_sources(mbgl-node
    PRIVATE platform/node/src/node_log.hpp
    PRIVATE platform/node/src/node_log.cpp
    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/util/async_queue.hpp

    # We are compiling with the uv loop, but since this target already has the headers for libuv,
    # we don't have to install it manually.
    PRIVATE platform/default/async_task.cpp
    PRIVATE platform/default/run_loop.cpp
    PRIVATE platform/default/timer.cpp
)

target_compile_options(mbgl-node
    PRIVATE -fPIC
    PRIVATE -fvisibility-inlines-hidden
)

target_include_directories(mbgl-node
    PRIVATE src # TODO: eliminate
)

target_link_libraries(mbgl-node
    PRIVATE mbgl-core
)

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()