Skip to content

Commit

Permalink
Changed native dependencies install method
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannicalo committed Jan 18, 2024
1 parent 6d34005 commit dc0c114
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 29 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.vscode
build
coverage
libraries
node_modules
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ build
coverage
jest.config.js
jsconfig.json
libraries
test
27 changes: 21 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@ if(MSVC)
set(WITH_CRT_DLL FALSE)
endif()

include_directories(${CMAKE_JS_INC})

add_definitions(-DNAPI_VERSION=8)

include(ExternalProject)

ExternalProject_Add(
jpeg
BUILD_COMMAND cmake --build . --config ${CMAKE_BUILD_TYPE} --target turbojpeg-static
CMAKE_ARGS -DCMAKE_POSITION_INDEPENDENT_CODE=ON
GIT_REPOSITORY "https://github.com/libjpeg-turbo/libjpeg-turbo.git"
GIT_TAG "2.1.5.1"
INSTALL_COMMAND ""
)

file(GLOB_RECURSE source "source/native/*")

add_library(${PROJECT_NAME} SHARED ${source} ${CMAKE_JS_SRC})
Expand All @@ -30,10 +39,16 @@ execute_process(

string(REGEX REPLACE "[\n\r\"]" "" nodeAddonApi ${nodeAddonApi})

option(ENABLE_SHARED "" FALSE)
ExternalProject_Get_Property(jpeg BINARY_DIR SOURCE_DIR)

add_subdirectory("libraries/libjpeg-turbo" EXCLUDE_FROM_ALL)
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_JS_INC} ${nodeAddonApi} ${SOURCE_DIR})

target_include_directories(${PROJECT_NAME} PRIVATE ${nodeAddonApi} "libraries/libjpeg-turbo")
target_link_directories(${PROJECT_NAME} PRIVATE ${BINARY_DIR})

if(MSVC)
set(jpeg "turbojpeg-static")
else()
set(jpeg "turbojpeg")
endif()

target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} turbojpeg-static)
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} ${jpeg})
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"dependencies": {
"bindings": "^1.5.0",
"cmake-js": "7.3.0",
"extract-zip": "^2.0.1",
"node-addon-api": "^7.0.0"
},
"description": "JPEG",
Expand All @@ -35,7 +34,7 @@
"benchmark": "node scripts/benchmark",
"build": "cmake-js compile",
"build-debug": "cmake-js compile --debug",
"install": "node scripts/install && npm run build",
"install": "npm run build",
"lint": "eslint -f pretty .",
"start": "jest --watch",
"test": "jest"
Expand Down
19 changes: 0 additions & 19 deletions scripts/install.js

This file was deleted.

0 comments on commit dc0c114

Please sign in to comment.