Skip to content

Commit

Permalink
[openimageio] Upgrade version, add features and fix build failure (mi…
Browse files Browse the repository at this point in the history
…crosoft#8543)

* [openimageio]Upgrade version and add features.

* [openimageio]Add definitions.

* [openimageio]Remove vcpkg_common_functions

* [openimageio] update to 2.1.9.0 and fix static build.

* [openimageio] Fix generated cmake files.

* [openimageio] Remove feature ptex due to some link error. Fix dependencies opencv and webp. Merge fix dependency patches.

* [openimageio] Add feature tools

* [openimageio] Fix openimageio targets.cmake name

* [openimageio] Fix find openjpeg

* [openimageio] Add dependency pybind11

* [openimageio] Fix find dependency ffmpeg[avresample]

* [openimageio] Add feature python

* [openimageio] Fix instructions for python

* [openimageio] Change feature name python to pybind11, add vcpkg_copy_tool_dependencies
  • Loading branch information
ras0219-msft authored Feb 9, 2020
2 parents ce6df30 + e97271e commit b20c6d3
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 149 deletions.
39 changes: 37 additions & 2 deletions ports/openimageio/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: openimageio
Version: 2019-08-08-4
Version: 2.1.9.0
Homepage: https://github.com/OpenImageIO/oiio
Description: A library for reading and writing images, and a bunch of related classes, utilities, and application
Build-Depends: libjpeg-turbo, tiff, libpng, openexr, boost-thread, boost-smart-ptr, boost-foreach, boost-regex, boost-type-traits, boost-static-assert, boost-unordered, boost-config, boost-algorithm, boost-filesystem, boost-system, boost-thread, boost-asio, boost-random, robin-map, boost-stacktrace
Expand All @@ -10,4 +10,39 @@ Description: Enable RAW image files support

Feature: opencolorio
Build-Depends: opencolorio
Description: Enable opencolorio support for openimageio
Description: Enable opencolorio support for openimageio

Feature: ffmpeg
Build-Depends: ffmpeg[avresample]
Description: Enable ffmpeg support for openimageio

Feature: field3d
Build-Depends: field3d
Description: Enable field3D support for openimageio

Feature: freetype
Build-Depends: freetype
Description: Enable freetype support for openimageio

Feature: opencv
Build-Depends: opencv
Description: Enable opencv support for openimageio

Feature: gif
Build-Depends: giflib
Description: Enable giflib support for openimageio

Feature: openjpeg
Build-Depends: openjpeg
Description: Enable openjpeg support for openimageio

Feature: webp
Build-Depends: libwebp
Description: Enable libwebp support for openimageio

Feature: pybind11
Build-Depends: pybind11
Description: Enable Python bindings support for openimageio

Feature: tools
Description: Build openimageio tools
12 changes: 12 additions & 0 deletions ports/openimageio/fix-config-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/cmake/Config.cmake.in b/src/cmake/Config.cmake.in
index c6e1a13..3d784f3 100644
--- a/src/cmake/Config.cmake.in
+++ b/src/cmake/Config.cmake.in
@@ -6,5 +6,5 @@ include(CMakeFindDependencyMacro)
# e.g. if switching to Boost::Boost instead of using ${Boost_LIBRARY_DIRS} the add:
# find_dependency(Boost @Boost_VERSION@)

-include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
+include("${CMAKE_CURRENT_LIST_DIR}/OpenImageIOTargets.cmake")
check_required_components("@PROJECT_NAME@")
\ No newline at end of file
97 changes: 97 additions & 0 deletions ports/openimageio/fix-dependency.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
diff --git a/src/cmake/externalpackages.cmake b/src/cmake/externalpackages.cmake
index 2f4f7ce..16035df 100644
--- a/src/cmake/externalpackages.cmake
+++ b/src/cmake/externalpackages.cmake
@@ -169,10 +169,17 @@ checked_find_package (PNG REQUIRED)
checked_find_package (TIFF 3.0 REQUIRED)

# IlmBase & OpenEXR
+find_package (Threads)
+if (CMAKE_USE_PTHREADS_INIT)
+ set (ILMBASE_PTHREADS ${CMAKE_THREAD_LIBS_INIT})
+endif ()
checked_find_package (OpenEXR 2.0 REQUIRED)
# We use Imath so commonly, may as well include it everywhere.
-include_directories ("${OPENEXR_INCLUDES}" "${ILMBASE_INCLUDES}"
- "${ILMBASE_INCLUDES}/OpenEXR")
+set(ILMBASE_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY} ${ILMBASE_PTHREADS} CACHE STRING "The libraries needed to use IlmBase")
+set(OPENEXR_LIBRARIES ${OPENEXR_ILMIMF_LIBRARY} ${ILMBASE_LIBRARIES} CACHE STRING "The libraries needed to use OpenEXR")
+set(ILMBASE_INCLUDE_DIR ${OPENEXR_INCLUDE_DIR})
+set(ILMBASE_FOUND TRUE)
+include_directories ("${OPENEXR_INCLUDE_DIR}")
if (CMAKE_COMPILER_IS_CLANG AND OPENEXR_VERSION VERSION_LESS 2.3)
# clang C++ >= 11 doesn't like 'register' keyword in old exr headers
add_compile_options (-Wno-deprecated-register)
@@ -217,7 +224,7 @@ checked_find_package (HDF5
ISDEPOF Field3D)
checked_find_package (OpenColorIO
DEFINITIONS -DUSE_OCIO=1 -DUSE_OPENCOLORIO=1)
-checked_find_package (OpenCV
+checked_find_package (OpenCV CONFIG
DEFINITIONS -DUSE_OPENCV=1)

# Intel TBB
@@ -226,19 +233,23 @@ checked_find_package (TBB 2017
ISDEPOF OpenVDB)

checked_find_package (DCMTK 3.6.1) # For DICOM images
-checked_find_package (FFmpeg 2.6)
+checked_find_package (FFMPEG)
checked_find_package (Field3D
DEPS HDF5
DEFINITIONS -DUSE_FIELD3D=1)
checked_find_package (GIF 4)
checked_find_package (Libheif 1.3) # For HEIF/HEIC format
checked_find_package (LibRaw)
-checked_find_package (OpenJpeg)
+checked_find_package (OpenJPEG CONFIG)
checked_find_package (OpenVDB 5.0
DEPS TBB
DEFINITIONS -DUSE_OPENVDB=1)
-checked_find_package (PTex)
-checked_find_package (Webp)
+checked_find_package (ptex CONFIG)
+set(PTEX_FOUND ${ptex_FOUND})
+set(PTEX_LIBRARIES Ptex::Ptex)
+checked_find_package (Webp CONFIG)
+set(WEBP_FOUND ${Webp_FOUND})
+set(WEBP_LIBRARY WebP::webp WebP::webpdemux WebP::webpdecoder)

option (USE_R3DSDK "Enable R3DSDK (RED camera) support" OFF)
checked_find_package (R3DSDK) # RED camera
@@ -254,7 +265,9 @@ if (OPENGL_FOUND)
list (APPEND qt5_modules OpenGL)
endif ()
option (USE_QT "Use Qt if found" ON)
+if (USE_QT)
checked_find_package (Qt5 COMPONENTS ${qt5_modules})
+endif()
if (USE_QT AND NOT Qt5_FOUND AND APPLE)
message (STATUS " If you think you installed qt5 with Homebrew and it still doesn't work,")
message (STATUS " try: export PATH=/usr/local/opt/qt5/bin:$PATH")
diff --git a/src/jpeg2000.imageio/CMakeLists.txt b/src/jpeg2000.imageio/CMakeLists.txt
index 7bc6adb..0ac8937 100644
--- a/src/jpeg2000.imageio/CMakeLists.txt
+++ b/src/jpeg2000.imageio/CMakeLists.txt
@@ -3,7 +3,7 @@
# https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md

if (OPENJPEG_FOUND)
- if (${OPENJPEG_VERSION} VERSION_LESS 2.0)
+ if (0)
# Old OpenJpeg 1.5. Remove this eventually.
#
# For reasons I don't understand, OpenJPEG 1.5 fails imageinout_test
diff --git a/src/raw.imageio/CMakeLists.txt b/src/raw.imageio/CMakeLists.txt
index 81a0ff5..23326a0 100644
--- a/src/raw.imageio/CMakeLists.txt
+++ b/src/raw.imageio/CMakeLists.txt
@@ -5,7 +5,7 @@
if (LIBRAW_FOUND)
add_oiio_plugin (rawinput.cpp
INCLUDE_DIRS ${LibRaw_INCLUDE_DIR}
- LINK_LIBRARIES ${LibRaw_r_LIBRARIES}
+ LINK_LIBRARIES ${LibRaw_LIBRARIES}
DEFINITIONS "-DUSE_LIBRAW=1")
else ()
message (WARNING "Raw plugin will not be built")
13 changes: 13 additions & 0 deletions ports/openimageio/fix-tools-path.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/cmake/oiio_macros.cmake b/src/cmake/oiio_macros.cmake
index 9e54f67..d9c9437 100644
--- a/src/cmake/oiio_macros.cmake
+++ b/src/cmake/oiio_macros.cmake
@@ -142,7 +142,7 @@ macro (fancy_add_executable)
target_link_libraries (${_target_NAME} PRIVATE ${_target_LINK_LIBRARIES})
endif ()
set_target_properties (${_target_NAME} PROPERTIES FOLDER "Tools")
- install_targets (${_target_NAME})
+ install(TARGETS ${_target_NAME} RUNTIME DESTINATION tools/openimageio)
else ()
message (STATUS "${ColorRed}Disabling ${_target_NAME} ${ColorReset}")
endif ()
35 changes: 0 additions & 35 deletions ports/openimageio/fix_libraw.patch

This file was deleted.

13 changes: 13 additions & 0 deletions ports/openimageio/fix_static_build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/cmake/compiler.cmake b/src/cmake/compiler.cmake
index 4f4f31c..a18895e 100644
--- a/src/cmake/compiler.cmake
+++ b/src/cmake/compiler.cmake
@@ -451,7 +451,7 @@ set (EXTRA_DSO_LINK_ARGS "" CACHE STRING "Extra command line definitions when bu
#
option (BUILD_SHARED_LIBS "Build shared libraries (set to OFF to build static libs)" ON)
if (NOT BUILD_SHARED_LIBS)
- add_definitions (-D${PROJECT_NAME}_STATIC_DEFINE=1)
+ add_definitions (-DOIIO_STATIC_DEFINE=1)
endif ()


75 changes: 39 additions & 36 deletions ports/openimageio/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,81 +1,84 @@
include(vcpkg_common_functions)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO OpenImageIO/oiio
REF ad1ab61a56c63d770e4beb335efe8b1f1a9e36cd
SHA512 48ee7862583e7adb86b56b20634c34aebf83ef0a3a14ad96182494ce6a84cb027334840a6c4c335e9342110c3a36532e3eeae22a3ed7363cd91b27cb7ca58154
REF fdd982a9922ff508b8b22e5d024356b582572f46 #2.1.9.0
SHA512 1d076cb035b1b2cb603343465ed810ca47223211870d58f48c177d40d71a9cf82e53548b0c70127daf5dbd06f1b24772919e49e55110d914a542bcb62b99f6e8
HEAD_REF master
PATCHES
fix_libraw.patch
use-webp.patch
remove_wrong_dependency.patch
use-vcpkg-find-openexr.patch
fix-dependency.patch
fix_static_build.patch
fix-tools-path.patch
fix-config-cmake.patch
)

file(REMOVE_RECURSE "${SOURCE_PATH}/ext")

file(REMOVE "${SOURCE_PATH}/src/cmake/modules/FindLibRaw.cmake")
file(REMOVE "${SOURCE_PATH}/src/cmake/modules/FindOpenEXR.cmake")
file(REMOVE "${SOURCE_PATH}/src/cmake/modules/FindLibRaw.cmake"
"${SOURCE_PATH}/src/cmake/modules/FindOpenEXR.cmake"
"${SOURCE_PATH}/src/cmake/modules/FindOpenCV.cmake"
"${SOURCE_PATH}/src/cmake/modules/FindFFmpeg.cmake"
"${SOURCE_PATH}/src/cmake/modules/FindWebp.cmake")

file(MAKE_DIRECTORY "${SOURCE_PATH}/ext/robin-map/tsl")

if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
set(BUILDSTATIC ON)
set(LINKSTATIC ON)
else()
set(BUILDSTATIC OFF)
set(LINKSTATIC OFF)
endif()

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
libraw USE_LIBRAW
opencolorio USE_OCIO
libraw USE_LIBRAW
opencolorio USE_OCIO
ffmpeg USE_FFMPEG
field3d USE_FIELD3D
freetype USE_FREETYPE
gif USE_GIF
opencv USE_OPENCV
openjpeg USE_OPENJPEG
webp USE_WEBP
pybind11 USE_PYTHON
tools OIIO_BUILD_TOOLS
)

