Skip to content

Commit 36d68e4

Browse files
committed
Add find_package option
1 parent 67c79be commit 36d68e4

File tree

5 files changed

+89
-29
lines changed

5 files changed

+89
-29
lines changed

.github/workflows/ci_steps.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ on:
4747
type: string
4848
OPENEXR_FORCE_INTERNAL_DEFLATE:
4949
type: string
50+
OPENEXR_FORCE_INTERNAL_OPENJPH:
51+
type: string
5052
BUILD_TESTING:
5153
type: string
5254
namespace:
@@ -82,6 +84,11 @@ jobs:
8284
if: ${{ inputs.OPENEXR_FORCE_INTERNAL_DEFLATE == 'OFF' }}
8385
run: share/ci/scripts/install_libdeflate.sh master
8486

87+
- name: Install OpenJPH
88+
# Pre-install OpenJPH so the builds validate finding the external installation
89+
if: ${{ inputs.OPENEXR_FORCE_INTERNAL_OPENJPH == 'OFF' }}
90+
run: share/ci/scripts/install_openjph.sh master
91+
8592
- name: Install help2man
8693
# TODO: this could go in the ASWF Linux docker
8794
# container. Also, it doesn't currently work for Windows, so
@@ -110,6 +117,7 @@ jobs:
110117
-DOPENEXR_BUILD_TOOLS=${{ inputs.OPENEXR_BUILD_TOOLS }} \
111118
-DOPENEXR_FORCE_INTERNAL_IMATH=${{ inputs.OPENEXR_FORCE_INTERNAL_IMATH }} \
112119
-DOPENEXR_FORCE_INTERNAL_DEFLATE=${{ inputs.OPENEXR_FORCE_INTERNAL_DEFLATE }} \
120+
-DOPENEXR_OJPH_USE_FINDPACKAGE=${{ ! inputs.OPENEXR_FORCE_INTERNAL_OPENJPH }} \
113121
-DBUILD_TESTING=${{ inputs.BUILD_TESTING }} \
114122
-DOPENEXR_RUN_FUZZ_TESTS=OFF \
115123
-DCMAKE_VERBOSE_MAKEFILE=ON"

.github/workflows/ci_workflow.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ jobs:
7777
OPENEXR_BUILD_TOOLS: ${{ matrix.OPENEXR_BUILD_TOOLS || 'ON' }}
7878
OPENEXR_FORCE_INTERNAL_IMATH: ${{ matrix.OPENEXR_FORCE_INTERNAL_IMATH || 'OFF' }}
7979
OPENEXR_FORCE_INTERNAL_DEFLATE: ${{ matrix.OPENEXR_FORCE_INTERNAL_DEFLATE || 'OFF' }}
80+
OPENEXR_FORCE_INTERNAL_OPENJPH: ${{ matrix.OPENEXR_FORCE_INTERNAL_OPENJPH || 'OFF' }}
8081
BUILD_TESTING: ${{ matrix.BUILD_TESTING || 'ON' }}
8182
namespace: ${{ matrix.namespace }}
8283
validate_install: ${{ matrix.validate_install || 'ON' }}
@@ -107,6 +108,7 @@ jobs:
107108
OPENEXR_BUILD_TOOLS: 'OFF'
108109
OPENEXR_FORCE_INTERNAL_IMATH: 'ON'
109110
OPENEXR_FORCE_INTERNAL_DEFLATE: 'ON'
111+
OPENEXR_FORCE_INTERNAL_OPENJPH: 'ON'
110112
BUILD_TESTING: 'OFF'
111113

