Skip to content

Commit

Permalink
build: Use exported targets for libjpeg-turbo and bump min to 2.1 (#3987
Browse files Browse the repository at this point in the history
)

libjpeg-turbo has exported cmake configs since its version 2.1. Relying
on this simplifies the build and allows us to completely remove the
troublesome Findlibjpeg-turbo.cmake. This implies raising the floor for
libjpeg-turbo support to 2.1 (the current release is 3.0) which was
released in April 2021 (beta in Nov 2020).

That's cutting it a little close (we usually support dependencies going
back at least 3 years at a minimum, and often significantly longer). But
since this is an optional dependency anyway and simplifies the build,
I'm tempted to do so.

Signed-off-by: Larry Gritz <[email protected]>
  • Loading branch information
lgritz authored Sep 22, 2023
1 parent 6f99f27 commit 96036be
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 77 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ jobs:
pybind11_ver: v2.11.1
python_ver: "3.10"
simd: avx2,f16c
setenvs: export LIBRAW_VERSION=0.20.2
setenvs: export LIBJPEGTURBO_VERSION=3.0.0
LIBRAW_VERSION=0.20.2
LIBTIFF_VERSION=v4.5.0
OPENCOLORIO_VERSION=v2.3.0
OPENJPEG_VERSION=v2.4.0
Expand All @@ -320,7 +321,8 @@ jobs:
pybind11_ver: master
python_ver: "3.10"
simd: avx2,f16c
setenvs: export LIBRAW_VERSION=master
setenvs: export LIBJPEGTURBO_VERSION=main
LIBRAW_VERSION=master
LIBTIFF_VERSION=master
OPENCOLORIO_VERSION=main
OPENJPEG_VERSION=master
Expand Down Expand Up @@ -371,6 +373,7 @@ jobs:
openexr_ver: v2.5.8
pybind11_ver: v2.5.0
simd: avx
setenvs: export EXTRA_DEP_PACKAGES=libjpeg-turbo8-dev
- desc: static libs gcc7 C++14 exr2.4
nametag: linux-static
os: ubuntu-20.04
Expand Down
4 changes: 2 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ NEW or CHANGED MINIMUM dependencies since the last major release are **bold**.
* **OpenEXR/Imath >= 2.4** (recommended: 3.1 or higher; tested through 3.2
and main) (ADVISORY: We expect that OIIO 2.6 in 2024 will require OpenEXR >= 3.1)
* libTIFF >= 3.9 (recommended: 4.0+; tested through 4.5)
* libjpeg >= 8, or libjpeg-turbo >= 1.1 (tested through jpeg9d and jpeg-turbo
2.1)
* libjpeg >= 8 (tested through jpeg9e), or **libjpeg-turbo >= 2.1** (tested
through 3.0)
* Boost >= 1.53 (recommended: at least 1.66; tested through 1.81)
* **[fmtlib](https://github.com/fmtlib/fmt) >= 7.0** (tested through 10.1).
If not found at build time, this will be automatically downloaded unless
Expand Down
8 changes: 5 additions & 3 deletions src/build-scripts/build_libjpeg-turbo.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ set -ex

# Repo and branch/tag/commit of libjpeg-turbo to download if we don't have it yet
LIBJPEGTURBO_REPO=${LIBJPEGTURBO_REPO:=https://github.com/libjpeg-turbo/libjpeg-turbo.git}
LIBJPEGTURBO_VERSION=${LIBJPEGTURBO_VERSION:=2.0.5}
LIBJPEGTURBO_VERSION=${LIBJPEGTURBO_VERSION:=3.0.0}

# Where to put libjpeg-turbo repo source (default to the ext area)
LIBJPEGTURBO_SRC_DIR=${LIBJPEGTURBO_SRC_DIR:=${PWD}/ext/libjpeg-turbo}
LOCAL_DEPS_DIR=${LOCAL_DEPS_DIR:=${PWD}/ext}
LIBJPEGTURBO_SRC_DIR=${LIBJPEGTURBO_SRC_DIR:=${LOCAL_DEPS_DIR}/libjpeg-turbo}
# Temp build area (default to a build/ subdir under source)
LIBJPEGTURBO_BUILD_DIR=${LIBJPEGTURBO_BUILD_DIR:=${LIBJPEGTURBO_SRC_DIR}/build}
# Install area for libjpeg-turbo (default to ext/dist)
LIBJPEGTURBO_INSTALL_DIR=${LIBJPEGTURBO_INSTALL_DIR:=${PWD}/ext/dist}
LIBJPEGTURBO_INSTALL_DIR=${LIBJPEGTURBO_INSTALL_DIR:=${LOCAL_DEPS_DIR}/dist}
#LIBJPEGTURBO_CONFIG_OPTS=${LIBJPEGTURBO_CONFIG_OPTS:=}

pwd
Expand Down Expand Up @@ -50,4 +51,5 @@ popd
# Set up paths. These will only affect the caller if this script is
# run with 'source' rather than in a separate shell.
export JPEGTurbo_ROOT=$LIBJPEGTURBO_INSTALL_DIR
export libjpegturbo_ROOT=$LIBJPEGTURBO_INSTALL_DIR

4 changes: 4 additions & 0 deletions src/build-scripts/gh-installdeps.bash
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ if [[ "$ABI_CHECK" != "" ]] ; then
source src/build-scripts/build_abi_tools.bash
fi

if [[ "$LIBJPEGTURBO_VERSION" != "" ]] ; then
source src/build-scripts/build_libjpeg-turbo.bash
fi

if [[ "$USE_ICC" != "" ]] ; then
# We used gcc for the prior dependency builds, but use icc for OIIO itself
echo "which icpc:" $(which icpc)
Expand Down
11 changes: 5 additions & 6 deletions src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,11 @@ set (OPENIMAGEIO_IMATH_DEPENDENCY_VISIBILITY "PUBLIC" CACHE STRING
set (OPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH OFF CACHE BOOL
"Exclude find_dependency(Imath) from the exported OpenImageIOConfig.cmake")

# JPEG -- prefer Turbo-JPEG to regular libjpeg
checked_find_package (JPEGTurbo
DEFINITIONS -DUSE_JPEG_TURBO=1
PRINT JPEG_INCLUDES JPEG_INCLUDE_DIRS
JPEG_LIBRARIES JPEG_VERSION)
if (NOT JPEG_FOUND) # Try to find the non-turbo version
# JPEG -- prefer JPEG-Turbo to regular libjpeg
checked_find_package (libjpeg-turbo
VERSION_MIN 2.1
DEFINITIONS -DUSE_JPEG_TURBO=1)
if (NOT TARGET libjpeg-turbo::jpeg) # Try to find the non-turbo version
checked_find_package (JPEG REQUIRED)
endif ()

Expand Down
59 changes: 0 additions & 59 deletions src/cmake/modules/FindJPEGTurbo.cmake

This file was deleted.

8 changes: 5 additions & 3 deletions src/jpeg.imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: BSD-3-Clause and Apache-2.0
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio

add_oiio_plugin (jpeginput.cpp jpegoutput.cpp
INCLUDE_DIRS ${JPEG_INCLUDE_DIRS}
LINK_LIBRARIES JPEG::JPEG)
LINK_LIBRARIES
$<TARGET_NAME_IF_EXISTS:libjpeg-turbo::jpeg>
$<TARGET_NAME_IF_EXISTS:JPEG::JPEG>
)
11 changes: 9 additions & 2 deletions src/tiff.imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: BSD-3-Clause and Apache-2.0
# SPDX-License-Identifier: Apache-2.0
# https://github.com/OpenImageIO/oiio

add_oiio_plugin (tiffinput.cpp tiffoutput.cpp
LINK_LIBRARIES TIFF::TIFF JPEG::JPEG ZLIB::ZLIB)
LINK_LIBRARIES TIFF::TIFF
ZLIB::ZLIB
$<TARGET_NAME_IF_EXISTS:libjpeg-turbo::jpeg>
$<TARGET_NAME_IF_EXISTS:JPEG::JPEG>
)

# TODO: It's not clear that we need to explicitly list the ZLIB and JPEG
# targets here, or if TIFF::TIFF is expected to carry them along if needed.

0 comments on commit 96036be

Please sign in to comment.