summaryrefslogtreecommitdiff
path: root/cmake/node.cmake
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-06-03 18:05:04 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-08-05 11:42:22 +0200
commit692fe1f3ffc8f4364b39c14aa7d90cec2ff5c0a6 (patch)
tree1d08af7d56e986dba2b548ff9b9a7e1a77c713ed /cmake/node.cmake
parente3ee55b28d0b230d054c9718f79a1f6d685cd62b (diff)
downloadqtlocation-mapboxgl-692fe1f3ffc8f4364b39c14aa7d90cec2ff5c0a6.tar.gz
[build] switch to CMake
This is very much a work in progress.
Diffstat (limited to 'cmake/node.cmake')
-rw-r--r--cmake/node.cmake52
1 files changed, 52 insertions, 0 deletions
diff --git a/cmake/node.cmake b/cmake/node.cmake
new file mode 100644
index 0000000000..9c8c6b074b
--- /dev/null
+++ b/cmake/node.cmake
@@ -0,0 +1,52 @@
+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
+)
+
+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()