2023-02-04 07:10:25 +00:00
|
|
|
set(TARGET whisper-addon)
|
|
|
|
|
|
|
|
# Base settings
|
|
|
|
#==================================================================
|
|
|
|
# env var supported by cmake-js
|
|
|
|
add_definitions(-DNAPI_VERSION=4)
|
|
|
|
include_directories(${CMAKE_JS_INC})
|
|
|
|
#==================================================================
|
|
|
|
|
|
|
|
add_library(${TARGET} SHARED ${CMAKE_JS_SRC} addon.cpp)
|
|
|
|
set_target_properties(${TARGET} PROPERTIES PREFIX "" SUFFIX ".node")
|
|
|
|
|
|
|
|
include(DefaultTargetOptions)
|
|
|
|
|
|
|
|
# Include N-API wrappers
|
|
|
|
#==================================================================
|
|
|
|
execute_process(COMMAND node -p "require('node-addon-api').include"
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_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(${TARGET} PRIVATE ${NODE_ADDON_API_DIR})
|
|
|
|
#==================================================================
|
|
|
|
|
2023-02-15 17:28:10 +00:00
|
|
|
target_link_libraries(${TARGET} ${CMAKE_JS_LIB} common whisper ${CMAKE_THREAD_LIBS_INIT})
|
2023-02-05 13:02:08 +00:00
|
|
|
|
|
|
|
if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
|
|
|
|
# Generate node.lib
|
|
|
|
execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS})
|
|
|
|
endif()
|