forked from nodegui/nodegui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnapi.cmake
More file actions
27 lines (21 loc) · 775 Bytes
/
napi.cmake
File metadata and controls
27 lines (21 loc) · 775 Bytes
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
# NAPI stuff
function(AddNapiSupport addonName)
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})
set_target_properties(${addonName} PROPERTIES PREFIX "" SUFFIX ".node")
target_include_directories(${addonName} PRIVATE
"${NODE_ADDON_API_DIR}"
)
target_compile_definitions(${addonName} PRIVATE
NAPI_CPP_EXCEPTIONS
)
if (WIN32)
target_compile_definitions(${addonName} PRIVATE
_HAS_EXCEPTIONS=1
)
endif()
endfunction(AddNapiSupport addonName)