Skip to content

Commit

Permalink
Improved CMake settings
Browse files Browse the repository at this point in the history
  • Loading branch information
giovannicalo committed Jan 20, 2024
1 parent 1b0b163 commit 9cd5127
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
build
coverage
libraries
16 changes: 7 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,25 @@ set(CMAKE_CXX_STANDARD 23)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(jpegLibrary turbojpeg)

if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "/MTd /Zi")
set(CMAKE_CXX_FLAGS_RELEASE "/MT")
set(WITH_CRT_DLL FALSE)
set(jpegLibrary turbojpeg-static)
endif()

add_definitions(-DNAPI_VERSION=8)

include(ExternalProject)

ExternalProject_Add(
jpeg
jpegProject
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_SHALLOW TRUE
GIT_TAG "3.0.1"
INSTALL_COMMAND ""
)
Expand All @@ -39,16 +43,10 @@ execute_process(

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

ExternalProject_Get_Property(jpeg BINARY_DIR SOURCE_DIR)
ExternalProject_Get_Property(jpegProject BINARY_DIR SOURCE_DIR)

target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_JS_INC} ${nodeAddonApi} ${SOURCE_DIR})

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} ${jpeg})
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB} ${jpegLibrary})
2 changes: 1 addition & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"module": "CommonJS",
"target": "ES2022"
},
"exclude": ["build", "coverage", "libraries", "node_modules"]
"exclude": ["build", "coverage", "node_modules"]
}

0 comments on commit 9cd5127

Please sign in to comment.