112114
- build: 6
@@ -141,6 +143,7 @@ jobs:
141143
OPENEXR_BUILD_TOOLS: ${{ matrix.OPENEXR_BUILD_TOOLS || 'ON' }}
142144
OPENEXR_FORCE_INTERNAL_IMATH: ${{ matrix.OPENEXR_FORCE_INTERNAL_IMATH || 'OFF' }}
143145
OPENEXR_FORCE_INTERNAL_DEFLATE: ${{ matrix.OPENEXR_FORCE_INTERNAL_DEFLATE || 'OFF' }}
146+
OPENEXR_FORCE_INTERNAL_OPENJPH: ${{ matrix.OPENEXR_FORCE_INTERNAL_OPENJPH || 'OFF' }}
144147
BUILD_TESTING: ${{ matrix.BUILD_TESTING || 'ON' }}
145148
validate_install: ${{ matrix.validate_install || 'ON' }}
146149
strategy:
@@ -170,6 +173,7 @@ jobs:
170173
OPENEXR_BUILD_TOOLS: 'OFF'
171174
OPENEXR_FORCE_INTERNAL_IMATH: 'ON'
172175
OPENEXR_FORCE_INTERNAL_DEFLATE: 'ON'
176+
OPENEXR_FORCE_INTERNAL_OPENJPH: 'ON'
173177
BUILD_TESTING: 'OFF'
174178

175179
- build: 6
@@ -195,6 +199,7 @@ jobs:
195199
OPENEXR_BUILD_TOOLS: ${{ matrix.OPENEXR_BUILD_TOOLS || 'ON' }}
196200
OPENEXR_FORCE_INTERNAL_IMATH: ${{ matrix.OPENEXR_FORCE_INTERNAL_IMATH || 'OFF' }}
197201
OPENEXR_FORCE_INTERNAL_DEFLATE: ${{ matrix.OPENEXR_FORCE_INTERNAL_DEFLATE || 'OFF' }}
202+
OPENEXR_FORCE_INTERNAL_OPENJPH: ${{ matrix.OPENEXR_FORCE_INTERNAL_OPENJPH || 'OFF' }}
198203
BUILD_TESTING: ${{ matrix.BUILD_TESTING || 'ON' }}
199204
validate_install: ${{ matrix.validate_install || 'ON' }}
200205
strategy:
@@ -224,6 +229,7 @@ jobs:
224229
OPENEXR_BUILD_TOOLS: 'OFF'
225230
OPENEXR_FORCE_INTERNAL_IMATH: 'ON'
226231
OPENEXR_FORCE_INTERNAL_DEFLATE: 'ON'
232+
OPENEXR_FORCE_INTERNAL_OPENJPH: 'ON'
227233
BUILD_TESTING: 'OFF'
228234

229235
- build: 6

cmake/LibraryDefine.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function(OPENEXR_DEFINE_LIBRARY libname)
2525
INTERFACE cxx_std_17 )
2626

2727
# we are embedding OpenJPH
28-
target_include_directories(${objlib} PRIVATE ${openjph_SOURCE_DIR}/src/core/common)
28+
target_include_directories(${objlib} PRIVATE ${OPENJPH_OPENJPH_INCLUDE_DIRS})
2929

3030
# we are embedding libdeflate
3131
target_include_directories(${objlib} PRIVATE ${EXR_DEFLATE_INCLUDE_DIR})
@@ -43,7 +43,7 @@ function(OPENEXR_DEFINE_LIBRARY libname)
4343
if(OPENEXR_CURLIB_CURBINDIR)
4444
target_include_directories(${objlib} PRIVATE $<BUILD_INTERFACE:${OPENEXR_CURLIB_CURBINDIR}>)
4545
endif()
46-
target_link_libraries(${objlib} PUBLIC ${PROJECT_NAME}::Config ${OPENEXR_CURLIB_DEPENDENCIES} ${CMAKE_DL_LIBS} openjph)
46+
target_link_libraries(${objlib} PUBLIC ${PROJECT_NAME}::Config ${OPENEXR_CURLIB_DEPENDENCIES} ${CMAKE_DL_LIBS} ${OPENJPH_LIBRARIES})
4747
if(OPENEXR_CURLIB_PRIVATE_DEPS)
4848
target_link_libraries(${objlib} PRIVATE ${OPENEXR_CURLIB_PRIVATE_DEPS})
4949
endif()

cmake/OpenEXRSetup.cmake

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -299,35 +299,52 @@ endif()
299299

300300

