Skip to content

Commit

Permalink
fix(NAPI): wrong include path
Browse files Browse the repository at this point in the history
  • Loading branch information
BotellaA committed Oct 2, 2019
1 parent bf2511f commit 7e23837
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,11 @@ target_include_directories(genepi
PUBLIC
${PROJECT_SOURCE_DIR}/include
${PROJECT_BINARY_DIR}
${PROJECT_SOURCE_DIR}/node_modules/node-addon-api
${PROJECT_SOURCE_DIR}/../node-addon-api
PRIVATE
${NODE_ADDON_API_DIR}
${CMAKE_JS_INC}
)

target_link_libraries(genepi PUBLIC ${CMAKE_JS_LIB})
export(TARGETS genepi NAMESPACE genepi:: FILE genepi_target.cmake)
include(GenerateExportHeader)
Expand Down
22 changes: 21 additions & 1 deletion cmake/utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,32 @@ set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

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})

macro(add_genepi_library target_name files)
add_library(${target_name} SHARED ${files} ${CMAKE_JS_SRC})
target_include_directories(${target_name}
PUBLIC
${PROJECT_SOURCE_DIR}/include
${PROJECT_BINARY_DIR}
PRIVATE
${NODE_ADDON_API_DIR}
${CMAKE_JS_INC}
)
set_target_properties(${target_name}
PROPERTIES
PREFIX ""
SUFFIX ".node"
)
target_link_libraries(${target_name} genepi::genepi ${CMAKE_JS_LIB})
target_link_libraries(${target_name}
PUBLIC
genepi::genepi
${CMAKE_JS_LIB}
)
endmacro()

0 comments on commit 7e23837

Please sign in to comment.