forked from atanmarko/safex-nodejs-libwallet
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
79 lines (64 loc) · 2.54 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
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
cmake_minimum_required(VERSION 2.8)
# Name of the project (will be the name of the plugin)
project(safex)
set (CMAKE_CXX_STANDARD 11)
file(GLOB BOOST_LIBS
"deps/libboost*.a"
)
if(BUILD_WIN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNODE_HOST_BINARY=node.exe")
set(WIN_DELAY_LOAD_HOOK ${CMAKE_CURRENT_SOURCE_DIR}/win_delay_load_hook.cc)
set(LIBNODE ${CMAKE_CURRENT_SOURCE_DIR}/deps/libnode.a)
endif()
file(GLOB SOURCE_FILES "src/*.cc" "src/*.h")
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${WIN_DELAY_LOAD_HOOK})
# Gives our library file a .node extension without any "lib" prefix
set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
# Essential include files to build a node addon,
# You should add this line in every CMake.js based project
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_JS_INC} include/)
# INCLUDE N-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})
set(CMAKE_CXX_STANDARD_LIBRARIES " -std=c++11 ${CMAKE_CXX_STANDARD_LIBRARIES}")
# Essential library files to link to a node addon
# You should add this line in every CMake.js based project
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} ${CMAKE_THREAD_LIBS_INIT})
if(BUILD_WIN)
target_link_libraries(${PROJECT_NAME}
${CMAKE_SOURCE_DIR}/deps/libwallet_api.dll.a
${LIBNODE}
)
elseif(APPLE)
target_link_libraries(${PROJECT_NAME}
${CMAKE_SOURCE_DIR}/deps/libwallet_merged.a
${CMAKE_SOURCE_DIR}/deps/libunbound.a
${CMAKE_SOURCE_DIR}/deps/libepee.a
${CMAKE_SOURCE_DIR}/deps/libeasylogging.a
${CMAKE_SOURCE_DIR}/deps/liblmdb.a
/usr/local/opt/[email protected]/lib/libssl.a
/usr/local/opt/[email protected]/lib/libcrypto.a
z
"-framework PCSC"
${BOOST_LIBS}
)
else()
target_link_libraries(${PROJECT_NAME}
${CMAKE_SOURCE_DIR}/deps/libwallet_merged.a
${CMAKE_SOURCE_DIR}/deps/libunbound.a
${CMAKE_SOURCE_DIR}/deps/libepee.a
${CMAKE_SOURCE_DIR}/deps/libeasylogging.a
${CMAKE_SOURCE_DIR}/deps/liblmdb.a
ssl
z
crypto
pcsclite
${BOOST_LIBS}
)
endif()