vcpkg_find_acquire_program(PYTHON3)
get_filename_component(PYTHON3_DIR "${PYTHON3}" DIRECTORY)
vcpkg_add_to_path("${PYTHON3_DIR}")

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS ${FEATURE_OPTIONS}
-DOIIO_BUILD_TOOLS=OFF
-DOIIO_BUILD_TESTS=OFF
-DHIDE_SYMBOLS=ON
-DUSE_DICOM=OFF
-DUSE_FFMPEG=OFF
-DUSE_FIELD3D=OFF
-DUSE_FREETYPE=OFF
-DUSE_GIF=OFF
-DUSE_DCMTK=OFF
-DUSE_NUKE=OFF
-DUSE_OPENCV=OFF
-DUSE_OPENJPEG=OFF
-DUSE_OPENSSL=OFF
-DUSE_PTEX=OFF
-DUSE_PYTHON=OFF
-DUSE_QT=OFF
-DUSE_WEBP=OFF
-DBUILDSTATIC=${BUILDSTATIC}
-DUSE_PTEX=OFF
-DLINKSTATIC=${LINKSTATIC}
-DBUILD_MISSING_PYBIND11=OFF
-DBUILD_MISSING_DEPS=OFF
-DCMAKE_DISABLE_FIND_PACKAGE_Git=ON
-DVERBOSE=ON
OPTIONS_DEBUG
-DOPENEXR_CUSTOM_LIB_DIR=${CURRENT_INSTALLED_DIR}/debug/lib
)

vcpkg_install_cmake()

vcpkg_copy_pdbs()

vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/OpenImageIO)

if ("tools" IN_LIST FEATURES)
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/openimageio)
endif()

# Clean
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/doc)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/doc)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/doc
${CURRENT_PACKAGES_DIR}/debug/doc
${CURRENT_PACKAGES_DIR}/debug/include
${CURRENT_PACKAGES_DIR}/debug/share)

file(COPY ${SOURCE_PATH}/src/cmake/modules/FindOpenImageIO.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})

# Handle copyright
file(COPY ${SOURCE_PATH}/LICENSE.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/openimageio)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/openimageio/LICENSE.md ${CURRENT_PACKAGES_DIR}/share/openimageio/copyright)
file(INSTALL ${SOURCE_PATH}/LICENSE.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
15 changes: 0 additions & 15 deletions ports/openimageio/remove_wrong_dependency.patch

This file was deleted.

27 changes: 0 additions & 27 deletions ports/openimageio/use-vcpkg-find-openexr.patch

This file was deleted.

Loading

0 comments on commit b20c6d3

Please sign in to comment.