Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ jobs:
setenvs: export OpenImageIO_BUILD_LOCAL_DEPS=all
OpenImageIO_DEPENDENCY_BUILD_VERBOSE=ON
LIBRAW_VERSION=0.21.4
OPENJPEG_VERSION=v2.5.4
PTEX_VERSION=v2.4.2
PUGIXML_VERSION=v1.14
WEBP_VERSION=v1.4.0
Expand Down
32 changes: 32 additions & 0 deletions src/cmake/build_OpenJPEG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/Academ SoftwareFoundation/OpenImageIO

set_cache (OpenJPEG_BUILD_VERSION 2.5.4 "OpenJPEG version for local builds")
set (OpenJPEG_GIT_REPOSITORY "https://github.com/uclouvain/openjpeg.git")
set (OpenJPEG_GIT_TAG "v${OpenJPEG_BUILD_VERSION}")
set_cache (OpenJPEG_BUILD_SHARED_LIBS ${LOCAL_BUILD_SHARED_LIBS_DEFAULT}
DOC "Should a local OpenJPEG build, if necessary, build shared libraries" ADVANCED)


string (MAKE_C_IDENTIFIER ${OpenJPEG_BUILD_VERSION} OpenJPEG_VERSION_IDENT)

build_dependency_with_cmake(OpenJPEG
VERSION ${OpenJPEG_BUILD_VERSION}
GIT_REPOSITORY ${OpenJPEG_GIT_REPOSITORY}
GIT_TAG ${OpenJPEG_GIT_TAG}
CMAKE_ARGS
-D BUILD_CODEC=OFF
-D CMAKE_POSITION_INDEPENDENT_CODE=ON
)
# Set some things up that we'll need for a subsequent find_package to work
set (OpenJPEG_ROOT ${OpenJPEG_LOCAL_INSTALL_DIR})


# Signal to caller that we need to find again at the installed location
set (OpenJPEG_REFIND TRUE)
set (OpenJPEG_REFIND_ARGS CONFIG)

if (OpenJPEG_BUILD_SHARED_LIBS)
install_local_dependency_libs (OpenJPEG openjp2)
endif ()
3 changes: 2 additions & 1 deletion src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ checked_find_package (LibRaw

checked_find_package (OpenJPEG VERSION_MIN 2.0
RECOMMEND_MIN 2.2
RECOMMEND_MIN_REASON "for multithreading support")
RECOMMEND_MIN_REASON "for multithreading support"
PREFER_CONFIG)
# Note: Recent OpenJPEG versions have exported cmake configs, but we don't
# find them reliable at all, so we stick to our FindOpenJPEG.cmake module.

Expand Down
9 changes: 9 additions & 0 deletions src/cmake/modules/FindOpenJPEG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,15 @@ if (OPENJPEG_FOUND)
foreach (tmplib ${OpenJpeg_libvars})
list (APPEND OPENJPEG_LIBRARIES ${${tmplib}})
endforeach ()

if (NOT TARGET openjp2)
add_library(openjp2 UNKNOWN IMPORTED)
set_target_properties(openjp2 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OPENJPEG_INCLUDES}")
set_property(TARGET openjp2 APPEND PROPERTY
IMPORTED_LOCATION "${OPENJPEG_LIBRARIES}")
endif()

if (NOT OpenJpeg_FIND_QUIETLY)
FIND_PACKAGE_MESSAGE (OPENJPEG
"Found OpenJpeg: v${OPENJPEG_VERSION} ${OPENJPEG_LIBRARIES}"
Expand Down
15 changes: 12 additions & 3 deletions src/jpeg2000.imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
# https://github.com/AcademySoftwareFoundation/OpenImageIO

if (OPENJPEG_FOUND)
set(_jpeg2000_includes ${OPENJPEG_INCLUDES})
set(_jpeg2000_lib_dirs ${OPENJPEG_LIBRARY_DIRS})
set(_jpeg2000_libs ${OPENJPEG_LIBRARIES})
if (TARGET openjp2_static AND (LINKSTATIC OR NOT TARGET openjp2))
# Use static OpenJPEG library for LINKSTATIC situations, or if
# no dynamic library is available.
set (OPENJPEG_TARGET openjp2_static)
elseif (TARGET openjp2)
set (OPENJPEG_TARGET openjp2)
else ()
set(_jpeg2000_includes ${OPENJPEG_INCLUDES})
set(_jpeg2000_lib_dirs ${OPENJPEG_LIBRARY_DIRS})
set(_jpeg2000_libs ${OPENJPEG_LIBRARIES})
endif ()
set(_jpeg2000_defs "USE_OPENJPEG")

if (openjph_FOUND)
Expand All @@ -16,6 +24,7 @@ if (OPENJPEG_FOUND)
INCLUDE_DIRS ${_jpeg2000_includes}
LINK_DIRECTORIES ${_jpeg2000_lib_dirs}
LINK_LIBRARIES ${_jpeg2000_libs}
${OPENJPEG_TARGET}
$<TARGET_NAME_IF_EXISTS:openjph>
DEFINITIONS ${_jpeg2000_defs}
)
Expand Down
Loading