-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
62 lines (48 loc) · 1.85 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
cmake_minimum_required(VERSION 3.10)
if (WIN32)
include( helpers/CMakeExtras.txt OPTIONAL )
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE AND DEFINED ENV{CMAKE_TOOLCHAIN_FILE})
set(CMAKE_TOOLCHAIN_FILE $ENV{CMAKE_TOOLCHAIN_FILE})
endif()
message("Using CMAKE_TOOLCHAIN_FILE ${ENV} ${CMAKE_TOOLCHAIN_FILE}")
# Uncomment this to dump env vars:
# get_cmake_property(_variableNames VARIABLES)
# list (SORT _variableNames)
# foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
# endforeach()
if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
message(FATAL_ERROR "Cmake toolchain file was not found. Set it as an system enviornment variable and restart")
endif()
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
project( node-leveldb )
add_subdirectory( leveldb-mcpe )
if (UNIX)
add_definitions(-DLEVELDB_PLATFORM_POSIX "-DDLLX=")
if(APPLE)
add_definitions(-DOS_MACOSX)
endif()
elseif (WIN32)
add_definitions(-DLEVELDB_PLATFORM_WINDOWS "-DDLLX=__declspec(dllexport)")
endif()
include_directories("leveldb-mcpe/include"})
include_directories(${CMAKE_JS_INC})
file(GLOB SOURCE_FILES "src/*.cpp" "src/*.h")
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
# Include N-API wrappers
include_directories(
${CMAKE_SOURCE_DIR}/node_modules/node-addon-api
${CMAKE_SOURCE_DIR}/node_modules/node-addon-api/src
${CMAKE_JS_INC}
)
message(STATUS "Include dirs")
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
message(STATUS "dir='${dir}'")
endforeach()
# define NPI_VERSION
add_definitions(-DNAPI_VERSION=3)
target_link_libraries( node-leveldb leveldb )