File tree Expand file tree Collapse file tree 7 files changed +70
-5
lines changed
Expand file tree Collapse file tree 7 files changed +70
-5
lines changed Original file line number Diff line number Diff line change @@ -544,7 +544,6 @@ jobs:
544544 setenvs : export OpenImageIO_BUILD_LOCAL_DEPS=all
545545 OpenImageIO_DEPENDENCY_BUILD_VERBOSE=ON
546546 LIBRAW_VERSION=0.21.4
547- OPENJPEG_VERSION=v2.5.4
548547 PTEX_VERSION=v2.4.2
549548 PUGIXML_VERSION=v1.14
550549 WEBP_VERSION=v1.4.0
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ if [[ -z $DEP_DOWNLOAD_ONLY ]]; then
4545 -DCMAKE_BUILD_TYPE=Release \
4646 -DCMAKE_INSTALL_PREFIX=${OPENJPEG_INSTALL_DIR} \
4747 -DBUILD_CODEC=OFF \
48+ -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
49+ -DBUILD_SHARED_LIBS=${OPENJPEG_BUILD_SHARED_LIBS:- ON} \
4850 ${OPENJPEG_CONFIG_OPTS}
4951 time cmake --build ${OPENJPEG_BUILD_DIR} --config Release --target install
5052fi
Original file line number Diff line number Diff line change 1+ # Copyright Contributors to the OpenImageIO project.
2+ # SPDX-License-Identifier: Apache-2.0
3+ # https://github.com/Academ SoftwareFoundation/OpenImageIO
4+
5+ set_cache (OpenJPEG_BUILD_VERSION 2.5.4 "OpenJPEG version for local builds" )
6+ set (OpenJPEG_GIT_REPOSITORY "https://github.com/uclouvain/openjpeg.git" )
7+ set (OpenJPEG_GIT_TAG "v${OpenJPEG_BUILD_VERSION} " )
8+ set_cache (OpenJPEG_BUILD_SHARED_LIBS ${LOCAL_BUILD_SHARED_LIBS_DEFAULT}
9+ DOC "Should a local OpenJPEG build, if necessary, build shared libraries" ADVANCED )
10+
11+
12+ string (MAKE_C_IDENTIFIER ${OpenJPEG_BUILD_VERSION} OpenJPEG_VERSION_IDENT)
13+
14+ build_dependency_with_cmake(OpenJPEG
15+ VERSION ${OpenJPEG_BUILD_VERSION}
16+ GIT_REPOSITORY ${OpenJPEG_GIT_REPOSITORY}
17+ GIT_TAG ${OpenJPEG_GIT_TAG}
18+ CMAKE_ARGS
19+ -D BUILD_CODEC=OFF
20+ -D CMAKE_POSITION_INDEPENDENT_CODE =ON
21+ )
22+ # Set some things up that we'll need for a subsequent find_package to work
23+ set (OpenJPEG_ROOT ${OpenJPEG_LOCAL_INSTALL_DIR} )
24+
25+
26+ # Signal to caller that we need to find again at the installed location
27+ set (OpenJPEG_REFIND TRUE )
28+ set (OpenJPEG_REFIND_ARGS CONFIG)
29+ set_invert (OpenJPEG_LINKSTATIC ${OpenJPEG_BUILD_SHARED_LIBS} )
30+
31+ if (OpenJPEG_BUILD_SHARED_LIBS)
32+ install_local_dependency_libs (OpenJPEG openjp2)
33+ endif ()
Original file line number Diff line number Diff line change @@ -172,7 +172,8 @@ checked_find_package (LibRaw
172172
173173checked_find_package (OpenJPEG VERSION_MIN 2.0
174174 RECOMMEND_MIN 2.2
175- RECOMMEND_MIN_REASON "for multithreading support" )
175+ RECOMMEND_MIN_REASON "for multithreading support"
176+ PREFER_CONFIG)
176177# Note: Recent OpenJPEG versions have exported cmake configs, but we don't
177178# find them reliable at all, so we stick to our FindOpenJPEG.cmake module.
178179
Original file line number Diff line number Diff line change @@ -174,6 +174,15 @@ if (OPENJPEG_FOUND)
174174 foreach (tmplib ${OpenJpeg_libvars} )
175175 list (APPEND OPENJPEG_LIBRARIES ${${tmplib} })
176176 endforeach ()
177+
178+ if (NOT TARGET openjp2)
179+ add_library (openjp2 UNKNOWN IMPORTED )
180+ set_target_properties (openjp2 PROPERTIES
181+ INTERFACE_INCLUDE_DIRECTORIES "${OPENJPEG_INCLUDES} " )
182+ set_property (TARGET openjp2 APPEND PROPERTY
183+ IMPORTED_LOCATION "${OPENJPEG_LIBRARIES} " )
184+ endif ()
185+
177186 if (NOT OpenJpeg_FIND_QUIETLY)
178187 FIND_PACKAGE_MESSAGE (OPENJPEG
179188 "Found OpenJpeg: v${OPENJPEG_VERSION} ${OPENJPEG_LIBRARIES} "
Original file line number Diff line number Diff line change @@ -20,6 +20,16 @@ macro (set_replace_if_nonempty var replacement)
2020endmacro ()
2121
2222
23+ # Set a variable to the inverse of whether `value` was true or false.
24+ macro (set_invert var value )
25+ if (${value} )
26+ set (${var} FALSE ${ARGN} )
27+ else ()
28+ set (${var} TRUE ${ARGN} )
29+ endif ()
30+ endmacro ()
31+
32+
2333
2434# Set a cmake variable `var` from an environment variable, if it is not
2535# already defined (or if the FORCE flag is used). By default, the env var is
Original file line number Diff line number Diff line change 33# https://github.com/AcademySoftwareFoundation/OpenImageIO
44
55if (OPENJPEG_FOUND)
6- set (_jpeg2000_includes ${OPENJPEG_INCLUDES} )
7- set (_jpeg2000_lib_dirs ${OPENJPEG_LIBRARY_DIRS} )
8- set (_jpeg2000_libs ${OPENJPEG_LIBRARIES} )
6+ if (TARGET openjp2_static AND (NOT TARGET openjp2 OR
7+ LINKSTATIC OR OpenJPEG_LINKSTATIC))
8+ # Use static OpenJPEG library for LINKSTATIC situations, or if
9+ # no dynamic library is available.
10+ set (OPENJPEG_TARGET openjp2_static)
11+ elseif (TARGET openjp2)
12+ set (OPENJPEG_TARGET openjp2)
13+ else ()
14+ set (_jpeg2000_includes ${OPENJPEG_INCLUDES} )
15+ set (_jpeg2000_lib_dirs ${OPENJPEG_LIBRARY_DIRS} )
16+ set (_jpeg2000_libs ${OPENJPEG_LIBRARIES} )
17+ endif ()
18+ message (VERBOSE "OPENJPEG_TARGET=${OPENJPEG_TARGET} " )
919 set (_jpeg2000_defs "USE_OPENJPEG" )
1020
1121 if (openjph_FOUND)
@@ -16,6 +26,7 @@ if (OPENJPEG_FOUND)
1626 INCLUDE_DIRS ${_jpeg2000_includes}
1727 LINK_DIRECTORIES ${_jpeg2000_lib_dirs}
1828 LINK_LIBRARIES ${_jpeg2000_libs}
29+ ${OPENJPEG_TARGET}
1930 $<TARGET_NAME_IF_EXISTS:openjph>
2031 DEFINITIONS ${_jpeg2000_defs}
2132 )
You can’t perform that action at this time.
0 commit comments