Skip to content

Commit

Permalink
Use libjpeg-turbo in ext/libjpeg.cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
y-guyon committed Feb 6, 2024
1 parent 2790a81 commit 56e25e3
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 12 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,13 @@ jobs:
-I.\apps\shared -I.\include -I.\third_party\iccjpeg
-external:W0
-external:I.\ext\libpng
-external:I.\ext\libjpeg
-external:I.\ext\libjpeg-turbo
-external:I.\ext\libjpeg-turbo\build.libavif
-external:I.\ext\zlib
-external:I.\build\ext\libpng
-external:I.\build\ext\zlib
/link
build\ext\libjpeg\jpeg.lib
ext\libjpeg-turbo\build.libavif\jpeg-static.lib
build\ext\libpng\libpng16_static.lib
build\ext\zlib\zlibstatic.lib
build\avif.lib
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
/ext/gpac
/ext/libargparse
/ext/libjpeg
/ext/libjpeg-turbo
/ext/libgav1
/ext/libpng
/ext/libwebp
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Fix ID selection for artificial grid alpha item when decoding a grid of tiles
which each have an associated auxiliary alpha image item
(https://crbug.com/oss-fuzz/65657).
* ext/libjpeg.cmd now pulls libjpeg-turbo instead of libjpeg and AVIF_JPEG=LOCAL
now expects the library dependency in ext/libjpeg-turbo/build.libavif.

## [1.0.3] - 2023-12-03

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ if(WIN32)
avif_exclude_safe(minigzip)
endif()
if(AVIF_LOCAL_JPEG)
avif_set_folder_safe(jpeg "ext/libjpeg")
avif_set_folder_safe(JPEG::JPEG "ext/libjpeg-turbo")
endif()
if(AVIF_LOCAL_LIBXML2)
avif_set_folder_safe(xml2 "ext/libxml2")
Expand Down
21 changes: 16 additions & 5 deletions cmake/Modules/LocalJpeg.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
add_subdirectory(${AVIF_SOURCE_DIR}/ext/libjpeg EXCLUDE_FROM_ALL)
set(LIB_FOLDER "${AVIF_SOURCE_DIR}/ext/libjpeg-turbo/build.libavif")
if(WIN32)
set(LIB_FILENAME "${LIB_FOLDER}/${CMAKE_STATIC_LIBRARY_PREFIX}jpeg-static${CMAKE_STATIC_LIBRARY_SUFFIX}")
else()
set(LIB_FILENAME "${LIB_FOLDER}/${CMAKE_STATIC_LIBRARY_PREFIX}jpeg${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
if(NOT EXISTS "${LIB_FILENAME}")
message(FATAL_ERROR "libavif: ${LIB_FILENAME} is missing, bailing out")
endif()

set_property(TARGET jpeg PROPERTY AVIF_LOCAL ON)
set(JPEG_INCLUDE_DIR "${AVIF_SOURCE_DIR}/ext/libjpeg")
target_include_directories(jpeg INTERFACE ${JPEG_INCLUDE_DIR})
add_library(JPEG::JPEG STATIC IMPORTED GLOBAL)
set_target_properties(JPEG::JPEG PROPERTIES IMPORTED_LOCATION "${LIB_FILENAME}" AVIF_LOCAL ON)
set(JPEG_INCLUDE_DIR "${AVIF_SOURCE_DIR}/ext/libjpeg-turbo")
target_include_directories(JPEG::JPEG INTERFACE "${JPEG_INCLUDE_DIR}")

add_library(JPEG::JPEG ALIAS jpeg)
# Also add the build directory path because it contains jconfig.h,
# which is included by jpeglib.h.
target_include_directories(JPEG::JPEG INTERFACE "${LIB_FOLDER}")
9 changes: 6 additions & 3 deletions ext/libjpeg.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
: # If you want to use a local build of jpeg, you must clone the repos in this directory first,
: # then enable CMake's AVIF_LOCAL_JPEG.
: # This git tag isn't likely to move much, as libjpeg isn't actively developed anymore.
: # then set CMake's AVIF_JPEG=LOCAL.
: # The git tags below are known to work, and will occasionally be updated. Feel free to use a more recent commit.

: # The odd choice of comment style in this file is to try to share this script between *nix and win32.

git clone --depth 1 https://github.com/joedrago/libjpeg.git
git clone -b 3.0.2 --depth 1 https://github.com/libjpeg-turbo/libjpeg-turbo.git

cmake -S libjpeg-turbo -B libjpeg-turbo/build.libavif -G Ninja -DENABLE_SHARED=OFF -DENABLE_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DWITH_TURBOJPEG=OFF
cmake --build libjpeg-turbo/build.libavif --parallel
2 changes: 1 addition & 1 deletion ext/zlibpng.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
: # If you want to use a local build of zlib/libpng, you must clone the repos in this directory first,
: # then enable CMake's AVIF_LOCAL_ZLIBPNG.
: # then set CMake's AVIF_ZLIBPNG=LOCAL.
: # The git tags below are known to work, and will occasionally be updated. Feel free to use a more recent commit.

: # The odd choice of comment style in this file is to try to share this script between *nix and win32.
Expand Down

0 comments on commit 56e25e3

Please sign in to comment.