-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
53 lines (42 loc) · 1.37 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.13)
project(node_portmapping VERSION 0.3.4)
include_directories(${CMAKE_JS_INC})
set(CMAKE_BUILD_TYPE Release)
include(FetchContent)
FetchContent_Declare(
libplum
GIT_REPOSITORY https://github.com/paullouisageneau/libplum.git
GIT_TAG "v0.5.1"
)
FetchContent_GetProperties(libplum)
if(NOT libplum_POPULATED)
FetchContent_Populate(libplum)
add_subdirectory(${libplum_SOURCE_DIR} ${libplum_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
add_library(${PROJECT_NAME} SHARED
src/wrapper.cpp
src/mapping.cpp
src/callback.cpp
src/main.cpp
${CMAKE_JS_SRC}
)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
target_link_libraries(${PROJECT_NAME} PRIVATE
LibPlum::LibPlumStatic
${CMAKE_JS_LIB}
)
# Include node-addon-api wrappers
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})
target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_API_DIR})
if(UNIX AND NOT APPLE)
target_link_libraries(${PROJECT_NAME} PRIVATE
-static-libgcc
-static-libstdc++
)
endif()