Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions src/build-scripts/build_OpenJPEG.bash
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${OPENJPEG_INSTALL_DIR} \
-DBUILD_CODEC=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DBUILD_SHARED_LIBS=${OPENJPEG_BUILD_SHARED_LIBS:-ON} \
${OPENJPEG_CONFIG_OPTS}
time cmake --build ${OPENJPEG_BUILD_DIR} --config Release --target install
fi
Expand Down
33 changes: 33 additions & 0 deletions src/cmake/build_OpenJPEG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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)
set_invert (OpenJPEG_LINKSTATIC ${OpenJPEG_BUILD_SHARED_LIBS})

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
10 changes: 10 additions & 0 deletions src/cmake/set_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ macro (set_replace_if_nonempty var replacement)
endmacro ()


# Set a variable to the inverse of whether `value` was true or false.
macro (set_invert var value)
if (${value})
set (${var} FALSE ${ARGN})
else ()
set (${var} TRUE ${ARGN})
endif ()
endmacro ()



# Set a cmake variable `var` from an environment variable, if it is not
# already defined (or if the FORCE flag is used). By default, the env var is
Expand Down
17 changes: 14 additions & 3 deletions src/jpeg2000.imageio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@
# 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 (NOT TARGET openjp2 OR
LINKSTATIC OR OpenJPEG_LINKSTATIC))
# 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 ()
message (VERBOSE "OPENJPEG_TARGET=${OPENJPEG_TARGET}")
set(_jpeg2000_defs "USE_OPENJPEG")

if (openjph_FOUND)
Expand All @@ -16,6 +26,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