301301
#######################################
302-
# Get OpenJPH
302+
# Find or download OpenJPH
303303
#######################################
304304

305-
message(STATUS "Fetching OpenJPH")
306-
307-
include(FetchContent)
308-
FetchContent_Declare(
309-
openjph
310-
GIT_REPOSITORY https://github.com/aous72/OpenJPH
311-
GIT_TAG supporting_differing_components
312-
)
313-
314-
set(OJPH_BUILD_TESTS OFF CACHE BOOL "" FORCE)
315-
set(OJPH_ENABLE_TIFF_SUPPORT OFF CACHE BOOL "" FORCE)
316-
set(OJPH_BUILD_EXECUTABLES OFF CACHE BOOL "" FORCE)
317-
FetchContent_MakeAvailable(openjph)
318-
install(
319-
TARGETS openjph
320-
EXPORT ${PROJECT_NAME}
321-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
322-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
323-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
324-
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
325-
PUBLIC_HEADER
326-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${OPENEXR_OUTPUT_SUBDIR}
327-
)
328-
set_target_properties(openjph PROPERTIES
329-
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
330-
)
305+
message(STATUS "Locating OpenJPH")
306+
307+
option(OPENEXR_OJPH_USE_FINDPACKAGE "Use find_package instead of downloading OpenJPH from a git repo" OFF)
308+
set(OPENEXR_OJPH_REPO "https://github.com/aous72/OpenJPH.git" CACHE STRING "OpenJPH Git repo URI")
309+
set(OPENEXR_OJPH_TAG "supporting_differing_components" CACHE STRING "OpenJPH Git repo tag")
310+
311+
if (NOT (OPENJPH_INCLUDE_DIRS AND OPENJPH_LIBRARIES))
312+
if (OPENEXR_OJPH_USE_FINDPACKAGE)
313+
find_package(openjph 0.19)
314+
else()
315+
include(FetchContent)
316+
FetchContent_Declare(
317+
openjph
318+
GIT_REPOSITORY ${OPENEXR_OJPH_REPO}
319+
GIT_TAG ${OPENEXR_OJPH_TAG}
320+
)
321+
322+
set(OJPH_BUILD_TESTS OFF CACHE BOOL "" FORCE)
323+
set(OJPH_ENABLE_TIFF_SUPPORT OFF CACHE BOOL "" FORCE)
324+
set(OJPH_BUILD_EXECUTABLES OFF CACHE BOOL "" FORCE)
325+
FetchContent_MakeAvailable(openjph)
326+
install(
327+
TARGETS openjph
328+
EXPORT ${PROJECT_NAME}
329+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
330+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
331+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
332+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
333+
PUBLIC_HEADER
334+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${OPENEXR_OUTPUT_SUBDIR}
335+
)
336+
set_target_properties(openjph PROPERTIES
337+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
338+
)
339+
340+
set(OPENJPH_INCLUDE_DIRS "${openjph_SOURCE_DIR}/src/core/common")
341+
set(OPENJPH_LIBRARIES openjph)
342+
endif()
343+
endif()
344+
345+
if (NOT (OPENJPH_INCLUDE_DIRS AND OPENJPH_LIBRARIES))
346+
message(SEND_ERROR "OpenJPH could not be found.")
347+
endif()
331348

332349
#######################################
333350
# Find or install Imath
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: BSD-3-Clause
3+
# Copyright Contributors to the OpenColorIO Project.
4+
5+
set -ex
6+
7+
TAG="$1"
8+
9+
if [[ $OSTYPE == "msys" ]]; then
10+
SUDO=""
11+
else
12+
SUDO="sudo"
13+
fi
14+
15+
git clone https://github.com/aous72/OpenJPH.git
16+
cd OpenJPH
17+
18+
git checkout ${TAG}
19+
20+
mkdir build
21+
cd build
22+
cmake -DCMAKE_BUILD_TYPE=Release ..
23+
$SUDO cmake --build . \
24+
--target install \
25+
--config Release \
26+
--parallel 2
27+
28+
cd ../..
29+
rm -rf OpenJPH

0 commit comments

Comments
 (0)