From 7d2494368a2445193e50cd04e3bdf623adcb7955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Thu, 5 Jan 2023 15:58:10 -0500 Subject: [PATCH 01/13] Changing version release type for 2.2.1 official release. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9367751054..d112bb3af4 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,7 @@ project(OpenColorIO LANGUAGES CXX C) # "dev", "beta1", rc1", etc or "" for an official release. -set(OpenColorIO_VERSION_RELEASE_TYPE "dev") +set(OpenColorIO_VERSION_RELEASE_TYPE "") ############################################################################### From 9239624a3e616d1e3f5ab9e2c86d5cc89804e588 Mon Sep 17 00:00:00 2001 From: bartstyczen <93516126+bartstyczen@users.noreply.github.com> Date: Sat, 3 Dec 2022 01:56:03 +0100 Subject: [PATCH 02/13] replace texture2D function with texture for GLSL 1.3 (#1723) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Bart Styczen Signed-off-by: Bart Styczen Co-authored-by: Doug Walker (cherry picked from commit d5cedbf55188e618c55758e035d6d2a21c607932) Signed-off-by: Cédrik Fuoco --- src/OpenColorIO/GpuShaderUtils.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/OpenColorIO/GpuShaderUtils.cpp b/src/OpenColorIO/GpuShaderUtils.cpp index 83689d8ff1..a3adefbdc0 100644 --- a/src/OpenColorIO/GpuShaderUtils.cpp +++ b/src/OpenColorIO/GpuShaderUtils.cpp @@ -143,11 +143,15 @@ std::string getTexSample(GpuLanguage lang, switch (lang) { case GPU_LANGUAGE_GLSL_1_2: - case GPU_LANGUAGE_GLSL_1_3: { kw << "texture" << N << "D(" << samplerName << ", " << coords << ")"; break; } + case GPU_LANGUAGE_GLSL_1_3: + { + kw << "texture(" << samplerName << ", " << coords << ")"; + break; + } case GPU_LANGUAGE_GLSL_ES_1_0: { if (N == 1) { From ee214975aa43d134bf85447cc9554249d7d586e0 Mon Sep 17 00:00:00 2001 From: FantasqueX Date: Sat, 3 Dec 2022 11:34:58 +0800 Subject: [PATCH 03/13] CheckSupportSSE2: Fix sse flags unexpected propagation (#1721) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set function will affects all variables in current directory. If sse flags are added in CheckSupportSSE2.cmake, they will remain in Findminizip-ng.cmake which will cause liblzma cannot be detected. This patch keep CMAKE_REQUIRED_FLAGS being changed only in current file scope. This patch has been tested on riscv64. Signed-off-by: Letu Ren Signed-off-by: Letu Ren Co-authored-by: Doug Walker (cherry picked from commit b6e40f4fca31c0567d4ca2505a9dbc9ff584cad2) Signed-off-by: Cédrik Fuoco --- share/cmake/utils/CheckSupportSSE2.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/share/cmake/utils/CheckSupportSSE2.cmake b/share/cmake/utils/CheckSupportSSE2.cmake index 3d97bf8a0a..f30bbb763c 100644 --- a/share/cmake/utils/CheckSupportSSE2.cmake +++ b/share/cmake/utils/CheckSupportSSE2.cmake @@ -3,6 +3,8 @@ include(CheckCXXSourceCompiles) +set(_cmake_required_flags_old "${CMAKE_REQUIRED_FLAGS}") + if(NOT CMAKE_SIZE_OF_VOID_P EQUAL 8) # As CheckCXXCompilerFlag implicitly uses CMAKE_CXX_FLAGS some custom flags could trigger # unrelated warnings causing a detection failure. So, the code disables all warnings to focus @@ -27,4 +29,7 @@ check_cxx_source_compiles (" }" HAVE_SSE2) +set(CMAKE_REQUIRED_FLAGS "${_cmake_required_flags_old}") +unset(_cmake_required_flags_old) + mark_as_advanced(HAVE_SSE2) From da8d837df33b2acb85f2c8ea0a014466d168b090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= <105517825+cedrik-fuoco-adsk@users.noreply.github.com> Date: Mon, 5 Dec 2022 17:33:12 -0500 Subject: [PATCH 04/13] Adsk contrib - Fix issue with minizip build (#1725) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * - Refactoring how OCIO search for minizip-ng. The first step is to search for an external minizip-ng. If not found, search for minizip-ng with MZ_COMPAT=ON (libminizip). If it is not found either, download and install minizip-ng with MZ_COMPAT=OFF. - Removing the minizip-ng part for the includes for minizip-ng headers. Signed-off-by: Cédrik Fuoco * Update comments Signed-off-by: Cédrik Fuoco * Improved find_package in Config mode (adding it back) Added missing scripts to install minizip-ng and zlib for the analysis workflow Signed-off-by: Cédrik Fuoco * Adding +x permissions for install_minizip_ng and zlib Fixing path to find zlib in install_minizip-ng.sh Signed-off-by: Cédrik Fuoco * Changing target name to match the one used by minizip-ng library (+ using the imported target instead of creating a new one when minizip-ng is found) Signed-off-by: Cédrik Fuoco Signed-off-by: Cédrik Fuoco Co-authored-by: Doug Walker (cherry picked from commit 811902b37d844b91ad6fb0535f3cb7ef2e8c65e8) Signed-off-by: Cédrik Fuoco --- .github/workflows/analysis_workflow.yml | 9 + share/ci/scripts/multi/install_minizip-ng.sh | 57 ++++ share/ci/scripts/multi/install_zlib.sh | 40 +++ share/cmake/modules/Findminizip-ng.cmake | 289 ++++++++++++------- share/cmake/modules/Findminizip.cmake | 172 +++++++++++ src/OpenColorIO/CMakeLists.txt | 2 +- src/OpenColorIO/OCIOZArchive.cpp | 20 +- src/apps/ocioarchive/CMakeLists.txt | 2 +- src/apps/ocioarchive/main.cpp | 10 +- tests/cpu/CMakeLists.txt | 2 +- 10 files changed, 479 insertions(+), 124 deletions(-) create mode 100755 share/ci/scripts/multi/install_minizip-ng.sh create mode 100755 share/ci/scripts/multi/install_zlib.sh create mode 100644 share/cmake/modules/Findminizip.cmake diff --git a/.github/workflows/analysis_workflow.yml b/.github/workflows/analysis_workflow.yml index fb5d8313b7..3b7443da57 100644 --- a/.github/workflows/analysis_workflow.yml +++ b/.github/workflows/analysis_workflow.yml @@ -104,12 +104,15 @@ jobs: run: | share/ci/scripts/multi/install_pugixml.sh latest - name: Install fixed ext package versions + # Minizip-ng depends on ZLIB. ZLIB must be installed first. run: | share/ci/scripts/multi/install_expat.sh 2.4.1 $EXT_PATH share/ci/scripts/multi/install_lcms2.sh 2.2 $EXT_PATH share/ci/scripts/multi/install_yaml-cpp.sh 0.7.0 $EXT_PATH share/ci/scripts/multi/install_pystring.sh 1.1.3 $EXT_PATH share/ci/scripts/multi/install_pybind11.sh 2.9.2 $EXT_PATH + share/ci/scripts/multi/install_zlib.sh 1.2.12 $EXT_PATH + share/ci/scripts/multi/install_minizip-ng.sh 3.0.6 $EXT_PATH - name: Install latest ext package versions run: | share/ci/scripts/multi/install_imath.sh latest $EXT_PATH @@ -206,12 +209,15 @@ jobs: share/ci/scripts/macos/install_boost.sh latest share/ci/scripts/multi/install_pugixml.sh latest $EXT_PATH - name: Install fixed ext package versions + # Minizip-ng depends on ZLIB. ZLIB must be installed first. run: | share/ci/scripts/multi/install_expat.sh 2.4.1 $EXT_PATH share/ci/scripts/multi/install_lcms2.sh 2.2 $EXT_PATH share/ci/scripts/multi/install_yaml-cpp.sh 0.7.0 $EXT_PATH share/ci/scripts/multi/install_pystring.sh 1.1.3 $EXT_PATH share/ci/scripts/multi/install_pybind11.sh 2.9.2 $EXT_PATH + share/ci/scripts/multi/install_zlib.sh 1.2.12 $EXT_PATH + share/ci/scripts/multi/install_minizip-ng.sh 3.0.6 $EXT_PATH - name: Install latest ext package versions run: | share/ci/scripts/multi/install_imath.sh latest $EXT_PATH @@ -325,12 +331,15 @@ jobs: share/ci/scripts/multi/install_pugixml.sh latest $EXT_PATH shell: bash - name: Install fixed ext package versions + # Minizip-ng depends on ZLIB. ZLIB must be installed first. run: | share/ci/scripts/multi/install_lcms2.sh 2.2 $EXT_PATH share/ci/scripts/multi/install_yaml-cpp.sh 0.7.0 $EXT_PATH share/ci/scripts/multi/install_pystring.sh 1.1.3 $EXT_PATH share/ci/scripts/multi/install_pybind11.sh 2.9.2 $EXT_PATH share/ci/scripts/multi/install_expat.sh 2.4.1 $EXT_PATH + share/ci/scripts/multi/install_zlib.sh 1.2.12 $EXT_PATH + share/ci/scripts/multi/install_minizip-ng.sh 3.0.6 $EXT_PATH shell: bash # OSL not installed due to LLVM compilation time. - name: Install latest ext package versions diff --git a/share/ci/scripts/multi/install_minizip-ng.sh b/share/ci/scripts/multi/install_minizip-ng.sh new file mode 100755 index 0000000000..b8c5aab75a --- /dev/null +++ b/share/ci/scripts/multi/install_minizip-ng.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +set -ex + +MINIZIPNG_VERSION="$1" +INSTALL_TARGET="$2" + +MINIZIPNG_MAJOR_MINOR=$(echo "${MINIZIPNG_VERSION}" | cut -d. -f-2) +MINIZIPNG_MAJOR=$(echo "${MINIZIPNG_VERSION}" | cut -d. -f-1) +MINIZIPNG_MINOR=$(echo "${MINIZIPNG_MAJOR_MINOR}" | cut -d. -f2-) +MINIZIPNG_PATCH=$(echo "${MINIZIPNG_VERSION}" | cut -d. -f3-) +MINIZIPNG_VERSION_U="${MINIZIPNG_MAJOR}.${MINIZIPNG_MINOR}.${MINIZIPNG_PATCH}" + +git clone https://github.com/zlib-ng/minizip-ng +cd minizip-ng + +if [ "$MINIZIPNG_VERSION" == "latest" ]; then + LATEST_TAG=$(git describe --abbrev=0 --tags) + git checkout tags/${LATEST_TAG} -b ${LATEST_TAG} +else + git checkout tags/${MINIZIPNG_VERSION_U} -b ${MINIZIPNG_VERSION_U} +fi + +mkdir build +cd build + +cmake -DCMAKE_BUILD_TYPE=Release \ + ${INSTALL_TARGET:+"-DCMAKE_INSTALL_PREFIX="${INSTALL_TARGET}""} \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + -DBUILD_SHARED_LIBS=OFF \ + -DMZ_OPENSSL=OFF \ + -DMZ_LIBBSD=OFF \ + -DMZ_BUILD_TESTS=OFF \ + -DMZ_COMPAT=OFF \ + -DMZ_BZIP2=OFF \ + -DMZ_LZMA=OFF \ + -DMZ_LIBCOMP=OFF \ + -DMZ_ZSTD=OFF \ + -DMZ_PKCRYPT=OFF \ + -DMZ_WZAES=OFF \ + -DMZ_SIGNING=OFF \ + -DMZ_ZLIB=ON \ + -DMZ_ICONV=OFF \ + -DMZ_FETCH_LIBS=OFF \ + -DMZ_FORCE_FETCH_LIBS=OFF \ + -DZLIB_LIBRARY=${INSTALL_TARGET}/${CMAKE_INSTALL_LIBDIR} \ + -DZLIB_INCLUDE_DIR=${INSTALL_TARGET}/include \ + ../. +cmake --build . \ + --target install \ + --config Release \ + --parallel 2 + +cd ../.. +rm -rf minizip-ng diff --git a/share/ci/scripts/multi/install_zlib.sh b/share/ci/scripts/multi/install_zlib.sh new file mode 100755 index 0000000000..1bd5460641 --- /dev/null +++ b/share/ci/scripts/multi/install_zlib.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +set -ex + +ZLIB_VERSION="$1" +INSTALL_TARGET="$2" + +ZLIB_MAJOR_MINOR=$(echo "${ZLIB_VERSION}" | cut -d. -f-2) +ZLIB_MAJOR=$(echo "${ZLIB_VERSION}" | cut -d. -f-1) +ZLIB_MINOR=$(echo "${ZLIB_MAJOR_MINOR}" | cut -d. -f2-) +ZLIB_PATCH=$(echo "${ZLIB_VERSION}" | cut -d. -f3-) +ZLIB_VERSION_U="${ZLIB_MAJOR}.${ZLIB_MINOR}.${ZLIB_PATCH}" + +git clone https://github.com/madler/zlib +cd zlib + +if [ "$ZLIB_VERSION" == "latest" ]; then + LATEST_TAG=$(git describe --abbrev=0 --tags) + git checkout tags/${LATEST_TAG} -b ${LATEST_TAG} +else + git checkout tags/v${ZLIB_VERSION_U} -b v${ZLIB_VERSION_U} +fi + +mkdir build +cd build + +cmake -DCMAKE_BUILD_TYPE=Release \ + ${INSTALL_TARGET:+"-DCMAKE_INSTALL_PREFIX="${INSTALL_TARGET}""} \ + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \ + -DBUILD_SHARED_LIBS=OFF \ + ../. +cmake --build . \ + --target install \ + --config Release \ + --parallel 2 + +cd ../.. +rm -rf zlib diff --git a/share/cmake/modules/Findminizip-ng.cmake b/share/cmake/modules/Findminizip-ng.cmake index 528d1d0d3e..b0136abc5f 100644 --- a/share/cmake/modules/Findminizip-ng.cmake +++ b/share/cmake/modules/Findminizip-ng.cmake @@ -3,6 +3,12 @@ # # Locate or install minizip-ng # +# This module will try to do the following: +# 1) Locate minizip-ng +# 2) If minizip-ng cannot be found, it will try to find minizip (minizip-ng with MZ_COMPAT=ON) +# 3) If minizip-ng with MZ_COMPAT=ON cannot be found, minizip-ng will be downloaded, built and +# installed. +# # Variables defined by this module: # minizip-ng_FOUND - If FALSE, do not try to link to minizip-ng # minizip-ng_LIBRARY - minizip-ng library to link to @@ -10,7 +16,18 @@ # minizip-ng_VERSION - The version of the library # # Targets defined by this module: -# minizip-ng::minizip-ng - IMPORTED target, if found +# MINIZIP::minizip-ng - IMPORTED target, if found +# +# If minizip-ng is not installed in a standard path, you can use the minizip-ng_ROOT +# variable to tell CMake where to find it. If it is not found and +# OCIO_INSTALL_EXT_PACKAGES is set to MISSING or ALL, minizip-ng will be downloaded, +# built, and statically-linked into libOpenColorIO at build time. +# +# For external builds of minizip-ng, please note that the same build options should be used. +# Using more options, such as enabling other compression methods, will provoke linking issue +# since OCIO is not linking to those libraries. +# +# e.g. Setting MZ_BZIP2=ON will cause linking issue since OCIO will not be linked against BZIP2. # ############################################################################### ### Try to find package ### @@ -18,13 +35,58 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) if(NOT DEFINED minizip-ng_ROOT) # Search for minizip-ng-config.cmake - find_package(minizip-ng ${minizip-ng_FIND_VERSION} CONFIG) + find_package(minizip-ng ${minizip-ng_FIND_VERSION} CONFIG QUIET) endif() if (minizip-ng_FOUND) - get_target_property(minizip-ng_LIBRARY MINIZIP::minizip-ng LOCATION) get_target_property(minizip-ng_INCLUDE_DIR MINIZIP::minizip-ng INTERFACE_INCLUDE_DIRECTORIES) - else () + get_target_property(minizip-ng_LIBRARY MINIZIP::minizip-ng LOCATION) + + # Depending on the options used when minizip-ng was built, it could have multiple libraries + # listed in INTERFACE_LINK_LIBRARIES. OCIO only needs ZLIB. + # Only add custom zlib target ZLIB::ZLIB to INTERFACE_LINK_LIBRARIES. + set_target_properties(MINIZIP::minizip-ng PROPERTIES INTERFACE_LINK_LIBRARIES "ZLIB::ZLIB") + + if (NOT minizip-ng_LIBRARY) + # Lib names to search for + set(_minizip-ng_LIB_NAMES minizip-ng) + + if(BUILD_TYPE_DEBUG) + # Prefer Debug lib names (Windows only) + list(INSERT _minizip-ng_LIB_NAMES 0 minizip-ngd) + endif() + + if(minizip-ng_STATIC_LIBRARY) + # Prefer static lib names + set(_minizip-ng_STATIC_LIB_NAMES + "${CMAKE_STATIC_LIBRARY_PREFIX}minizip-ng${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(WIN32 AND BUILD_TYPE_DEBUG) + # Prefer static Debug lib names (Windows only) + list(INSERT _minizip-ng_STATIC_LIB_NAMES 0 + "${CMAKE_STATIC_LIBRARY_PREFIX}minizip-ngd${CMAKE_STATIC_LIBRARY_SUFFIX}") + endif() + endif() + + # Find library + find_library(minizip-ng_LIBRARY + NAMES + ${_minizip-ng_STATIC_LIB_NAMES} + ${_minizip-ng_LIB_NAMES} + HINTS + ${minizip-ng_ROOT} + ${PC_minizip-ng_LIBRARY_DIRS} + PATH_SUFFIXES + lib64 lib + ) + + # Set IMPORTED_LOCATION property for MINIZIP::minizip-ng target. + if (TARGET MINIZIP::minizip-ng) + set_target_properties(MINIZIP::minizip-ng PROPERTIES + IMPORTED_LOCATION "${minizip-ng_LIBRARY}" + ) + endif() + endif() + else() list(APPEND _minizip-ng_REQUIRED_VARS minizip-ng_INCLUDE_DIR) # Search for minizip-ng.pc @@ -40,11 +102,13 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) ${PC_minizip-ng_INCLUDE_DIRS} PATH_SUFFIXES include + include/minizip-ng minizip-ng/include ) # Lib names to search for - set(_minizip-ng_LIB_NAMES minizip-ng libminizip-ng) + set(_minizip-ng_LIB_NAMES minizip-ng) + if(BUILD_TYPE_DEBUG) # Prefer Debug lib names (Windows only) list(INSERT _minizip-ng_LIB_NAMES 0 minizip-ngd) @@ -92,127 +156,140 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) ) endif() -############################################################################### -### Create target - -if(NOT TARGET minizip-ng::minizip-ng) - add_library(minizip-ng::minizip-ng UNKNOWN IMPORTED GLOBAL) - set(_minizip-ng_TARGET_CREATE TRUE) +if(NOT minizip-ng_FOUND) + # Looking for an external minizip-ng that might be built using MZ_COMPAT=ON. + # But do not download it if it cannot be found. + find_package(minizip ${minizip-ng_FIND_VERSION} REQUIRED) endif() -############################################################################### -### Install package from source ### -if(NOT minizip-ng_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) - include(ExternalProject) - include(GNUInstallDirs) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") - - # Set find_package standard args - set(minizip-ng_FOUND TRUE) - set(minizip-ng_VERSION ${minizip-ng_FIND_VERSION}) - set(minizip-ng_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") - - # Minizip-ng use a hardcoded lib prefix instead of CMAKE_STATIC_LIBRARY_PREFIX - set(_minizip-ng_LIB_PREFIX "lib") - - set(minizip-ng_LIBRARY - "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${_minizip-ng_LIB_PREFIX}minizip-ng${_minizip-ng_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") - - if(_minizip-ng_TARGET_CREATE) - set(MINIZIP-NG_CMAKE_ARGS - ${MINIZIP-NG_CMAKE_ARGS} - -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} - -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} - -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} - -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} - -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} - -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}/minizip-ng - -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} - -DBUILD_SHARED_LIBS=OFF - -DMZ_OPENSSL=OFF - -DMZ_LIBBSD=OFF - -DMZ_BUILD_TESTS=OFF - -DMZ_COMPAT=OFF - -DMZ_BZIP2=OFF - -DMZ_LZMA=OFF - -DMZ_LIBCOMP=OFF - -DMZ_ZSTD=OFF - -DMZ_PKCRYPT=OFF - -DMZ_WZAES=OFF - -DMZ_SIGNING=OFF - -DMZ_ZLIB=ON - -DMZ_ICONV=OFF - -DMZ_FETCH_LIBS=OFF - -DMZ_FORCE_FETCH_LIBS=OFF - -DZLIB_LIBRARY=${ZLIB_LIBRARIES} - -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS} - ) +if(NOT minizip_FOUND AND NOT TARGET MINIZIP::minizip) + ############################################################################### + ### Create target - if(CMAKE_TOOLCHAIN_FILE) - set(minizip-ng_CMAKE_ARGS - ${minizip-ng_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) - endif() + if(NOT TARGET MINIZIP::minizip-ng) + add_library(MINIZIP::minizip-ng UNKNOWN IMPORTED GLOBAL) + set(_minizip-ng_TARGET_CREATE TRUE) + endif() + + ############################################################################### + ### Install package from source ### + if(NOT minizip-ng_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + include(ExternalProject) + include(GNUInstallDirs) + + set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") + set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") - if(APPLE) - string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") + # Set find_package standard args + set(minizip-ng_FOUND TRUE) + set(minizip-ng_VERSION ${minizip-ng_FIND_VERSION}) - set(minizip-ng_CMAKE_ARGS - ${minizip-ng_CMAKE_ARGS} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} - -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} + set(minizip-ng_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}/minizip-ng") + + # Minizip-ng use a hardcoded lib prefix instead of CMAKE_STATIC_LIBRARY_PREFIX + set(_minizip-ng_LIB_PREFIX "lib") + + set(minizip-ng_LIBRARY + "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${_minizip-ng_LIB_PREFIX}minizip-ng${_minizip-ng_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") + + if(_minizip-ng_TARGET_CREATE) + set(MINIZIP-NG_CMAKE_ARGS + ${MINIZIP-NG_CMAKE_ARGS} + -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} + -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} + -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} + -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} + -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + # Since the other modules create a subfolder for the includes by default and since + # minizip-ng does not, a suffix is added to CMAKE_INSTALL_INCLUDEDIR in order to + # install the headers under a subdirectory named "minizip-ng". + # Note that this does not affect external builds for minizip-ng. + -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}/minizip-ng + -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} + -DBUILD_SHARED_LIBS=OFF + -DMZ_OPENSSL=OFF + -DMZ_LIBBSD=OFF + -DMZ_BUILD_TESTS=OFF + -DMZ_COMPAT=OFF + -DMZ_BZIP2=OFF + -DMZ_LZMA=OFF + -DMZ_LIBCOMP=OFF + -DMZ_ZSTD=OFF + -DMZ_PKCRYPT=OFF + -DMZ_WZAES=OFF + -DMZ_SIGNING=OFF + -DMZ_ZLIB=ON + -DMZ_ICONV=OFF + -DMZ_FETCH_LIBS=OFF + -DMZ_FORCE_FETCH_LIBS=OFF + -DZLIB_LIBRARY=${ZLIB_LIBRARIES} + -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS} ) - endif() - if (ANDROID) - set(minizip-ng_CMAKE_ARGS - ${minizip-ng_CMAKE_ARGS} - -DANDROID_PLATFORM=${ANDROID_PLATFORM} - -DANDROID_ABI=${ANDROID_ABI} - -DANDROID_STL=${ANDROID_STL}) + if(CMAKE_TOOLCHAIN_FILE) + set(minizip-ng_CMAKE_ARGS + ${minizip-ng_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() + + if(APPLE) + string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") + + set(minizip-ng_CMAKE_ARGS + ${minizip-ng_CMAKE_ARGS} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} + -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} + ) + endif() + + if (ANDROID) + set(minizip-ng_CMAKE_ARGS + ${minizip-ng_CMAKE_ARGS} + -DANDROID_PLATFORM=${ANDROID_PLATFORM} + -DANDROID_ABI=${ANDROID_ABI} + -DANDROID_STL=${ANDROID_STL}) + endif() endif() - endif() - # Hack to let imported target be built from ExternalProject_Add - file(MAKE_DIRECTORY ${minizip-ng_INCLUDE_DIR}) - - ExternalProject_Add(minizip-ng_install - GIT_REPOSITORY "https://github.com/zlib-ng/minizip-ng.git" - GIT_TAG "${minizip-ng_VERSION}" - GIT_CONFIG advice.detachedHead=false - GIT_SHALLOW TRUE - PREFIX "${_EXT_BUILD_ROOT}/libminizip-ng" - BUILD_BYPRODUCTS ${minizip-ng_LIBRARY} - CMAKE_ARGS ${MINIZIP-NG_CMAKE_ARGS} - EXCLUDE_FROM_ALL TRUE - BUILD_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} --build . - --config ${CMAKE_BUILD_TYPE} - --target install - --parallel - ) + # Hack to let imported target be built from ExternalProject_Add + file(MAKE_DIRECTORY ${minizip-ng_INCLUDE_DIR}) - add_dependencies(minizip-ng::minizip-ng minizip-ng_install) - message(STATUS "Installing minizip-ng: ${minizip-ng_LIBRARY} (version \"${minizip-ng_VERSION}\")") + ExternalProject_Add(minizip-ng_install + GIT_REPOSITORY "https://github.com/zlib-ng/minizip-ng.git" + GIT_TAG "${minizip-ng_VERSION}" + GIT_CONFIG advice.detachedHead=false + GIT_SHALLOW TRUE + PREFIX "${_EXT_BUILD_ROOT}/libminizip-ng" + BUILD_BYPRODUCTS ${minizip-ng_LIBRARY} + CMAKE_ARGS ${MINIZIP-NG_CMAKE_ARGS} + EXCLUDE_FROM_ALL TRUE + BUILD_COMMAND "" + INSTALL_COMMAND + ${CMAKE_COMMAND} --build . + --config ${CMAKE_BUILD_TYPE} + --target install + --parallel + ) + + add_dependencies(MINIZIP::minizip-ng minizip-ng_install) + message(STATUS "Installing minizip-ng: ${minizip-ng_LIBRARY} (version \"${minizip-ng_VERSION}\")") + endif() endif() ############################################################################### ### Configure target ### if(_minizip-ng_TARGET_CREATE) - set_target_properties(minizip-ng::minizip-ng PROPERTIES + set_target_properties(MINIZIP::minizip-ng PROPERTIES IMPORTED_LOCATION "${minizip-ng_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${minizip-ng_INCLUDE_DIR}" ) mark_as_advanced(minizip-ng_INCLUDE_DIR minizip-ng_LIBRARY minizip-ng_VERSION) - target_link_libraries(minizip-ng::minizip-ng INTERFACE ZLIB::ZLIB) + target_link_libraries(MINIZIP::minizip-ng INTERFACE ZLIB::ZLIB) endif() \ No newline at end of file diff --git a/share/cmake/modules/Findminizip.cmake b/share/cmake/modules/Findminizip.cmake new file mode 100644 index 0000000000..1a75747177 --- /dev/null +++ b/share/cmake/modules/Findminizip.cmake @@ -0,0 +1,172 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. +# +# Locate minizip-ng with MZ_COMPAT=ON. +# +# This module DOES NOT install minizip-ng with MZ_COMPAT=ON if it is not found. +# +# Note: This option changes the name for the library file to "libminizip", but it is still +# actually minizip-ng. OCIO uses the API from minizip-ng. +# +# Variables defined by this module: +# minizip_FOUND - If FALSE, do not try to link to minizip +# minizip_LIBRARY - minizip library to link to +# minizip_INCLUDE_DIR - Where to find mz.h and other headers +# minizip_VERSION - The version of the library +# +# This module set the variables below because this is still minizip-ng. The librarie become +# "minizip" because of the cmake option MZ_COMPAT=ON. +# +# minizip-ng_FOUND - If FALSE, do not try to link to minizip-ng +# minizip-ng_LIBRARY - minizip-ng library to link to +# minizip-ng_INCLUDE_DIR - Where to find mz.h and other headers +# minizip-ng_VERSION - The version of the library +# +# Targets defined by this module: +# MINIZIP::minizip-ng - IMPORTED target, if found +# +############################################################################### +### Try to find package ### + +if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) + + if(NOT DEFINED minizip_ROOT) + # Search for minizip-config.cmake + find_package(minizip ${minizip_FIND_VERSION} CONFIG QUIET) + endif() + + if (minizip_FOUND) + get_target_property(minizip_INCLUDE_DIR MINIZIP::minizip INTERFACE_INCLUDE_DIRECTORIES) + get_target_property(minizip_LIBRARY MINIZIP::minizip LOCATION) + + if (NOT minizip_LIBRARY) + # Lib names to search for + set(_minizip_LIB_NAMES minizip) + + if(BUILD_TYPE_DEBUG) + # Prefer Debug lib names (Windows only) + list(INSERT _minizip_LIB_NAMES 0 minizipd) + endif() + + if(minizip_STATIC_LIBRARY) + # Prefer static lib names + set(_minizip_STATIC_LIB_NAMES + "${CMAKE_STATIC_LIBRARY_PREFIX}minizip${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(WIN32 AND BUILD_TYPE_DEBUG) + # Prefer static Debug lib names (Windows only) + list(INSERT _minizip_STATIC_LIB_NAMES 0 + "${CMAKE_STATIC_LIBRARY_PREFIX}minizipd${CMAKE_STATIC_LIBRARY_SUFFIX}") + endif() + endif() + + # Find library + find_library(minizip_LIBRARY + NAMES + ${_minizip_STATIC_LIB_NAMES} + ${_minizip_LIB_NAMES} + HINTS + ${minizip_ROOT} + ${PC_minizip_LIBRARY_DIRS} + PATH_SUFFIXES + lib64 lib + ) + endif() + else() + list(APPEND _minizip_REQUIRED_VARS minizip_INCLUDE_DIR) + + # Search for minizip.pc + find_package(PkgConfig QUIET) + pkg_check_modules(PC_minizip QUIET "minizip>=${minizip_FIND_VERSION}") + + # Find include directory + find_path(minizip_INCLUDE_DIR + NAMES + mz.h + HINTS + ${minizip_ROOT} + ${PC_minizip_INCLUDE_DIRS} + PATH_SUFFIXES + include + minizip/include + ) + + # Lib names to search for + set(_minizip_LIB_NAMES minizip) + + if(BUILD_TYPE_DEBUG) + # Prefer Debug lib names (Windows only) + list(INSERT _minizip_LIB_NAMES 0 minizipd) + endif() + + if(minizip_STATIC_LIBRARY) + # Prefer static lib names + set(_minizip_STATIC_LIB_NAMES + "${CMAKE_STATIC_LIBRARY_PREFIX}minizip${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(WIN32 AND BUILD_TYPE_DEBUG) + # Prefer static Debug lib names (Windows only) + list(INSERT _minizip_STATIC_LIB_NAMES 0 + "${CMAKE_STATIC_LIBRARY_PREFIX}minizipd${CMAKE_STATIC_LIBRARY_SUFFIX}") + endif() + endif() + + # Find library + find_library(minizip_LIBRARY + NAMES + ${_minizip_STATIC_LIB_NAMES} + ${_minizip_LIB_NAMES} + HINTS + ${minizip_ROOT} + ${PC_minizip_LIBRARY_DIRS} + PATH_SUFFIXES + lib64 + lib + ) + + # Get version from header or pkg-config + set(minizip_VERSION "${minizip_FIND_VERSION}") + endif() + + # Override REQUIRED if package can be installed + if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) + set(minizip_FIND_REQUIRED FALSE) + endif() + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(minizip + REQUIRED_VARS + minizip_LIBRARY + minizip_INCLUDE_DIR + VERSION_VAR + minizip_VERSION + ) +endif() + +############################################################################### +### Create target + +if(minizip_FOUND AND NOT TARGET MINIZIP::minizip-ng) + add_library(MINIZIP::minizip-ng UNKNOWN IMPORTED GLOBAL) + set(_minizip_TARGET_CREATE TRUE) +endif() + +############################################################################### + +############################################################################### +### Configure target ### + +if(minizip_FOUND AND _minizip_TARGET_CREATE) + set_target_properties(MINIZIP::minizip-ng PROPERTIES + IMPORTED_LOCATION "${minizip_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${minizip_INCLUDE_DIR}" + ) + + # This is still minizip-ng even though the library is called minizip because of MZ_COMPAT=ON. + set(minizip-ng_LIBRARY ${minizip_LIBRARY}) + set(minizip-ng_INCLUDE_DIR ${minizip_INCLUDE_DIR}) + set(minizip-ng_FOUND ${minizip_FOUND}) + set(minizip-ng_VERSION ${minizip_VERSION}) + + mark_as_advanced(minizip_INCLUDE_DIR minizip_LIBRARY minizip_VERSION) + + target_link_libraries(MINIZIP::minizip-ng INTERFACE ZLIB::ZLIB) +endif() \ No newline at end of file diff --git a/src/OpenColorIO/CMakeLists.txt b/src/OpenColorIO/CMakeLists.txt index ab9c048126..2bc379e118 100755 --- a/src/OpenColorIO/CMakeLists.txt +++ b/src/OpenColorIO/CMakeLists.txt @@ -277,7 +277,7 @@ target_link_libraries(OpenColorIO "$" "$" yaml-cpp - minizip-ng::minizip-ng + MINIZIP::minizip-ng ) if(APPLE) diff --git a/src/OpenColorIO/OCIOZArchive.cpp b/src/OpenColorIO/OCIOZArchive.cpp index 52e292ef77..85fc7bb76d 100644 --- a/src/OpenColorIO/OCIOZArchive.cpp +++ b/src/OpenColorIO/OCIOZArchive.cpp @@ -17,16 +17,16 @@ #include "OCIOZArchive.h" -#include "minizip-ng/mz.h" -#include "minizip-ng/mz_os.h" -#include "minizip-ng/mz_strm.h" -#include "minizip-ng/mz_strm_buf.h" -#include "minizip-ng/mz_strm_mem.h" -#include "minizip-ng/mz_strm_os.h" -#include "minizip-ng/mz_strm_split.h" -#include "minizip-ng/mz_strm_zlib.h" -#include "minizip-ng/mz_zip.h" -#include "minizip-ng/mz_zip_rw.h" +#include "mz.h" +#include "mz_os.h" +#include "mz_strm.h" +#include "mz_strm_buf.h" +#include "mz_strm_mem.h" +#include "mz_strm_os.h" +#include "mz_strm_split.h" +#include "mz_strm_zlib.h" +#include "mz_zip.h" +#include "mz_zip_rw.h" namespace OCIO_NAMESPACE { diff --git a/src/apps/ocioarchive/CMakeLists.txt b/src/apps/ocioarchive/CMakeLists.txt index d71d719aeb..6b868d1979 100644 --- a/src/apps/ocioarchive/CMakeLists.txt +++ b/src/apps/ocioarchive/CMakeLists.txt @@ -19,7 +19,7 @@ target_link_libraries(ocioarchive PRIVATE apputils OpenColorIO - minizip-ng::minizip-ng + MINIZIP::minizip-ng ) install(TARGETS ocioarchive diff --git a/src/apps/ocioarchive/main.cpp b/src/apps/ocioarchive/main.cpp index bf222fc8aa..190cadee54 100644 --- a/src/apps/ocioarchive/main.cpp +++ b/src/apps/ocioarchive/main.cpp @@ -13,11 +13,11 @@ namespace OCIO = OCIO_NAMESPACE; #include "apputils/argparse.h" // Config archive functionality. -#include "minizip-ng/mz.h" -#include "minizip-ng/mz_os.h" -#include "minizip-ng/mz_strm.h" -#include "minizip-ng/mz_zip.h" -#include "minizip-ng/mz_zip_rw.h" +#include "mz.h" +#include "mz_os.h" +#include "mz_strm.h" +#include "mz_zip.h" +#include "mz_zip_rw.h" // Array of non OpenColorIO arguments. static std::vector args; diff --git a/tests/cpu/CMakeLists.txt b/tests/cpu/CMakeLists.txt index ff3b19dc78..e78a86bede 100755 --- a/tests/cpu/CMakeLists.txt +++ b/tests/cpu/CMakeLists.txt @@ -23,7 +23,7 @@ function(add_ocio_test NAME SOURCES PRIVATE_INCLUDES) utils::strings yaml-cpp testutils - minizip-ng::minizip-ng + MINIZIP::minizip-ng xxHash ) From 3ca65dce7ff7b4f2b09e2aab43efa49a2b7b96bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= <105517825+cedrik-fuoco-adsk@users.noreply.github.com> Date: Mon, 5 Dec 2022 20:16:27 -0500 Subject: [PATCH 05/13] Adsk contrib - Processor cache does not detect changes in cccid (#1726) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * For Looks that has a FileTransform and for Colorspace with FileTransfrom, add the CCCID to the processor's cache key for that transform. Signed-off-by: Cédrik Fuoco * Removing the workaround in the related unit tests and fixing the issue by adding the environment variable to the context using setStringVar. The processor's cache key is using the context cache ID which has all the context variables taken into account. Signed-off-by: Cédrik Fuoco * Now using addStringVars and creating a new context instead of reusing the one used for the filename. Signed-off-by: Cédrik Fuoco * Adding cccid to the context when there are no context variable. Signed-off-by: Cédrik Fuoco * Adding a few unit tests to test that the processor is different when changing the FileTransform's CCCID. Signed-off-by: Cédrik Fuoco * Using setStringVar to set CCNUM context variable in unit test. Signed-off-by: Cédrik Fuoco * Adding a test in FileTransform to test CollectContextVariables directly. Signed-off-by: Cédrik Fuoco * Minor tweaks for the unit test Signed-off-by: Cédrik Fuoco Signed-off-by: Cédrik Fuoco Co-authored-by: Doug Walker (cherry picked from commit 4fa775030a9b51ba6b9ebc09acd85887da4c02a8) Signed-off-by: Cédrik Fuoco --- src/OpenColorIO/transforms/FileTransform.cpp | 10 ++++ tests/cpu/Config_tests.cpp | 55 ++++++++++++++++++++ tests/cpu/transforms/FileTransform_tests.cpp | 52 ++++++++++++++++++ tests/python/OCIOZArchiveTest.py | 6 --- 4 files changed, 117 insertions(+), 6 deletions(-) diff --git a/src/OpenColorIO/transforms/FileTransform.cpp b/src/OpenColorIO/transforms/FileTransform.cpp index 172c242470..4fd4d5d475 100755 --- a/src/OpenColorIO/transforms/FileTransform.cpp +++ b/src/OpenColorIO/transforms/FileTransform.cpp @@ -282,6 +282,16 @@ bool CollectContextVariables(const Config &, usedContextVars->addStringVars(ctxFilepath); } + // Check if the CCCID is using a context variable and add it to the context if that's the case. + ContextRcPtr ctxCCCID = Context::Create(); + const char * cccid = tr.getCCCId(); + std::string resolvedCCCID = context.resolveStringVar(cccid, ctxCCCID); + if (0 != strcmp(resolvedCCCID.c_str(), cccid)) + { + foundContextVars = true; + usedContextVars->addStringVars(ctxCCCID); + } + return foundContextVars; } diff --git a/tests/cpu/Config_tests.cpp b/tests/cpu/Config_tests.cpp index 329bd63ef5..76b668fc8e 100644 --- a/tests/cpu/Config_tests.cpp +++ b/tests/cpu/Config_tests.cpp @@ -7833,6 +7833,61 @@ OCIO_ADD_TEST(Config, context_variables_typical_use_cases) cfg->getProcessor(ctx2, "cs1", "cs2").get()); } } + + + // Case 7 - Context variables in the FileTransform's CCCID. + { + static const std::string CONFIG = + "ocio_profile_version: 2\n" + "\n" + "environment:\n" + " CCPREFIX: cc\n" + "\n" + "search_path: " + OCIO::GetTestFilesDir() + "\n" + "\n" + "roles:\n" + " default: cs1\n" + "\n" + "displays:\n" + " disp1:\n" + " - ! {name: view1, colorspace: cs2}\n" + "\n" + "colorspaces:\n" + " - !\n" + " name: cs1\n" + "\n" + " - !\n" + " name: cs2\n" + " from_scene_reference: ! {src: cdl_test1.ccc, cccid: $CCPREFIX00$CCNUM}\n"; + + std::istringstream iss; + iss.str(CONFIG); + + OCIO::ConfigRcPtr cfg; + OCIO_CHECK_NO_THROW(cfg = OCIO::Config::CreateFromStream(iss)->createEditableCopy()); + OCIO_CHECK_NO_THROW(cfg->validate()); + + OCIO::ConstTransformRcPtr ctf = cfg->getColorSpace("cs2")->getTransform( + OCIO::COLORSPACE_DIR_FROM_REFERENCE + ); + OCIO_REQUIRE_ASSERT(ctf); + + OCIO::ContextRcPtr ctx = cfg->getCurrentContext()->createEditableCopy(); + + ctx->setStringVar("CCNUM", "01"); + OCIO::ConstProcessorRcPtr p1 = cfg->getProcessor(ctx, ctf, OCIO::TRANSFORM_DIR_FORWARD); + + ctx->setStringVar("CCNUM", "02"); + OCIO::ConstProcessorRcPtr p2 = cfg->getProcessor(ctx, ctf, OCIO::TRANSFORM_DIR_FORWARD); + + ctx->setStringVar("CCNUM", "03"); + OCIO::ConstProcessorRcPtr p3 = cfg->getProcessor(ctx, ctf, OCIO::TRANSFORM_DIR_FORWARD); + + // All three processors should be different. + OCIO_CHECK_NE(p1.get(), p2.get()); + OCIO_CHECK_NE(p1.get(), p3.get()); + OCIO_CHECK_NE(p2.get(), p3.get()); + } } OCIO_ADD_TEST(Config, virtual_display) diff --git a/tests/cpu/transforms/FileTransform_tests.cpp b/tests/cpu/transforms/FileTransform_tests.cpp index 928adfa6fe..55315822cf 100644 --- a/tests/cpu/transforms/FileTransform_tests.cpp +++ b/tests/cpu/transforms/FileTransform_tests.cpp @@ -431,4 +431,56 @@ OCIO_ADD_TEST(FileTransform, context_variables) // A basic check to validate that context variables are correctly used. OCIO_CHECK_NO_THROW(cfg->getProcessor(ctx, file, OCIO::TRANSFORM_DIR_FORWARD)); + + + { + // Case 4 - The 'cccid' now contains a context variable + static const std::string CONFIG = + "ocio_profile_version: 2\n" + "\n" + "environment:\n" + " CCPREFIX: cc\n" + " CCNUM: 02\n" + "\n" + "search_path: " + OCIO::GetTestFilesDir() + "\n" + "\n" + "roles:\n" + " default: cs1\n" + "\n" + "displays:\n" + " disp1:\n" + " - ! {name: view1, colorspace: cs2}\n" + "\n" + "colorspaces:\n" + " - !\n" + " name: cs1\n" + "\n" + " - !\n" + " name: cs2\n" + " from_scene_reference: ! {src: cdl_test1.ccc, cccid: $CCPREFIX00$CCNUM}\n"; + + std::istringstream iss; + iss.str(CONFIG); + + OCIO::ConstConfigRcPtr cfg; + OCIO_CHECK_NO_THROW(cfg = OCIO::Config::CreateFromStream(iss)); + OCIO_CHECK_NO_THROW(cfg->validate()); + + ctx = cfg->getCurrentContext()->createEditableCopy(); + OCIO_CHECK_NO_THROW(ctx->setStringVar("CCNUM", "01")); + + usedContextVars = OCIO::Context::Create(); // New & empty instance. + OCIO::ConstTransformRcPtr tr1 = cfg->getColorSpace("cs2")->getTransform( + OCIO::COLORSPACE_DIR_FROM_REFERENCE + ); + OCIO::ConstFileTransformRcPtr fTr1 = OCIO::DynamicPtrCast(tr1); + OCIO_CHECK_ASSERT(fTr1); + + OCIO_CHECK_ASSERT(CollectContextVariables(*cfg, *ctx, *fTr1, usedContextVars)); + OCIO_CHECK_EQUAL(2, usedContextVars->getNumStringVars()); + OCIO_CHECK_EQUAL(std::string("CCPREFIX"), usedContextVars->getStringVarNameByIndex(0)); + OCIO_CHECK_EQUAL(std::string("cc"), usedContextVars->getStringVarByIndex(0)); + OCIO_CHECK_EQUAL(std::string("CCNUM"), usedContextVars->getStringVarNameByIndex(1)); + OCIO_CHECK_EQUAL(std::string("01"), usedContextVars->getStringVarByIndex(1)); + } } diff --git a/tests/python/OCIOZArchiveTest.py b/tests/python/OCIOZArchiveTest.py index 1f364101cb..b649badc93 100644 --- a/tests/python/OCIOZArchiveTest.py +++ b/tests/python/OCIOZArchiveTest.py @@ -282,9 +282,6 @@ def test_cccid(self): cdl = processor.createGroupTransform()[0] self.assertEqual(cdl.getSlope()[0], 0.9) - # FIXME: There is a bug with the Processor cache, this clears it. - self.CONFIG.setStrictParsingEnabled(False) - self.CONTEXT['CCCID'] = 'look-03' processor = self.CONFIG.getProcessor(self.CONTEXT, look_transform, @@ -292,9 +289,6 @@ def test_cccid(self): cdl = processor.createGroupTransform()[0] self.assertEqual(cdl.getSlope()[0], 1.2) - # FIXME: There is a bug with the Processor cache, this clears it. - self.CONFIG.setStrictParsingEnabled(False) - self.CONTEXT['CCCID'] = 'look-01' processor = self.CONFIG.getProcessor(self.CONTEXT, look_transform, From 16590c396b68df0f01f79500766cef624fbfce0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= <105517825+cedrik-fuoco-adsk@users.noreply.github.com> Date: Mon, 5 Dec 2022 23:10:29 -0500 Subject: [PATCH 06/13] Adsk contrib - Configure the OpenColorIO.pc file on Windows (#1720) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Configure the OpenColorIO.pc file on Windows and fix an issue where CMAKE_INSTALL_PREFIX wasn't included in the cmake build command in ocio.bat. Signed-off-by: Cédrik Fuoco * Removing pkconfig folder since that PC file is not used. Signed-off-by: Cédrik Fuoco * Small tweak in the configuration of OpenColorIO.cmake.in to handle absolute path with CMAKE_INSTALL_LIBDIR or CMAKE_INSTALL_INCLUDEDIR. Keeping exec_prefix for CMAKE_INSTALL_INCLUDE_DIR since it was changed for a specific issue on Mac (see PR #1120). Signed-off-by: Cédrik Fuoco * Using ${prefix} for includedir Signed-off-by: Cédrik Fuoco Signed-off-by: Cédrik Fuoco Co-authored-by: Doug Walker (cherry picked from commit 332462e7f5051b7e26ee3d8c22890cd5e71e7c30) Signed-off-by: Cédrik Fuoco --- share/dev/windows/ocio.bat | 3 ++- src/OpenColorIO/CMakeLists.txt | 26 +++++++++++++++------ src/OpenColorIO/pkgconfig/OpenColorIO.pc.in | 11 --------- 3 files changed, 21 insertions(+), 19 deletions(-) delete mode 100644 src/OpenColorIO/pkgconfig/OpenColorIO.pc.in diff --git a/share/dev/windows/ocio.bat b/share/dev/windows/ocio.bat index 04e61b7096..7f24bc279b 100644 --- a/share/dev/windows/ocio.bat +++ b/share/dev/windows/ocio.bat @@ -193,6 +193,7 @@ IF NOT EXIST "!PYTHON_PATH!" ( if !DO_CONFIGURE!==1 ( echo Running CMake... cmake -B "!BUILD_PATH!"^ + -DCMAKE_INSTALL_PREFIX=!INSTALL_PATH!^ -DOCIO_INSTALL_EXT_PACKAGES=ALL^ -DCMAKE_BUILD_TYPE=!CMAKE_BUILD_TYPE!^ -DGLEW_ROOT="!GLEW_ROOT!"^ @@ -231,7 +232,7 @@ if Not "%CMAKE_CONFIGURE_STATUS%"=="Failed" ( rem Run cmake --install only if cmake --build was successful. if Not "%CMAKE_BUILD_STATUS%"=="Failed" ( rem Install OCIO - cmake --install !BUILD_PATH! --config !CMAKE_BUILD_TYPE! --prefix !INSTALL_PATH! + cmake --install !BUILD_PATH! --config !CMAKE_BUILD_TYPE! if not ErrorLevel 1 ( set CMAKE_INSTALL_STATUS=Ok ) else ( diff --git a/src/OpenColorIO/CMakeLists.txt b/src/OpenColorIO/CMakeLists.txt index 2bc379e118..b667a6d1fa 100755 --- a/src/OpenColorIO/CMakeLists.txt +++ b/src/OpenColorIO/CMakeLists.txt @@ -174,18 +174,30 @@ set(SOURCES SystemMonitor.cpp ) -if(NOT WIN32) +# Install the pkg-config file. - # Install the pkg-config file. +set(prefix ${CMAKE_INSTALL_PREFIX}) +set(exec_prefix "\${prefix}") - set(prefix ${CMAKE_INSTALL_PREFIX}) - set(exec_prefix "\${prefix}") +# CMAKE_INSTALL_LIBDIR is not guaranteed to be relative. +# Not using cmake_path function since it is only available from CMake ≥ 3.20. +if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") + set(libdir "${CMAKE_INSTALL_LIBDIR}") +else() set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") - set(includedir "\${exec_prefix}/${CMAKE_INSTALL_INCLUDEDIR}") - configure_file(res/OpenColorIO.pc.in ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc @ONLY) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) endif() +# CMAKE_INSTALL_INCLUDEDIR is not guaranteed to be relative. +# Not using cmake_path function since it is only available from CMake ≥ 3.20. +if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") + set(includedir "${CMAKE_INSTALL_INCLUDEDIR}") +else() + set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") +endif() + +configure_file(res/OpenColorIO.pc.in ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc @ONLY) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/OpenColorIO.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + add_library(OpenColorIO ${SOURCES}) # Require at least a C++11 compatible compiler for consumer projects. diff --git a/src/OpenColorIO/pkgconfig/OpenColorIO.pc.in b/src/OpenColorIO/pkgconfig/OpenColorIO.pc.in deleted file mode 100644 index ed1d5c4549..0000000000 --- a/src/OpenColorIO/pkgconfig/OpenColorIO.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright Contributors to the OpenColorIO Project. - -libdir=@CMAKE_INSTALL_FULL_LIBDIR@ -includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ - -Name: OpenColorIO -Description: A color management framework for visual effects and animation -Version: @OCIO_VERSION_FULL_STR@ -Cflags: -I${includedir} -Libs: -L${libdir} -lOpenColorIO From c8e4a7d08fe8401fb40fd4d7cc217689e0659d03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= <105517825+cedrik-fuoco-adsk@users.noreply.github.com> Date: Tue, 6 Dec 2022 00:32:32 -0500 Subject: [PATCH 07/13] Adsk contrib - Hiding minizip-ng symbols on Mac (#1729) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Hiding minizip-ng symbols on Mac Signed-off-by: Cédrik Fuoco * Fixing a linking issue related to the code that tries to hide expat symbols and small refactor to add robustness. Signed-off-by: Cédrik Fuoco Signed-off-by: Cédrik Fuoco Co-authored-by: Doug Walker (cherry picked from commit 907ed3be172e8adea2a9d8e5a56238888db57b44) Signed-off-by: Cédrik Fuoco --- src/OpenColorIO/CMakeLists.txt | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/OpenColorIO/CMakeLists.txt b/src/OpenColorIO/CMakeLists.txt index b667a6d1fa..1c4d774ddb 100755 --- a/src/OpenColorIO/CMakeLists.txt +++ b/src/OpenColorIO/CMakeLists.txt @@ -368,9 +368,36 @@ if(UNIX AND NOT APPLE) set_property (TARGET OpenColorIO APPEND PROPERTY LINK_FLAGS "-Wl,--exclude-libs,ALL") elseif(APPLE) - # Hide the expat symbols. - set_property (TARGET OpenColorIO - APPEND PROPERTY LINK_FLAGS "-Wl,-hidden-lexpat") + if (expat_LIBRARY) + get_filename_component(_expat_LIBDIR "${expat_LIBRARY}" DIRECTORY) + # Add the path to CMake list of search paths for libraries. + list(APPEND _OCIO_LINK_FLAGS_LIST_ "-Wl,-L${_expat_LIBDIR}") + # Hide the expat symbols. + list(APPEND _OCIO_LINK_FLAGS_LIST_ "-Wl,-hidden-lexpat") + endif() + + + # Check for minizip first since our Findminizip module sets minizip-ng_LIBRARY. + if (minizip_LIBRARY) + get_filename_component(_minizip-ng_LIBDIR "${minizip_LIBRARY}" DIRECTORY) + set(_minizip-ng_NAME "minizip") + elseif(minizip-ng_LIBRARY) + get_filename_component(_minizip-ng_LIBDIR "${minizip-ng_LIBRARY}" DIRECTORY) + set(_minizip-ng_NAME "minizip-ng") + endif() + + if (_minizip-ng_LIBDIR) + # Add the path to CMake list of search paths for libraries. + list(APPEND _OCIO_LINK_FLAGS_LIST_ "-Wl,-L${_minizip-ng_LIBDIR}") + # Hide the minizip-ng symbols. + list(APPEND _OCIO_LINK_FLAGS_LIST_ "-Wl,-hidden-l${_minizip-ng_NAME}") + endif() + + if (_OCIO_LINK_FLAGS_LIST_) + list(JOIN _OCIO_LINK_FLAGS_LIST_ " " _OCIO_LINK_FLAGS_LIST_) + set_property (TARGET OpenColorIO + APPEND PROPERTY LINK_FLAGS "${_OCIO_LINK_FLAGS_LIST_}") + endif() endif() if(MSVC AND BUILD_SHARED_LIBS) From f056902a153e1b2fb71749374185018f4e1255f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= <105517825+cedrik-fuoco-adsk@users.noreply.github.com> Date: Thu, 22 Dec 2022 20:48:34 -0500 Subject: [PATCH 08/13] Adsk contrib - Fix issue with is colorspace linear (#1734) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Throw when the colorspace is undefined for isColorSpaceLinear method. (+ unit test) Signed-off-by: Cédrik Fuoco * Typo Signed-off-by: Cédrik Fuoco Signed-off-by: Cédrik Fuoco Co-authored-by: Doug Walker (cherry picked from commit 6d7c4791f15c14d6d7457f5d59bf2d126e62865f) Signed-off-by: Cédrik Fuoco --- src/OpenColorIO/Config.cpp | 7 +++++++ tests/cpu/ColorSpace_tests.cpp | 13 +++++++++++++ tests/python/ColorSpaceTest.py | 6 ++++++ 3 files changed, 26 insertions(+) diff --git a/src/OpenColorIO/Config.cpp b/src/OpenColorIO/Config.cpp index bdf9994756..665d522390 100644 --- a/src/OpenColorIO/Config.cpp +++ b/src/OpenColorIO/Config.cpp @@ -3127,6 +3127,13 @@ bool Config::isColorSpaceLinear(const char * colorSpace, ReferenceSpaceType refe { auto cs = getColorSpace(colorSpace); + if (cs == nullptr) + { + std::ostringstream os; + os << "Could not test colorspace linearity. Colorspace " << colorSpace << " does not exist."; + throw Exception(os.str().c_str()); + } + if (cs->isData()) { return false; diff --git a/tests/cpu/ColorSpace_tests.cpp b/tests/cpu/ColorSpace_tests.cpp index fc3a6581a6..db959703c7 100644 --- a/tests/cpu/ColorSpace_tests.cpp +++ b/tests/cpu/ColorSpace_tests.cpp @@ -898,6 +898,19 @@ inactive_colorspaces: [display_linear-trans, scene_linear-trans] OCIO_CHECK_EQUAL_FROM(isLinearToDisplayReference, bDisplayExpected, line); }; + // Test undefined color spaces. + { + OCIO_CHECK_THROW_WHAT( + config->isColorSpaceLinear("colorspace_abc", OCIO::REFERENCE_SPACE_SCENE), OCIO::Exception, + "Could not test colorspace linearity. Colorspace colorspace_abc does not exist" + ); + + OCIO_CHECK_THROW_WHAT( + config->isColorSpaceLinear("colorspace_abc", OCIO::REFERENCE_SPACE_DISPLAY), OCIO::Exception, + "Could not test colorspace linearity. Colorspace colorspace_abc does not exist" + ); + } + { testSceneReferred("display_data", false, __LINE__); testSceneReferred("display_linear-enc", false, __LINE__); diff --git a/tests/python/ColorSpaceTest.py b/tests/python/ColorSpaceTest.py index 792bcf5fec..465539886c 100644 --- a/tests/python/ColorSpaceTest.py +++ b/tests/python/ColorSpaceTest.py @@ -579,6 +579,12 @@ def test_display_referred(self, cfg, cs_name, expected_value): ) self.assertEqual(is_linear_to_display_reference, expected_value) + # Test undefined color spaces. + with self.assertRaises(OCIO.Exception): + cfg.isColorSpaceLinear('colorspace_abc', OCIO.REFERENCE_SPACE_SCENE) + with self.assertRaises(OCIO.Exception): + cfg.isColorSpaceLinear('colorspace_abc', OCIO.REFERENCE_SPACE_DISPLAY) + # Test the scene referred color spaces. test_scene_referred(self, cfg, "display_data", False) test_scene_referred(self, cfg, "display_linear-enc", False) From 2ce2ee91c6339e986f149e30a43cdfeacf697bd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= <105517825+cedrik-fuoco-adsk@users.noreply.github.com> Date: Tue, 3 Jan 2023 23:40:07 -0500 Subject: [PATCH 09/13] Adsk Contrib - Improve naming of ICC-based displays on Windows (#1742) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adding a method to get the Monitor's userFriendlyName if available Signed-off-by: Cédrik Fuoco * Removing the slashes at the start of the display name Signed-off-by: Cédrik Fuoco * Adding descriptions and comments. Adding troubleshooting script that print the monitor display name and ICC profile path. Signed-off-by: Cédrik Fuoco * no message Signed-off-by: Cédrik Fuoco * Comments Signed-off-by: Cédrik Fuoco Signed-off-by: Cédrik Fuoco Co-authored-by: Doug Walker (cherry picked from commit 1d126b56e9c9b6b36fc013f7eb52fc12f896f8a3) Signed-off-by: Cédrik Fuoco --- .../troubleshooting/print_system_monitors.py | 21 ++++ src/OpenColorIO/SystemMonitor_windows.cpp | 106 ++++++++++++++++-- 2 files changed, 120 insertions(+), 7 deletions(-) create mode 100644 share/troubleshooting/print_system_monitors.py diff --git a/share/troubleshooting/print_system_monitors.py b/share/troubleshooting/print_system_monitors.py new file mode 100644 index 0000000000..4c3932e85c --- /dev/null +++ b/share/troubleshooting/print_system_monitors.py @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. +# +# This script will print the information OCIO has for each active monitor/display +# connected to the system. The information consists of a Monitor Name and a path +# to the monitor's ICC profile. +# +# OCIO attempts to build the unique Monitor Name based on information available +# from the operating system, but sometimes that information may not be that helpful. +# Ideally the Monitor Names should be descriptive enough to allow a user to determine +# which name corresponds to which physical display and yet brief enough that they are +# able to be used in menus that list the available displays. +# +# This script is an easy way to check the information OCIO detects on a given system +# and may be useful when submitting bug reports. +# +import PyOpenColorIO as OCIO + +for m in OCIO.SystemMonitors().getMonitors(): + # Each element is a tuple containing the monitor display name and the ICC profile path. + print(m) \ No newline at end of file diff --git a/src/OpenColorIO/SystemMonitor_windows.cpp b/src/OpenColorIO/SystemMonitor_windows.cpp index d981fbe7b4..4b8d71584b 100644 --- a/src/OpenColorIO/SystemMonitor_windows.cpp +++ b/src/OpenColorIO/SystemMonitor_windows.cpp @@ -13,7 +13,7 @@ #include #include "Platform.h" - +#include "utils/StringUtils.h" namespace OCIO_NAMESPACE { @@ -21,11 +21,87 @@ namespace OCIO_NAMESPACE static constexpr char ErrorMsg[] { "Problem obtaining monitor profile information from operating system." }; +// List all active display paths using QueryDisplayConfig and GetDisplayConfigBufferSizes. +// Get the data from each path using DisplayConfigGetDeviceInfo. +void getAllMonitorsWithQueryDisplayConfig(std::vector & monitorsName) +{ + // https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-displayconfig_path_info + std::vector paths; + // https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-displayconfig_mode_info + std::vector modes; + + UINT32 flags = QDC_ONLY_ACTIVE_PATHS | QDC_VIRTUAL_MODE_AWARE; + LONG result = ERROR_SUCCESS; + do + { + // Determine how many path and mode structures to allocate. + UINT32 pathCount, modeCount; + // The GetDisplayConfigBufferSizes function retrieves the size of the buffers that are + // required to call the QueryDisplayConfig function. + result = GetDisplayConfigBufferSizes(flags, &pathCount, &modeCount); + + // Allocate the path and mode arrays. + paths.resize(pathCount); + modes.resize(modeCount); + + // The QueryDisplayConfig function retrieves information about all possible display paths + // for all display devices, or views, in the current setting. + result = QueryDisplayConfig(flags, &pathCount, paths.data(), &modeCount, modes.data(), nullptr); + + // The function may have returned fewer paths/modes than estimated. + paths.resize(pathCount); + modes.resize(modeCount); + + // It's possible that between the call to GetDisplayConfigBufferSizes and QueryDisplayConfig + // that the display state changed, so loop on the case of ERROR_INSUFFICIENT_BUFFER. + } while (result == ERROR_INSUFFICIENT_BUFFER); + + if (result == ERROR_SUCCESS) + { + // For each active path + for (auto& path : paths) + { + // The DISPLAYCONFIG_TARGET_DEVICE_NAME structure contains information about the target. + // Find the target (monitor) friendly name + DISPLAYCONFIG_TARGET_DEVICE_NAME targetName = {}; + targetName.header.adapterId = path.targetInfo.adapterId; + targetName.header.id = path.targetInfo.id; + targetName.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME; + targetName.header.size = sizeof(targetName); + result = DisplayConfigGetDeviceInfo(&targetName.header); + + if (result == ERROR_SUCCESS) + { + monitorsName.push_back( + (result == ERROR_SUCCESS && targetName.flags.friendlyNameFromEdid) ? + targetName.monitorFriendlyDeviceName : L"" + ); + } + } + } + +} + +/** + * Populate the internal structure with monitors name and ICC profiles name. + * + * Expected monitor display name: + * + * DISPLAYn, + * + * where n is a positive integer starting at 1. + * where monitorFriendlyDeviceName comes from DISPLAYCONFIG_TARGET_DEVICE_NAME structure. + * where DeviceString comes from DISPLAY_DEVICE structure. + * + */ void SystemMonitorsImpl::getAllMonitors() { m_monitors.clear(); + std::vector friendlyMonitorNames; + getAllMonitorsWithQueryDisplayConfig(friendlyMonitorNames); + // Initialize the structure. DISPLAY_DEVICE dispDevice; ZeroMemory(&dispDevice, sizeof(dispDevice)); @@ -33,6 +109,7 @@ void SystemMonitorsImpl::getAllMonitors() // Iterate over all the monitors. DWORD dispNum = 0; + // After the first call to EnumDisplayDevices, dispDevice.DeviceString is the adapter name. while (EnumDisplayDevices(nullptr, dispNum, &dispDevice, 0)) { const std::tstring deviceName = dispDevice.DeviceName; @@ -49,9 +126,10 @@ void SystemMonitorsImpl::getAllMonitors() ZeroMemory(&dispDevice, sizeof(dispDevice)); dispDevice.cb = sizeof(dispDevice); - // After a second call, dispDev.DeviceString contains the - // monitor name for that device. - EnumDisplayDevices(deviceName.c_str(), dispNum, &dispDevice, 0); + // After second call, dispDevice.DeviceString is the monitor name for that device. + // Second parameters must be 0 to get the monitor name. + // See https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-enumdisplaydevicesw + EnumDisplayDevices(deviceName.c_str(), 0, &dispDevice, 0); TCHAR icmPath[MAX_PATH + 1]; DWORD pathLength = MAX_PATH; @@ -60,8 +138,23 @@ void SystemMonitorsImpl::getAllMonitors() // TODO: Several ICM profiles could be associated to a single device. - const std::tstring displayName - = deviceName + TEXT(", ") + dispDevice.DeviceString; + bool idxExists = friendlyMonitorNames.size() >= dispNum+1; + bool friendlyNameExists = idxExists && !friendlyMonitorNames.at(dispNum).empty(); + + // Check if the distNum index exists in friendlyMonitorNames vector and check if + // there is a corresponding friendly name. + const std::tstring extra = friendlyNameExists ? + friendlyMonitorNames.at(dispNum) : std::tstring(dispDevice.DeviceString); + + std::tstring strippedDeviceName = deviceName; + if(StringUtils::StartsWith(Platform::Utf16ToUtf8(deviceName), "\\\\.\\DISPLAY")) + { + // Remove the slashes. + std::string prefix = "\\\\.\\"; + strippedDeviceName = deviceName.substr(prefix.length()); + } + + const std::tstring displayName = strippedDeviceName + TEXT(", ") + extra; // Get the associated ICM profile path. if (GetICMProfile(hDC, &pathLength, icmPath)) @@ -98,5 +191,4 @@ void SystemMonitorsImpl::getAllMonitors() } } - } // namespace OCIO_NAMESPACE From 8cc106875672a0ea4740b21bcdc37030bd155cb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Achard?= Date: Wed, 4 Jan 2023 21:14:21 +0100 Subject: [PATCH 10/13] Fix minizip-ng CMake args passing (#1741) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémi Achard Signed-off-by: Rémi Achard Co-authored-by: Doug Walker (cherry picked from commit 051241c9f12b5ac1a82c61a92715dfabbcf42c50) Signed-off-by: Cédrik Fuoco --- share/cmake/modules/Findminizip-ng.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/cmake/modules/Findminizip-ng.cmake b/share/cmake/modules/Findminizip-ng.cmake index b0136abc5f..0915ad8b18 100644 --- a/share/cmake/modules/Findminizip-ng.cmake +++ b/share/cmake/modules/Findminizip-ng.cmake @@ -193,8 +193,8 @@ if(NOT minizip_FOUND AND NOT TARGET MINIZIP::minizip) "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${_minizip-ng_LIB_PREFIX}minizip-ng${_minizip-ng_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") if(_minizip-ng_TARGET_CREATE) - set(MINIZIP-NG_CMAKE_ARGS - ${MINIZIP-NG_CMAKE_ARGS} + set(minizip-ng_CMAKE_ARGS + ${minizip-ng_CMAKE_ARGS} -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} -DCMAKE_POSITION_INDEPENDENT_CODE=ON @@ -265,7 +265,7 @@ if(NOT minizip_FOUND AND NOT TARGET MINIZIP::minizip) GIT_SHALLOW TRUE PREFIX "${_EXT_BUILD_ROOT}/libminizip-ng" BUILD_BYPRODUCTS ${minizip-ng_LIBRARY} - CMAKE_ARGS ${MINIZIP-NG_CMAKE_ARGS} + CMAKE_ARGS ${minizip-ng_CMAKE_ARGS} EXCLUDE_FROM_ALL TRUE BUILD_COMMAND "" INSTALL_COMMAND From 7b651a56caec791128513e8405948414ff3fbd67 Mon Sep 17 00:00:00 2001 From: Doug Walker Date: Wed, 4 Jan 2023 16:00:36 -0500 Subject: [PATCH 11/13] Fix inverse Lut1D optimization bug (#1743) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Doug Walker Signed-off-by: Doug Walker (cherry picked from commit 5152635a189f05e85af8a7bff62fb348ec293d97) Signed-off-by: Cédrik Fuoco --- src/OpenColorIO/OpOptimizers.cpp | 34 +++++++++- src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp | 80 +++++++++++++++++++++++ src/OpenColorIO/ops/lut1d/Lut1DOpData.h | 2 + tests/cpu/OpOptimizers_tests.cpp | 57 ++++++++++++++++ 4 files changed, 172 insertions(+), 1 deletion(-) diff --git a/src/OpenColorIO/OpOptimizers.cpp b/src/OpenColorIO/OpOptimizers.cpp index 8b7e2c2fc7..7788bfb164 100755 --- a/src/OpenColorIO/OpOptimizers.cpp +++ b/src/OpenColorIO/OpOptimizers.cpp @@ -12,6 +12,7 @@ #include "Op.h" #include "ops/lut1d/Lut1DOp.h" #include "ops/lut3d/Lut3DOp.h" +#include "ops/range/RangeOp.h" namespace OCIO_NAMESPACE { @@ -241,7 +242,38 @@ int RemoveInverseOps(OpRcPtrVec & opVec, OptimizationFlags oFlags) // When a pair of inverse ops is removed, we want the optimized ops to give the // same result as the original. For certain ops such as Lut1D or Log this may // mean inserting a Range to emulate the clamping done by the original ops. - auto replacedBy = op1->getIdentityReplacement(); + + OpRcPtr replacedBy; + if (type1 == OpData::Lut1DType) + { + // Lut1D gets special handling so that both halfs of the pair are available. + // Only the inverse LUT has the values needed to generate the replacement. + + ConstLut1DOpDataRcPtr lut1 = OCIO_DYNAMIC_POINTER_CAST(op1->data()); + ConstLut1DOpDataRcPtr lut2 = OCIO_DYNAMIC_POINTER_CAST(op2->data()); + + OpDataRcPtr opData = lut1->getPairIdentityReplacement(lut2); + + OpRcPtrVec ops; + if (opData->getType() == OpData::MatrixType) + { + // No-op that will be optimized. + auto mat = OCIO_DYNAMIC_POINTER_CAST(opData); + CreateMatrixOp(ops, mat, TRANSFORM_DIR_FORWARD); + } + else if (opData->getType() == OpData::RangeType) + { + // Clamping op. + auto range = OCIO_DYNAMIC_POINTER_CAST(opData); + CreateRangeOp(ops, range, TRANSFORM_DIR_FORWARD); + } + replacedBy = ops[0]; + } + else + { + replacedBy = op1->getIdentityReplacement(); + } + replacedBy->finalize(); if (replacedBy->isNoOp()) { diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp b/src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp index 899981615a..a12a7a3e1f 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpData.cpp @@ -279,6 +279,86 @@ OpDataRcPtr Lut1DOpData::getIdentityReplacement() const return res; } +OpDataRcPtr Lut1DOpData::getPairIdentityReplacement(ConstLut1DOpDataRcPtr & lut2) const +{ + OpDataRcPtr res; + if (isInputHalfDomain()) + { + // TODO: If a half-domain LUT has a flat spot, it would be more appropriate + // to use a Range, since some areas would be clamped in a round-trip. + // Currently leaving this a Matrix since it is a potential work-around + // for situations where you want a pair identity of LUTs to be totally + // removed, even if it omits some clamping at extreme values. + res = std::make_shared(); + } + else + { + // Note that the ops have been finalized by the time this is called, + // Therefore, for an inverse Lut1D, it means initializeFromForward() has + // been called and so any reversals have been converted to flat regions. + // Therefore, the first and last LUT entries are the extreme values and + // the ComponentProperties has been initialized, but only for the op + // whose direction is INVERSE. + const Lut1DOpData * invLut = (m_direction == TRANSFORM_DIR_INVERSE) + ? this: lut2.get(); + const ComponentProperties & redProperties = invLut->getRedProperties(); + const unsigned long length = invLut->getArray().getLength(); + + // If the start or end of the LUT contains a flat region, that will cause + // a round-trip to be limited. + + double minValue = 0.; + double maxValue = 1.; + switch (m_direction) + { + case TRANSFORM_DIR_FORWARD: // Fwd Lut1D -> Inv Lut1D + { + // A round-trip in this order will impose at least a clamp to [0,1] + // based on what happens entering the first Fwd Lut1D. However, the + // clamping may be to an even narrower range if there are flat regions. + // + // The flat region limitation is imposed based on the where it falls + // relative to the [0,1] input domain. + + // TODO: A RangeOp has one min & max for all channels, whereas a Lut1D may + // have three independent channels. Potentially could look at all chans + // and take the extrema of each? For now, just using the first channel. + const unsigned long minIndex = redProperties.startDomain; + const unsigned long maxIndex = redProperties.endDomain; + + minValue = (double)minIndex / (length - 1); + maxValue = (double)maxIndex / (length - 1); + break; + } + case TRANSFORM_DIR_INVERSE: // Inv Lut1D -> Fwd Lut1D + { + // A round-trip in this order will impose a clamp, but it may be to + // bounds outside of [0,1] since the Fwd LUT may contain values outside + // [0,1] and so the Inv LUT will accept inputs on that extended range. + // + // The flat region limitation is imposed based on the output range. + + const bool isIncreasing = redProperties.isIncreasing; + const unsigned long maxChannels = invLut->getArray().getMaxColorComponents(); + const unsigned long lastValIndex = (length - 1) * maxChannels; + // Note that the array for the invLut has had initializeFromForward() + // done and so any reversals have been converted to flat regions and + // the extrema are at the beginning & end of the LUT. + const Array::Values & lutValues = invLut->getArray().getValues(); + + // TODO: Currently only basing this on the red channel. + minValue = isIncreasing ? lutValues[0] : lutValues[lastValIndex]; + maxValue = isIncreasing ? lutValues[lastValIndex] : lutValues[0]; + break; + } + } + + res = std::make_shared(minValue, maxValue, + minValue, maxValue); + } + return res; +} + void Lut1DOpData::setInputHalfDomain(bool isHalfDomain) noexcept { m_halfFlags = (isHalfDomain) ? diff --git a/src/OpenColorIO/ops/lut1d/Lut1DOpData.h b/src/OpenColorIO/ops/lut1d/Lut1DOpData.h index a536b5a460..d06ca8da6d 100644 --- a/src/OpenColorIO/ops/lut1d/Lut1DOpData.h +++ b/src/OpenColorIO/ops/lut1d/Lut1DOpData.h @@ -179,6 +179,8 @@ class Lut1DOpData : public OpData OpDataRcPtr getIdentityReplacement() const override; + OpDataRcPtr getPairIdentityReplacement(ConstLut1DOpDataRcPtr & lut2) const; + inline const ComponentProperties & getRedProperties() const { return m_componentProperties[0]; diff --git a/tests/cpu/OpOptimizers_tests.cpp b/tests/cpu/OpOptimizers_tests.cpp index b3305f4def..6f606fd6e8 100644 --- a/tests/cpu/OpOptimizers_tests.cpp +++ b/tests/cpu/OpOptimizers_tests.cpp @@ -645,6 +645,63 @@ OCIO_ADD_TEST(OpOptimizers, lut1d_identity_replacement) } } +OCIO_ADD_TEST(OpOptimizers, lut1d_identity_replacement_order) +{ + // See issue #1737, https://github.com/AcademySoftwareFoundation/OpenColorIO/issues/1737. + + // This CTF contains a single LUT1D, inverse direction, normal (not half) domain. + // It contains values from -6 to +3.4. + const std::string fileName("lut1d_inverse_gpu.ctf"); + OCIO::ContextRcPtr context = OCIO::Context::Create(); + + OCIO::OpRcPtrVec inv_ops; + OCIO_CHECK_NO_THROW(OCIO::BuildOpsTest(inv_ops, fileName, context, + // FWD direction simply means don't swap the direction, the + // file contains an inverse LUT1D and leave it that way. + OCIO::TRANSFORM_DIR_FORWARD)); + OCIO::OpRcPtrVec fwd_ops; + OCIO_CHECK_NO_THROW(OCIO::BuildOpsTest(fwd_ops, fileName, context, + OCIO::TRANSFORM_DIR_INVERSE)); + + // Check forward LUT1D followed by inverse LUT1D. + { + OCIO::OpRcPtrVec fwd_inv_ops = fwd_ops; + fwd_inv_ops += inv_ops; + + OCIO_CHECK_NO_THROW(fwd_inv_ops.finalize()); + OCIO_CHECK_NO_THROW(fwd_inv_ops.optimize(OCIO::OPTIMIZATION_NONE)); + OCIO_CHECK_EQUAL(fwd_inv_ops.size(), 2); // no optmization was done + + OCIO::OpRcPtrVec optOps = fwd_inv_ops.clone(); + OCIO_CHECK_NO_THROW(optOps.finalize()); + OCIO_CHECK_NO_THROW(optOps.optimize(OCIO::OPTIMIZATION_DEFAULT)); + OCIO_CHECK_EQUAL(optOps.size(), 1); + OCIO_CHECK_EQUAL(optOps[0]->getInfo(), ""); + + // Compare renders. + CompareRender(fwd_inv_ops, optOps, __LINE__, 1e-6f); + } + + // Check inverse LUT1D followed by forward LUT1D. + { + OCIO::OpRcPtrVec inv_fwd_ops = inv_ops; + inv_fwd_ops += fwd_ops; + + OCIO_CHECK_NO_THROW(inv_fwd_ops.finalize()); + OCIO_CHECK_NO_THROW(inv_fwd_ops.optimize(OCIO::OPTIMIZATION_NONE)); + OCIO_CHECK_EQUAL(inv_fwd_ops.size(), 2); // no optmization was done + + OCIO::OpRcPtrVec optOps = inv_fwd_ops.clone(); + OCIO_CHECK_NO_THROW(optOps.finalize()); + OCIO_CHECK_NO_THROW(optOps.optimize(OCIO::OPTIMIZATION_DEFAULT)); + OCIO_CHECK_EQUAL(optOps.size(), 1); + OCIO_CHECK_EQUAL(optOps[0]->getInfo(), ""); + + // Compare renders. + CompareRender(inv_fwd_ops, optOps, __LINE__, 1e-6f); + } +} + OCIO_ADD_TEST(OpOptimizers, lut1d_half_domain_keep_prior_range) { // A half-domain LUT should not allow removal of a prior range op. From 213c6dd3d8428db2d28e68c0e257a28da0e01ec8 Mon Sep 17 00:00:00 2001 From: Doug Walker Date: Wed, 4 Jan 2023 16:44:23 -0500 Subject: [PATCH 12/13] Update documentation for 2.2 release (#1738) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update documentation for 2.2 release Signed-off-by: Doug Walker * Fix typos Signed-off-by: Doug Walker * Remove V2_DOC_README.md Signed-off-by: Doug Walker * Tweaks to 2.2 Signed-off-by: Doug Walker * Improve installation section Signed-off-by: Doug Walker * Add link to demo config Signed-off-by: Doug Walker * Fix typos Signed-off-by: Doug Walker * Improve file_rules section Signed-off-by: Doug Walker Signed-off-by: Doug Walker (cherry picked from commit 17f5c98f9b89e423f66d0cd07a2334467b1bdee0) Signed-off-by: Cédrik Fuoco --- COMMITTERS.md | 1 + CONTRIBUTING.md | 41 +- docs/V2_DOC_README.md | 106 ----- docs/concepts/publications/publications.rst | 27 +- docs/configurations/_index.rst | 6 +- docs/configurations/aces_1.0.3.rst | 8 +- docs/configurations/aces_cg.rst | 42 ++ docs/configurations/aces_studio.rst | 41 ++ docs/configurations/ocio_v2_demo.rst | 4 + docs/guides/authoring/colorspaces.rst | 18 +- docs/guides/authoring/overview.rst | 19 +- docs/guides/authoring/rules.rst | 57 ++- docs/guides/authoring/transforms.rst | 1 + .../contributing/documentation_guidelines.rst | 102 ++++- .../contributing/repository_structure.rst | 28 +- .../contributing/submitting_changes.rst | 10 +- docs/guides/using_ocio/tool_overview.rst | 48 ++- docs/index.rst | 25 +- docs/quick_start/downloads.rst | 39 +- docs/quick_start/for_artists.rst | 9 +- docs/quick_start/for_config_authors.rst | 9 +- docs/quick_start/for_contributors.rst | 5 +- docs/quick_start/for_devs.rst | 18 +- docs/quick_start/installation.rst | 374 +++++++++++------ docs/{upgrading_v2 => releases}/_index.rst | 8 +- .../how_to.rst => releases/ocio_2_0.rst} | 24 +- docs/releases/ocio_2_1.rst | 173 ++++++++ docs/releases/ocio_2_2.rst | 395 ++++++++++++++++++ docs/toc_redirect.rst | 2 +- include/OpenColorIO/OpenColorIO.h | 26 +- include/OpenColorIO/OpenColorTypes.h | 5 +- 31 files changed, 1259 insertions(+), 412 deletions(-) delete mode 100644 docs/V2_DOC_README.md create mode 100644 docs/configurations/aces_cg.rst create mode 100644 docs/configurations/aces_studio.rst rename docs/{upgrading_v2 => releases}/_index.rst (74%) rename docs/{upgrading_v2/how_to.rst => releases/ocio_2_0.rst} (97%) create mode 100644 docs/releases/ocio_2_1.rst create mode 100644 docs/releases/ocio_2_2.rst diff --git a/COMMITTERS.md b/COMMITTERS.md index e7da40cb39..23ed878e73 100644 --- a/COMMITTERS.md +++ b/COMMITTERS.md @@ -20,3 +20,4 @@ The current OpenColorIO Committers are: | Doug Walker | @doug-walker | | Kevin Wheatley | @KevinJW | | Rémi Achard | @remia | +| Cédrik Fuoco | @cedrik-fuoco-adsk | diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 684e09a7a1..0d0a442c4b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,7 +19,7 @@ explains our contribution process and procedures, so please review it first: For a description of the roles and responsibilities of the various members of the OpenColorIO community, see [GOVERNANCE](GOVERNANCE.md), and for further details, see the project's -[Technical Charter](docs/aswf/Charter.md). Briefly, Contributors are anyone +[Technical Charter](ASWF/Charter.md). Briefly, Contributors are anyone who submits content to the project, Committers review and approve such submissions, and the Technical Steering Committee provides general project oversight. @@ -214,18 +214,20 @@ the work. a Committer other than the PR contributor may squash and merge changes into the main branch. -See also (from the OCIO Developer Guide): -* [Getting started](http://opencolorio.org/developers/getting_started.html) -* [Submitting Changes](http://opencolorio.org/developers/submitting_changes.html) +For a more detailed description of the contribution process, please see the +Contributing Guide in the main OCIO documentation: + +* [Getting Started](https://opencolorio.readthedocs.io/en/latest/guides/contributing/contributing.html#getting-started) +* [Submitting Changes](https://opencolorio.readthedocs.io/en/latest/guides/contributing/contributing.html#submitting-changes) ## Coding Standards Please see the OpenColorIO -[Coding guidelines](http://opencolorio.org/developers/coding_guidelines.html) +[Coding guidelines](https://opencolorio.readthedocs.io/en/latest/guides/contributing/contributing.html#coding-style-guide) for a reference on project code style and best practices. For standards on contributing to documentation, see the -[Documentation guidelines](http://opencolorio.org/developers/documentation_guidelines.html). +[Documentation guidelines](https://opencolorio.readthedocs.io/en/latest/guides/contributing/contributing.html#documentation-guidelines). ## Test Policy @@ -245,27 +247,8 @@ The test should should be run, via ``ctest``, before submitting a pull request. ## Versioning Policy -OpenColorIO uses [semantic versioning](https://semver.org), which labels each -version with three numbers: Major.Minor.Patch, where: - -* **MAJOR** indicates incompatible API changes -* **MINOR** indicates functionality added in a backwards-compatible manner -* **PATCH** indicates backwards-compatible bug fixes - -## Creating a Release - -To create a new release from the main branch: - -1. Update the release notes in ``CHANGELOG.md`` with a high-level summary of - the features and improvements. Also include the summary in the Release - comments. - -2. Create a new release on the GitHub Releases page. - -3. Tag the release with name beginning with '``v``', e.g. '``v2.1.0``'. - -4. Download and sign the release tarball, as described - [here](https://wiki.debian.org/Creating%20signed%20GitHub%20releases), +OpenColorIO labels each version with three numbers: Major.Minor.Patch, where: -5. Attach the detached ``.asc`` signature file to the GitHub release as a - binary file. +* **MAJOR** indicates major architectural changes +* **MINOR** indicates an introduction of significant new features +* **PATCH** indicates ABI-compatible bug fixes and minor enhancements diff --git a/docs/V2_DOC_README.md b/docs/V2_DOC_README.md deleted file mode 100644 index 45bb946eeb..0000000000 --- a/docs/V2_DOC_README.md +++ /dev/null @@ -1,106 +0,0 @@ -# OCIO v2 Documentation Effort - -Since the API autodoc effort is happening simultaneously it will be easier for -a lot of contributors to do a light-weight build of the Sphinx docs, which -doesn't require building OCIO in its entirety. - -## How to Build HTML Docs - -In addition to the general OCIO v2 dependencies, install Doxygen, Sphinx, and -the Python packages listed in the `docs/requirements.txt` file. - -Doxygen can be installed with a package manager, or by downloading a binary -distribution from [Doxygen's website](https://www.doxygen.nl/download.html). -Use one of the following commands to install Doxygen with a platform-specific -package manager: - -Linux (Debian, etc.): - -``` -apt-get install doxygen -``` - -Linux (Fedora, etc.): - -``` -yum install doxygen -``` - -macOS ([Homebrew](https://brew.sh/)): - -``` -brew install doxygen -``` - -Windows ([Chocolatey](https://chocolatey.org/)): - -``` -choco install doxygen.install -``` - -Sphinx and the other Python dependencies can be installed with a single `pip` -command on all platforms: - -``` -pip install -r docs/requirements.txt -``` - -To build only the RST docs (excluding API) locally: - -``` -cd docs -mkdir _build -sphinx-build -b html . _build - _build/index.html -``` - -To build all HTML docs (including API) locally: - -``` -mkdir _build -cd _build -cmake ../. -DOCIO_BUILD_DOCS=ON -DCMAKE_INSTALL_PREFIX=../_install -make -j docs - docs/build-html/index.html -``` - -Python 3 is required to build the documentation. If you have multiple Python -installs you'll need to make sure pip and CMake find the correct version. You -can manually inform cmake of which to use by adding this option to the above -`cmake` command, which configures the documentation build: - -``` --DPython_ROOT= -``` - -To ease the documentation build and test on macOS one could also add these -three lines in the ~/.zshrc file: - -``` -alias python=/usr/local/bin/python3 -alias pip=/usr/local/bin/pip3 -alias =open -a "" -``` - -## Quirks - -The vuepress theme that we've migrated to has some quirks to its design. For -example it only allows two nested table of contents (TOC). So things have to be -organized in a slightly different way than other sphinx projects. - -The root-level `toc_redirect.rst` points to where to find the different section -TOCs. The name and contents of each sections TOC is defined in that -sub-directory's `_index.rst` file. - -In this TOC the `:caption:` directive determines what the name of the section -will be in the side-bar, and in the header of the website. The *H1* header -determines the name of the page in the right/left arrows navigation bar. In a -lot of cases this ends up doubling up the name on the page, but this seems -unavoidable at the present time. If additional explanatory text is put in the -`_index.rst` files then it shouldn't be as problematic. - -The site will show all *H1* headers in the side panel by default, these then -expand when selected to show all *H2* headers. - -Due to the limited TOC and side-bar depth, we shouldn't be afraid of looong -pages with many *H2* headings to break down the page into logical quadrants. diff --git a/docs/concepts/publications/publications.rst b/docs/concepts/publications/publications.rst index fe64c6f2f8..dfa8fcf778 100644 --- a/docs/concepts/publications/publications.rst +++ b/docs/concepts/publications/publications.rst @@ -4,11 +4,28 @@ .. _publications: -Publications -============ +Presentations & Publications +============================ -DigiPro 2020 **paper** `"The ASWF takes OpenColorIO to the Next Level" `_ +* OCIO wins the Pipeline Tool award at DigiPro 2022! `video `_ -DigiPro 2020 **video** `"The ASWF takes OpenColorIO to the Next Level" `_ +* ASWF Open Source Days 2022 `video `_ -`Cinematic Color `_ +* HPA Tech Retreat 2022 "Color Processing with OCIO v2 and the Academy/ASC Common LUT Format" + `Slides & Tutorial `_ + +* OCIO v2 wins an Engineering Excellence award from the Hollywood Post Alliance! + `article `_ + +* SIGGRAPH 2021 course "Color management with OpenColorIO V2" + `video `__ `PDF `__ `ACM `_ + +* ASWF Open Source Days 2021 `video `_ + +* DigiPro 2020 "The ASWF takes OpenColorIO to the Next Level" `video `__ `PDF `__ `ACM `_ + +* ASWF Open Source Days 2020 `video `_ + +* ASWF Open Source Days 2019 `video `_ + +* `Cinematic Color `_ diff --git a/docs/configurations/_index.rst b/docs/configurations/_index.rst index 2b7556688e..734cf350bd 100644 --- a/docs/configurations/_index.rst +++ b/docs/configurations/_index.rst @@ -10,8 +10,10 @@ Configurations .. toctree:: :caption: Configurations + aces_studio + aces_cg + ocio_v2_demo aces_1.0.3 - nuke_default spi_anim spi_vfx - ocio_v2_demo + nuke_default diff --git a/docs/configurations/aces_1.0.3.rst b/docs/configurations/aces_1.0.3.rst index b8ae17d946..ace8b95a0a 100644 --- a/docs/configurations/aces_1.0.3.rst +++ b/docs/configurations/aces_1.0.3.rst @@ -2,17 +2,21 @@ SPDX-License-Identifier: CC-BY-4.0 Copyright Contributors to the OpenColorIO Project. +.. _aces_1.0.3: + aces_1.0.3 ========== This section describes the ACES 1.0.3 OpenColorIO configuration. .. note:: - There is a more recent version of the ACES config for ACES 1.2 available here: + There is a more recent version of the ACES 1.0.3 config for ACES 1.2 available here: - https://github.com/colour-science/OpenColorIO-Configs/tree/feature/aces-1.2-config - An ACES config that takes advantage of the new OCIO v2 features is under development. +.. note:: + Please note that both of these configurations have been supplanted by the new + :ref:`aces_studio` for OCIO v2. Information about ACES diff --git a/docs/configurations/aces_cg.rst b/docs/configurations/aces_cg.rst new file mode 100644 index 0000000000..d134b62b44 --- /dev/null +++ b/docs/configurations/aces_cg.rst @@ -0,0 +1,42 @@ +.. + SPDX-License-Identifier: CC-BY-4.0 + Copyright Contributors to the OpenColorIO Project. + +.. _aces_cg: + +ACES CG Config +============== + +The ACES Computer Graphics (CG) config is a simple, lightweight config intended for use +in typical digital content creation (DCC) apps that need robust choices for texture and +rendering spaces and a basic selection of display and view transforms. + +Users who need a more extensive set of color spaces, including digital cinema camera +color spaces and a wider set of displays and view should look at the :ref:`aces_studio`. + +The latest version of this config may be downloaded from the Releases page of its GitHub +`repo. `_ + +The ACES CG Config leverages the high quality ACES implementation built into OCIO itself +and so requires no external LUT files. In fact, even the config file is built into OCIO +and users may access it from any application that uses OCIO 2.2 or higher by using the +following string in place of the config path:: + ocio://cg-config-v1.0.0_aces-v1.3_ocio-v2.1 + +The default built-in config is currently the ACES CG Config, so the even simpler: +``ocio://default`` may be used instead. Note however, that the value of the default +config may evolve over time. + +The OCIO Configs Working Group collected input from the community and simplified the +naming scheme relative to the earlier OCIO v1 ACES configs. However, aliases have been +added so that the original color space names continue to work (if there is an equivalent +space in the new config). + +Please note that with OCIO v2 we are trying to be more rigorous about what constitutes a +"color space". For this reason, the new configs do not bake view transforms or looks into +the display color spaces. Therefore, it is necessary to use a DisplayViewTransform rather +than a ColorSpaceTransform if you want to bake in an ACES Output Transform. This is not +only more rigorous from a color management point of view, it also helps clarify to end-users +the important role of a view transform in the process. Baking in a view transform is a +fundamentally different process than just converting between color space encodings, and it +should be perceived as such by users. diff --git a/docs/configurations/aces_studio.rst b/docs/configurations/aces_studio.rst new file mode 100644 index 0000000000..0f8132fc58 --- /dev/null +++ b/docs/configurations/aces_studio.rst @@ -0,0 +1,41 @@ +.. + SPDX-License-Identifier: CC-BY-4.0 + Copyright Contributors to the OpenColorIO Project. + +.. _aces_studio: + +ACES Studio Config +================== + +The ACES Studio Config is the successor to the widely used :ref:`ACES config ` +for OCIO v1. + +It contains the complete set of ACES color spaces, displays, and views. In addition, it +contains some extra color spaces that are widely used in the VFX and post-production +industries. + +Users who need a simpler config that contains just the basics needed to use ACES color +management in common DCC tools are encouraged to check out the :ref:`aces_cg`. + +The latest version of this config may be downloaded from the Releases page of its GitHub +`repo. `_ + +The ACES Studio Config leverages the high quality ACES implementation built into OCIO itself +and so requires no external LUT files. In fact, even the config file is built into OCIO +and users may access it from any application that uses OCIO 2.2 or higher by using the +following string in place of the config path:: + ocio://studio-config-v1.0.0_aces-v1.3_ocio-v2.1 + +The OCIO Configs Working Group collected input from the community and simplified the +naming scheme relative to the earlier OCIO v1 ACES configs. However, aliases have been +added so that the original color space names continue to work (if there is an equivalent +space in the new config). + +Please note that with OCIO v2 we are trying to be more rigorous about what constitutes a +"color space". For this reason, the new configs do not bake view transforms or looks into +the display color spaces. Therefore, it is necessary to use a DisplayViewTransform rather +than a ColorSpaceTransform if you want to bake in an ACES Output Transform. This is not +only more rigorous from a color management point of view, it also helps clarify to end-users +the important role of a view transform in the process. Baking in a view transform is a +fundamentally different process than just converting between color space encodings, and it +should be perceived as such by users. diff --git a/docs/configurations/ocio_v2_demo.rst b/docs/configurations/ocio_v2_demo.rst index 22c072c078..52f098f19a 100644 --- a/docs/configurations/ocio_v2_demo.rst +++ b/docs/configurations/ocio_v2_demo.rst @@ -10,6 +10,10 @@ ocio-v2_demo Note: this is not intended to be a complete production-ready config, its purpose is to introduce many of the new features in OCIO v2. +Due to the limitations of the web template, it may be easier for you to read this +config in a text editor. The config file is located +`here. `_ + .. literalinclude:: ocio-v2_demo.ocio :language: yaml diff --git a/docs/guides/authoring/colorspaces.rst b/docs/guides/authoring/colorspaces.rst index 27684f1515..b5cfce0239 100644 --- a/docs/guides/authoring/colorspaces.rst +++ b/docs/guides/authoring/colorspaces.rst @@ -15,19 +15,19 @@ Colorspaces Required. -This section is a list of all the colorspaces known to OCIO. A -colorspace can be referred to elsewhere within the config (including +This section is a list of the scene-referred colorspaces in the config. +A colorspace may be referred to elsewhere within the config (including other colorspace definitions), and are used within OCIO-supporting applications. -A color space may use the following keys: +A colorspace may use the following keys: ``to_scene_reference`` and ``from_scene_reference`` --------------------------------------------------- These keys specify the transforms that define the relationship between -the color space and the scene-referred reference space. +the colorspace and the scene-referred reference space. Note: In OCIO v1, the keys ``to_reference`` and ``from_reference`` were used (since there was only one reference space). These are still supported @@ -404,10 +404,10 @@ compatibility. Optional. -These two options are used when OCIO transforms are applied on the -GPU. +These two options were used in OCIO v1 when transforms were applied on the +GPU. However, the new GPU renderer in OCIO v2 does not need these. -It is also used to automatically generate a "shaper LUT" when +However, they may still be used to automatically generate a "shaper LUT" when :ref:`baking LUT's ` unless one is explicitly specified (not all output formats utilise this) @@ -469,6 +469,8 @@ It's common to use literal ``|`` block syntax to preserve all newlines: This is the second. +.. _config-display-colorspaces: + Display Colorspaces ******************* @@ -477,7 +479,7 @@ Display Colorspaces Optional. -This section is a list of all the display colorspaces known to OCIO. +This section is a list of all the display-referred colorspaces in the config. A display colorspace is very similar to a colorspace except its transforms go from or to the display-referred reference space rather than the scene-referred reference space. diff --git a/docs/guides/authoring/overview.rst b/docs/guides/authoring/overview.rst index 7df06e669c..7d96a97508 100644 --- a/docs/guides/authoring/overview.rst +++ b/docs/guides/authoring/overview.rst @@ -18,6 +18,12 @@ This page alone will not help you to write a useful config file! See the :ref:`configurations` section for examples of complete, practical configs, and discussion of how they fit within a facilities workflow. +Please note that you should use the OCIO Python or C++ API to generate +the config.ocio file rather than writing the YAML by hand in a text editor. +However, if you do ever modify YAML by hand rather than via the API, you +should run :ref:`overview-ociocheck` on it to ensure that the syntax is +correct. + YAML basics *********** @@ -29,7 +35,7 @@ has a good overview. OCIO configs typically use a small subset of YAML, so looking at existing configs is probably the quickest way to familiarise yourself -(just remember the indentation is important!) +(just remember the indentation is important!). Checking for errors ******************* @@ -59,8 +65,12 @@ An OCIO config has the following sections: * :ref:`config-displays-views` -- This section defines how color spaces should be viewed. * :ref:`config-looks` -- Looks are transforms used to adjust colors, such as to apply a creative effect. -* :ref:`config-colorspaces` -- This section defines the universe of color space encodings +* :ref:`config-colorspaces` -- This section defines the scene-referred color space encodings available within the config. +* :ref:`config-display-colorspaces` -- This section defines the display-referred color space + encodings available within the config. +* :ref:`config-named-transforms` -- Named Transforms are a way to provide transforms that + do not have a fixed relationship to a specific reference space, such as a utility curve. A collection of :ref:`config-transforms` is provided for use in the various sections of the config file. @@ -99,11 +109,12 @@ Optional. A brief description of the configuration. ``name`` ^^^^^^^^ -Optional. A unique name for the config. +Optional. A unique name for the config. Future versions of OCIO might use this as a +sort of "namespace" for the color spaces defined in the rest of the config. .. code-block:: yaml - name: foo_2021-02-01 + name: studio-config-v1.0.0_aces-v1.3_ocio-v2.1 ``search_path`` diff --git a/docs/guides/authoring/rules.rst b/docs/guides/authoring/rules.rst index 3c557dbf4a..8fbc35775d 100644 --- a/docs/guides/authoring/rules.rst +++ b/docs/guides/authoring/rules.rst @@ -16,7 +16,9 @@ File & Viewing rules ``file_rules`` ^^^^^^^^^^^^^^ -Either file_rules or the default role are Required. +.. warning:: + Either the file_rules section or the default role are Required for configs of + version 2 or higher. Use the File Rules to assign a default color space to files based on their path. @@ -24,10 +26,10 @@ Here is example showing the various types of rules that may be defined: .. code-block:: yaml - files_rules: + file_rules: - ! {name: LogC, extension: "*", pattern: "*LogC*", colorspace: ARRI LogC} - ! {name: OpenEXR, extension: "exr", pattern: "*", colorspace: ACEScg} - - ! {name: TIFF, regex: ".*\.TIF?F$", colorspace: sRGB} + - ! {name: TIFF, regex: ".*\\.TIF?F", colorspace: sRGB} - ! {name: ColorSpaceNamePathSearch} - ! {name: Default, colorspace: default} @@ -42,36 +44,41 @@ other keys depend on the rule type. This is the basic rule type that uses Unix glob style pattern matching and is thus very easy to use. It contains the keys: -* ``name``: Name of the rule +* ``name``: Name of the rule. * ``pattern``: Glob pattern to be used for the main part of the name/path. - This is case-sensitive. + This is case-sensitive. It must be in double-quotes. Set it to "*" if you only + want the rule to consider the extension. * ``extension``: Glob pattern or string to be used for the file extension. Note that if glob tokens are not used, the extension will be used in a non-case-sensitive way by default. For example the simple string "exr" would match "exr" and "EXR". - If you only want to match "exr", use the glob pattern "[e][x][r]". + If you only want to match "exr", use the glob pattern "[e][x][r]". It must be + in double-quotes. Set it to "*" if you only want the rule to consider the pattern. * ``colorspace``: ColorSpace name to be returned. -2. Regex Rules -- +2. RegEx Rules -- This is similar to the basic rule but allows additional capabilities for power-users. It contains the keys: -* ``name``: Name of the rule -* ``regex``: Regular expression to be evaluated. +* ``name``: Name of the rule. +* ``regex``: Regular expression to be evaluated. It must be in double-quotes. * ``colorspace``: ColorSpace name to be returned. +Note that a backslash character in a RegEx expression needs to be doubled up as ``\\`` +(as shown in the example above for the TIFF rule) to make it through the Yaml parsing. + 3. OCIO v1 style Rule -- This rule allows the use of the OCIO v1 style, where the string is searched for ColorSpace names from the config. This rule may occur 0 or 1 times in the list. The position in the list prioritizes it with respect to the other rules. It has the key: -* ``name``: Must be "ColorSpaceNamePathSearch". +* ``name``: Must be ``ColorSpaceNamePathSearch``. 4. Default Rule -- -The file_rules must always end with this rule. If no prior rules match, this +The file_rules section must always end with this rule. If no prior rules match, this rule specifies the ColorSpace applications will use. It has the keys: -* ``name``: must be "Default". +* ``name``: must be ``Default``. * ``colorspace``: ColorSpace name to be returned. Note: OCIO v1 defined a ``default`` role intended to specify a default color space @@ -84,19 +91,24 @@ missing, an exception will be thrown when loading the config. Note that the strictparsing token does not affect the behavior of the File Rules API. In other words, evaluating the rules will always result in a ColorSpace being -available to an application. However, the API alsos allow the application to know +available to an application. However, the API also allows the application to know which rule was the matching one. So apps that want to work in "strict" mode should first check if strictparsing is true and if so check to see if the matching rule was the Default Rule. If so, it could then notify the user and take whatever action -is appropriate. +is appropriate. (As an alternative to checking which rule number was matched, the +API call ``filepathOnlyMatchesDefaultRule`` may be used instead.) Roles may be used rather than ColorSpace names in the rules. -It is also legal for rules to have additional key:value pairs where the value +It is also legal for rules to have additional key:value pairs where the value may be an arbitrary string. The API provides access to getting/setting these additional pairs and will preserve them on a Config read/write. These may be used to define application-specific behavior. +Note to developers: The older ``parseColorSpaceFromString`` API call is now deprecated +and should be replaced with ``getColorSpaceFromFilepath``. + + ``strictparsing`` ^^^^^^^^^^^^^^^^^ @@ -107,12 +119,21 @@ Optional. Valid values are ``true`` and ``false``. Default is ``true`` strictparsing: true -OCIO provides a mechanism for applications to extract the colorspace -from a filename (the ``parseColorSpaceFromString`` API method) +.. warning:: + This attribute is from OCIO v1. In OCIO v2, the FileRules system was + introduced and so the ``strictparsing`` attribute is less relevant now. + The ``parseColorSpaceFromString`` API call is now deprecated and the + proper way to obtain this information is ``getColorSpaceFromFilepath``. + The FileRules always return a default color space but the API + ``filepathOnlyMatchesDefaultRule`` may be used by applications that + want to take some special action if ``strictparsing`` is true. + +OCIO v1 provided a mechanism for applications to extract the colorspace +from a filename (the ``parseColorSpaceFromString`` API method). So for a file like ``example_render_v001_lnf.0001.exr`` it will determine the colorspace ``lnf`` (it being the right-most substring -containing a colorspace name) +containing a colorspace name). However, if the colorspace cannot be determined and ``strictparsing: true``, it will return an empty string. diff --git a/docs/guides/authoring/transforms.rst b/docs/guides/authoring/transforms.rst index 51dbbe904a..8a5a36db83 100644 --- a/docs/guides/authoring/transforms.rst +++ b/docs/guides/authoring/transforms.rst @@ -344,6 +344,7 @@ Keys: must also be present and the result is clamped at the high end. +.. _config-named-transforms: Named Transforms **************** diff --git a/docs/guides/contributing/documentation_guidelines.rst b/docs/guides/contributing/documentation_guidelines.rst index 6749cdc3bd..2cb6758b16 100644 --- a/docs/guides/contributing/documentation_guidelines.rst +++ b/docs/guides/contributing/documentation_guidelines.rst @@ -14,18 +14,39 @@ The documentation primarily lives in the ``docs/`` folder, within the main OpenColorIO repository. The rST source for the C++ API documentation is extracted from -comments in the public header files in ``export/`` +comments in the public header files in ``include/`` -The Python API documentation is extracted from dummy .py files within -the ``src/pyglue/DocStrings/`` folder +Installation of requirements +**************************** + +Scripts are available, for each platform, to install the documentation +requirements. + +The ``install_docs_env.sh`` script in the share/ci/scripts/ directory +will install the Python-related requirements for building the documentation +(Sphinx, six, testresources, recommonmark, sphinx-press-theme, sphinx-tabs, +and breathe) and Doxygen. + +Use GitBash (`provided with Git for Windows `_) to +execute the script on Windows. + +Python 3 is required to build the documentation. If you have multiple Python +installs you'll need to make sure pip and CMake find the correct version. You +can manually inform CMake of which to use by adding this option to the below +`cmake` command, which configures the documentation build: + + -DPython_ROOT= + +For the Python packages, ensure their locations are in your ``PYTHONPATH`` +environment variable prior to configuring the build. Building the docs ***************** -Just like a :ref:`regular build from source `, -but specify the ``-D OCIO_BUILD_DOCS=yes`` argument to CMake. +The build is just like a :ref:`regular build from source `, +but specify the ``-D OCIO_BUILD_DOCS=ON`` argument to CMake. -Then run the ``make doc`` target. The default HTML output will be +Then run the ``make docs`` target. The default HTML output will be created in ``build_dir/docs/build-html/`` Note that CMake must be run before each invocation of ``make`` to copy @@ -37,7 +58,50 @@ Initial run:: Then after each change you wish to preview:: - $ cmake -D OCIO_BUILD_DOCS=yes .. && make doc + $ cmake -D OCIO_BUILD_DOCS=ON .. && make docs + +Updating the Python docs +************************ + +If a contributor makes changes to any part of OCIO which affects the Python API docs +(so, public headers, Python bindings, any documentation process code, etc.) they should +do a local build with the new CMake option -DOCIO_BUILD_FROZEN_DOCS=ON, and add the +modified rST files under docs/api/python/frozen to their PR. + +Note: If you run the scripts on Linux, the freezing process should work well. On other +platforms, the process may sometimes make spurious deltas to rST files unrelated to your +changes. Please don't add these files to your PR. + +The OCIO conf.py module has a switch that detects when docs are being built on GH Actions +(CI env var == true) it will backup the frozen folder to a sibling backup folder on Sphinx +init, and following Sphinx build completion will do a file-by-file comparison of the new +frozen and the backup folders. If there are differences, the CI job may fail with an error +explaining where the differences were found and with instructions on how to fix them. + +The conf.py also has a switch that detects when it is being run on RTD, and in that case +will itself run Doxygen to generate the XML needed by breathe prior to building the docs, +and will also facilitate a CMake configure_file-like process (via Python) to handle +substitutions in headers and docs source files that CMake would usually handle, but can't +in this case. One potential plus to all of this is that if someone wants to just build +OCIO docs, they can technically do so by running sphinx-build in the docs directory, and +nothing more. Right now that only works when the READTHEDOCS env var == True, but it could +be easily exposed another way if needed. + +These features required several custom Sphinx extensions tuned for our project which are +located under share/docs. + +Building the docs -- Excluding the API docs +******************************************* + +If you don't need to build the API documentation, there is a quick and dirty way to +do a docs build. This approach does not need to compile the C++ code but is not ideal +since it modifies files in the source directory rather than the build directory: + + export READTHEDOCS=True + cd docs (in the source directory) + mkdir _build + sphinx-build -b html . _build + _build/index.html Basics ****** @@ -79,6 +143,30 @@ Basics In order to bake a LUT, ... +Quirks +****** + +The vuepress theme that we've migrated to has some quirks to its design. For +example, it only allows two nested table of contents (TOC). So things have to be +organized in a slightly different way than other sphinx projects. + +The root-level `toc_redirect.rst` points to where to find the different section +TOCs. The name and contents of each sections TOC is defined in that +sub-directory's `_index.rst` file. + +In this TOC the `:caption:` directive determines what the name of the section +will be in the sidebar, and in the header of the website. The *H1* header +determines the name of the page in the right/left arrows navigation bar. In a +lot of cases this ends up doubling up the name on the page, but this seems +unavoidable at the present time. If additional explanatory text is put in the +`_index.rst` files then it shouldn't be as problematic. + +The site will show all *H1* headers in the side panel by default, these then +expand when selected to show all *H2* headers. + +Due to the limited TOC and sidebar depth, we shouldn't be afraid of looong +pages with many *H2* headings to break down the page into logical quadrants. + Emacs rST mode ************** diff --git a/docs/guides/contributing/repository_structure.rst b/docs/guides/contributing/repository_structure.rst index 372dafe7ed..fb04e99543 100644 --- a/docs/guides/contributing/repository_structure.rst +++ b/docs/guides/contributing/repository_structure.rst @@ -45,32 +45,32 @@ continuous integration (CI) workflows for all supported platforms. Each .yml file defines one GHA workflow, which can contain one or more jobs and the repository events that trigger the workflow. +ASWF +**** + +This subdirectory contains important ASWF governance documents like the +OpenColorIO charter, CLAs and DCO reference. + +The ``meetings`` subdirectory contains historical meeting minutes for +TSC (Technical Steering Committee) and working group meetings. More +recent TSC and working group meeting notes are stored on the +`ASWF Wiki. `_ + docs **** This directory contains the OpenColorIO documentation source and build configuration. -The ``guides/contributing/tsc`` subdirectory contains meeting minutes for all -recorded TSC (Technical Steering Committee) and working group meetings. The -``guides/contributing/aswf`` subdirectory contains important ASWF governance -documents like the OpenColorIO charter, CLAs and DCO reference. - See :ref:`documentation-guidelines` for information on contributing to OCIO documentation. ext *** -This directory serves two purposes: - -1. House modified external dependencies which are permissible to store within - the OpenColorIO repository. Permissible dependencies have compatible FOSS - licenses which have documented approval by the ASWF governing board. - -2. Location for external dependencies temporarily installed and statically - linked by OpenColorIO when using the CMake ``OCIO_INSTALL_EXT_PACKAGES`` - option with the value ``MISSING`` or ``ALL``. +Houses modified external dependencies which are permissible to store within +the OpenColorIO repository. Permissible dependencies have compatible FOSS +licenses which have documented approval by the ASWF governing board. include ******* diff --git a/docs/guides/contributing/submitting_changes.rst b/docs/guides/contributing/submitting_changes.rst index 261b2409cf..a818742f1b 100644 --- a/docs/guides/contributing/submitting_changes.rst +++ b/docs/guides/contributing/submitting_changes.rst @@ -13,8 +13,8 @@ Code Review Ask early, and ask often! All new contributors are highly encouraged to post development ideas, questions, -or any other thoughts to the :ref:`mailing_lists` before starting to code. This -greatly improves the process and quality of the resulting library. Code +or any other thoughts to :ref:`slack` or the :ref:`mailing_lists` before starting to +code. This greatly improves the process and quality of the resulting library. Code reviews (particularly for non-trivial changes) are typically far simpler if the reviewers are aware of a development task beforehand. (And, who knows? Maybe they will have implementation suggestions as well!) @@ -73,6 +73,12 @@ assistance. git add . git commit -s -m 'Implement my feature' +* If your PR changes anything that appears in the public API documentation, + you should follow the directions below in "Updating the Python docs". + If this proves problematic for you, please reach out for help on Slack. + One of the other developers will probably be able to make the updates + for you in another PR. + * Push your changes back to origin (your fork):: git push -u origin myFeature diff --git a/docs/guides/using_ocio/tool_overview.rst b/docs/guides/using_ocio/tool_overview.rst index 87ad7d3974..6e5be4c81e 100644 --- a/docs/guides/using_ocio/tool_overview.rst +++ b/docs/guides/using_ocio/tool_overview.rst @@ -24,6 +24,26 @@ Note that some tools depend on OpenEXR or OpenImageIO and other libraries: .. TODO: check app lib dependencies .. TODO: make a pretty table in RST. +.. _overview-ocioarchive: + +ocioarchive +*********** + +This command-line tool allows you to convert a config and its external LUT files +into an OCIOZ archive file. A .ocioz file may be supplied to any command that +takes the path to a config or set as the OCIO environment variable. + +This example creates a file called myarchive.ocioz:: + + $ ocioarchive myarchive --iconfig myconfig/config.ocio + +This command will expand it back out:: + + $ ocioarchive --extract myarchive.ocioz + +The --list option may be used to see the contents of a .ocioz file. + + .. _overview-ociocheck: ociocheck @@ -33,7 +53,7 @@ This is a command-line tool which shows an overview of an OCIO config file, and checks for obvious errors. For example, the following shows the output of a config with a typo - -the colorspace used for ``compositing_log`` is not incorrect:: +the colorspace used for ``compositing_log`` is incorrect:: $ ociocheck --iconfig example.ocio @@ -189,6 +209,17 @@ not the case. Also, it does not leverage any of the new OCIO v2 features. .. TODO: Link to discussion of OpenImageIO source? +.. _overview-pyociodisplay: + +pyociodisplay +************* + +The pyociodisplay tool is a minimal image viewer implementation demonstrating use of +the OCIO GPU renderer in a Python application. It requires downloading a few dependencies +before use. For more information, please see the +`README. `_ + + .. _overview-ociolutimage: ociolutimage @@ -240,6 +271,7 @@ ACES2065-1:: The --list argument will print out all of the standard ACES color spaces that are supported as --csc arguments. + .. _overview-ocioperf: ocioperf @@ -272,6 +304,7 @@ Examples:: .. TODO: examples formatting + .. _overview-ociowrite: ociowrite @@ -298,3 +331,16 @@ Here is an example:: $ export OCIO=/path/to/the/config.ocio $ ociowrite --colorspaces acescct aces2065-1 --file mytransform.ctf + + +.. _overview-pyocioamf: + +pyocioamf +********* + +The pyocioamf tool is an initial attempt to support the ACES Metadata File (AMF) +`format. `_ +This Python script will take an AMF file and produce an OCIO CTF file that implements its color +pipeline. The CTF file may be applied to images using tools such as :ref:`overview-ocioconvert`. +For more information, please see the +`README. `_ diff --git a/docs/index.rst b/docs/index.rst index e620b9f37b..1241802ea1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -20,31 +20,30 @@ OCIO v1 represented the culmination of years of production experience earned on films as SpiderMan 2 (2004), Surf's Up (2007), Cloudy with a Chance of Meatballs (2009), Alice in Wonderland (2010), and many more. -OpenColorIO v2 has been in development since 2017 and was feature complete as of +OpenColorIO v2 was in development from 2017 to 2020 and was feature complete as of SIGGRAPH 2020. After a stabilization and bug-fixing period, an official 2.0.0 -release was made in January 2021. OCIO v2 is in the VFX Reference Platform for -calendar year 2021. The OCIO v2 code is in the RB-2.0 branch on -`GitHub `_ -and we encourage developers to start integrating and providing feedback. -See :ref:`upgrading_to_v2` for more. +release was made in January 2021. Development has continued to be active since +then with the 2.1 release in 2021 and the 2.2 release in 2022 adding even more +capabilities. Here is more information about our :ref:`upgrading_to_v2`. About the Documentation ======================= +The documentation has been updated to include basic coverage of the new OCIO v2 features +but additional work is needed to provide more detail and tutorials about how to +best leverage them. We have an OCIO User Experience (UX) working group that is +gradually working on more coverage. + The documentation is a work-in-progress and we would love to have your help to -improve it! An easy way to get involved is to join the #docs channel on +improve it! An easy way to get involved is to join the #docs or #ux channel on :ref:`slack`. -The documentation has been updated to include most of the new OCIO v2 features -but additional work is needed to provide more detail and tutorials about how to -best leverage them. We will be working on that over the coming weeks. - Accessing Other Versions ************************ -You are reading the documentation for OCIO v2. The documentation for the the previous -stable release (1.1.1) is available `here `_. +You are reading the documentation for OCIO v2. The documentation for the earlier +1.x series of releases is available `here `_. Community diff --git a/docs/quick_start/downloads.rst b/docs/quick_start/downloads.rst index a2b71cf601..d39f449c57 100644 --- a/docs/quick_start/downloads.rst +++ b/docs/quick_start/downloads.rst @@ -7,44 +7,13 @@ Downloads ========= -* Sample OCIO Configurations -- `.zip `__ `.tar.gz `__ +* `OCIO v2 ACES Configurations `_ +* OCIO v1 Legacy Configurations -- `.zip `__ `.tar.gz `__ * Reference Images v1.0v4 -- `.tgz `__ -* Core Library v2.0.0 -- `.zip `__ `.tar.gz `__ -* Core Library dev -- `.zip `__ `.tar.gz `__ - -Per-version updates: :ref:`changelog-main`. - -Build instructions: :ref:`building-from-source`. +* `OCIO Library source code `_ .. _contributor-license-agreements: Contributor License Agreements ****************************** -Please see the `OCIO GitHub repository `__ - -Deprecated Downloads -******************** -* Reference Images v1.0v3 `tgz `__ -* Reference Images v1.0v2 `tgz `__ -* Reference Images v1.0v1 `tgz `__ - -* Core Library v1.1.1 -- `.zip `__ `.tar.gz `__ -* Core Library v1.1.0 -- `.zip `__ `.tar.gz `__ -* Core Library v1.0.9 -- `.zip `__ `.tar.gz `__ -* Core Library v1.0.8 -- `.zip `__ `.tar.gz `__ -* Core Library v1.0.7 -- `.zip `__ `.tar.gz `__ -* Core Library v1.0.6 -- `.zip `__ `.tar.gz `__ -* Core Library v1.0.5 -- `.zip `__ `.tar.gz `__ -* Core Library v1.0.4 -- `.zip `__ `.tar.gz `__ -* Core Library v1.0.3 -- `.zip `__ `.tar.gz `__ -* Core Library v1.0.2 -- `.zip `__ `.tar.gz `__ -* Core Library v1.0.1 -- `.zip `__ `.tar.gz `__ -* Core Library v1.0.0 -- `.zip `__ `.tar.gz `__ - -* Color Config v0.7v4 `tgz `__ (OCIO v0.7.6+) -* Core Library v0.8.7 -- `.zip `__ `.tar.gz `__ -* Core Library v0.7.9 -- `.zip `__ `.tar.gz `__ -* Core Library v0.6.1 -- `.zip `__ `.tar.gz `__ -* Core Library v0.5.16 -- `.zip `__ `.tar.gz `__ -* Core Library v0.5.8 -- `.zip `__ `.tar.gz `__ - +Please see the `OCIO GitHub repository `__ diff --git a/docs/quick_start/for_artists.rst b/docs/quick_start/for_artists.rst index 7716e4eb63..d3ee1613aa 100644 --- a/docs/quick_start/for_artists.rst +++ b/docs/quick_start/for_artists.rst @@ -14,7 +14,12 @@ each application. Note that OCIO configurations are required to do any 'real' work, and are available separately on the :ref:`downloads` section of this site. Example images are also available. For assistance customizing .ocio configurations, -contact `ocio-user `__\. +contact `ocio-user `_ or the #configs +channel on :ref:`slack` + +If your application supports OCIO 2.2 or later, you may take advantage of the +configurations built into OCIO itself. For example, by setting the config path to: +``ocio://default``. - Step 1: set the ``$OCIO`` environment-variable to ``/path/to/your/config.ocio`` - Step 2: Launch supported application. @@ -23,6 +28,6 @@ If you are on a platform that is not envvar friendly, most applications also provide a menu option to select a different OCIO configuration after launch. Please be sure to select a configuration that matches your color workflow (VFX -work typically requires a different profile than animated features). If you need +work sometimes requires a different profile than animated features). If you need assistance picking a profile, email `ocio-user `__\. diff --git a/docs/quick_start/for_config_authors.rst b/docs/quick_start/for_config_authors.rst index 87348ac2bb..45fa3cc722 100644 --- a/docs/quick_start/for_config_authors.rst +++ b/docs/quick_start/for_config_authors.rst @@ -7,11 +7,10 @@ Quick Start for Config Authors ============================== -Get started by following the :ref:`installation` instructions. Note that if -you want to try out the new OpenColorIO v2 features, you'll need to build -from source. You will want to make sure to build the command-line tools as -well as the library itself, so you should install OpenImageIO or OpenEXR before -building (OCIO is now able to build the latter itself). +As a config author, you'll want access to the OCIO command-line tools such as +``ociocheck``. Please see the :ref:`installation` instructions for the various +options, for example Homebrew on macOS and Vcpkg on Windows. On Linux you may +need to build from source. Grab the available configuration files (and the sample images, if you want) from :ref:`downloads` so you'll have some examples to study. diff --git a/docs/quick_start/for_contributors.rst b/docs/quick_start/for_contributors.rst index d123150228..3b33442d1c 100644 --- a/docs/quick_start/for_contributors.rst +++ b/docs/quick_start/for_contributors.rst @@ -15,9 +15,10 @@ testing, example configs, and documentation as well as actual coding. issues with the ``good first issue`` label. * If you want to help develop config files, start by looking at :ref:`quick_start_config_authors` - and join the #configs channel on :ref:`slack`. + and join the #configs channel on :ref:`slack`. From there, you may want to join the + OCIO Configs working group. -* If you want to help with documentation, join the #docs channel on :ref:`slack`. +* If you want to help with documentation, join the #docs and #ux channel on :ref:`slack`. * If you want to help test, join the #general channel on :ref:`slack` and let us know you want to help test. diff --git a/docs/quick_start/for_devs.rst b/docs/quick_start/for_devs.rst index fb98472ed2..358a5ac2d5 100644 --- a/docs/quick_start/for_devs.rst +++ b/docs/quick_start/for_devs.rst @@ -8,10 +8,12 @@ Quick Start for Developers ========================== Get started by following the :ref:`installation` instructions to build OCIO from -source. You will want to make sure to build the command-line tools as well as the -library itself, so you should install OpenImageIO or OpenEXR before building -(OCIO is now able to build the latter itself). Note that active development of -OCIO v2 is happening in the main branch. +source. In addition to the library itself, you will want to make sure to build the +command-line tools, including ``ocioconvert``. + +Note that active development of OCIO v2 is happening in the main branch. + +Watch the OCIO SIGGRAPH course listed in :ref:`publications`. Grab the available configuration files (and the sample images, if you want) from :ref:`downloads`. @@ -22,12 +24,16 @@ the :ref:`overview-ocioconvert` tool to process an image from one color space to Try using :ref:`overview-ociodisplay` to view an image through a color space conversion. Take a look at the example code in the :ref:`developers-usageexamples` and then study -the code for the command-line tools, which is under src/apps. +the code for the command-line tools, which is under ``src/apps``. -There are helper classes under src/libutils/apphelpers for common application tasks +There are helper classes under ``src/libutils/apphelpers`` for common application tasks such as generating color space menus, building a viewing pipeline for a viewport, and writing a color picker for scene-linear color spaces. Look through the :ref:`concepts_overview` to get a sense of the big picture. Check out :ref:`upgrading_to_v2` for an overview of the new features in OCIO v2. + +Join the #dev and #ux channel on :ref:`slack`. From the #ux channel, you may want to +get involved with the OCIO User Experience (UX) working group which discusses best +practices for implementing OCIO support in applications. diff --git a/docs/quick_start/installation.rst b/docs/quick_start/installation.rst index d265f5f0e3..600fa89e12 100644 --- a/docs/quick_start/installation.rst +++ b/docs/quick_start/installation.rst @@ -5,30 +5,45 @@ .. _installation: Installation -************ +============ + +Installation may be done either by installing pre-built binaries from various package +managers or by building from source. (The OCIO project currently does not provide +pre-built libraries as downloadable artifacts other than through package managers.) + +Please note that the version available through a given package manager may be significantly +outdated when compared to the current official OCIO release, so please verify the version +you install is current. (Unfortunately, even two years after the introduction of +OpenColorIO v2, several package managers continue to install OCIO 1.1.1.) -Although OpenColorIO is available through a variety of package managers, please note that the -version available through a given package manager may be significantly outdated when compared to -the current official OCIO release. Even two years after the introduction of OpenColorIO v2, several -package managers continue to install OCIO 1.1.1. +Alternatives +************ .. _Python: Python -^^^^^^ +++++++ + +If you only need the Python binding, the simplest solution is to take advantage of the pre-built +wheels in the Python Package Index (PyPI) `here `_. It +can be installed as follows, once you have Python installed. -If you only need the Python bindings, the simplest solution is to take advantage of the pre-built -wheels in the Python Package Installer (PyPi) `here `__. It -can be installed by using this command:: +**PyPI**:: pip install opencolorio +The pre-built wheels are listed `here `_. Note that +source code is provided, so it may be possible for ``pip`` to compile the binding on your machine if +the matrix of Python version and platform version does not have the combination you need. More +detailed instructions are available for how to use +`pip. `_ + OpenImageIO -^^^^^^^^^^^ ++++++++++++ -If you only need to apply color conversions to images, please note that OpenImageIO's oiiotool has -most of the functionality of the ocioconvert command-line tool (although not everything, such as -GPU processing). OpenImageIO is available via several package managers (including brew and vcpkg). +If you only need to apply color conversions to images, please note that OpenImageIO's ``oiiotool`` has +most of the functionality of the ``ocioconvert`` command-line tool (although not everything, such as +GPU processing). OpenImageIO is available via several package managers (including Homebrew and Vcpkg). **Homebrew**:: @@ -38,16 +53,17 @@ GPU processing). OpenImageIO is available via several package managers (includin vcpkg install openimageio[opencolorio,tools]:x64-windows --recurse -Installing OpenColorIO using existing packages -********************************************** + +Installing OpenColorIO using Package Managers +============================================= Linux -^^^^^ +***** -When it comes to Linux distributions, relatively few of the Linux distribution repositories have been -updated to OCIO v2. The **latest Fedora** is one good option as it offers the most -recent release of OpenColorIO v2. Information about the package can be found on -`fedoraproject website `__. +When it comes to Linux distributions, relatively few of the Linux distribution repositories +have been updated to OCIO v2. The **latest Fedora** is one good option as it offers a +recent release of OpenColorIO v2. Information about the package can be found on the +`Fedora project website `__. For the other distributions, information about which release of OpenColorIO is available can be verified on `pkgs.org `__. @@ -55,72 +71,88 @@ verified on `pkgs.org `__. **The recommendation is to build OpenColorIO from source**. You may build from source using the instructions below. See :ref:`building-from-source`. -Windows 7 or newer using vcpkg -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Windows using Vcpkg +******************* -Vcpkg can be used to install OpenColorIO on Windows. In order to do that, Vcpkg must be installed +Vcpkg can be used to install OpenColorIO on Windows 7 or higher. To do that, Vcpkg must be installed by following the `official instructions `__. Once Vcpkg is installed, OpenColorIO and some of the tools can be installed with the following command:: vcpkg install opencolorio[tools]:x64-windows -Note that this package **does not** install ocioconvert, ociodisplay, ociolutimage and the Python -bindings. +Note that this package **does not** install ``ocioconvert``, ``ociodisplay``, ``ociolutimage``, +and the Python binding. -The three missing tools can be built from source by following the steps in the :ref:`Windows 7 or newer` -section while the Python bindings can be install using the pip command in the :ref:`Python` section. +If you need the extra command-line tools, you'll need to install :ref:`from source. ` +However, the Python binding can be installed as described in the :ref:`Python` section. -OS X using Homebrew -^^^^^^^^^^^^^^^^^^^ +MacOS using Homebrew +******************* -You can use the Homebrew package manager to install OpenColorIO on OS X. +You can use the Homebrew package manager to install OpenColorIO on macOS. First install Homebrew as per the instructions on the `Homebrew -homepage `__ (or see the `Homebrew wiki -`__ for more -detailed instructions) +homepage `__ (or see the `Homebrew documentation +`__ for more detailed instructions). Then simply run the following command to install:: brew install opencolorio -Homebrew does not install the Python binding or the command-line tools that depend on OpenImageIO -such as ocioconvert, ociodisplay and ociolutimage. +Homebrew does not install the Python binding or the command-line tools that depend on either +OpenImageIO or OpenEXR such as ``ocioconvert``, ``ociodisplay``, and ``ociolutimage``. .. _building-from-source: -Building from source -******************** +Building from Source +==================== + +The basic requirements to build OCIO from source on Linux, macOS, and Windows are a +supported C++ compiler, CMake, and an internet connection. The OCIO Cmake scripts are +able to download, build, and install all other required components. However, more +advanced users are also able to have the build use their own version of dependencies. Dependencies -^^^^^^^^^^^^ +************ -The basic requirements for building OCIO are the following. Note that, by -default, cmake will try to install all of the items labelled with * and so -it is not necessary to install those items manually: +OCIO depends on the following components. By default, the OCIO CMake scripts will +download and build the items labelled with a \*, so it is not necessary to install those +items manually: -- cmake >= 3.12 +Required components: + +- C++ 11-17 compiler (gcc, clang, msvc) +- CMake >= 3.13 - \*Expat >= 2.4.1 (XML parser for CDL/CLF/CTF) - \*yaml-cpp >= 0.7.0 (YAML parser for Configs) - \*Imath >= 3.0 (for half domain LUTs) - \*pystring >= 1.1.3 +- \*minizip-ng >= 3.0.7 (for config archiving) +- \*ZLIB >= 1.2.13 (for config archiving) -Some optional components also depend on: +Optional OCIO functionality also depends on: - \*Little CMS >= 2.2 (for ociobakelut ICC profile baking) -- \*pybind11 >= 2.9.2 (for the Python bindings) -- Python >= 2.7 (for the Python bindings) -- Python 3.7 or 3.8 (for the docs, with the following PyPi packages) - - Sphinx - - six - - testresources - - recommonmark - - sphinx-press-theme - - sphinx-tabs - - breathe -- NumPy (for complete Python test suite) +- \*OpenGL GLUT & GLEW (for ociodisplay) +- \*OpenEXR >= 3.0 (for apps including ocioconvert) +- OpenImageIO >= 2.1.9 (for apps including ocioconvert) +- \*OpenFX >= 1.4 (for the OpenFX plug-ins) +- OpenShadingLanguage >= 1.11 (for the OSL unit tests) - Doxygen (for the docs) -- OpenImageIO >= 2.1.9 or OpenEXR >= 3.0 (for apps including ocioconvert) +- NumPy (optionally used in the Python test suite) +- \*pybind11 >= 2.9.2 (for the Python binding) +- Python >= 2.7 (for the Python binding only) +- Python 3.7 - 3.9 (for building the documentation) + +Building the documentation requires the following packages, available via PyPI: + +- Sphinx +- six +- testresources +- recommonmark +- sphinx-press-theme +- sphinx-tabs +- breathe Example bash scripts are provided in `share/ci/scripts `_ @@ -132,14 +164,14 @@ available for all supported platforms. Use GitBash this script on Windows. Automated Installation ----------------------- +++++++++++++++++++++++ -Listed dependencies with a preceeding * can be automatically installed at -build time using the ``OCIO_INSTALL_EXT_PACKAGES`` option in your cmake -command (requires an internet connection). This is the default. C/C++ -libraries are pulled from external repositories, built, and statically-linked -into libOpenColorIO. Python packages are installed with ``pip``. All installs -of these components are fully contained within your build directory. +Dependencies listed above with a preceeding * can be automatically installed at +build time using the ``OCIO_INSTALL_EXT_PACKAGES`` option in your ``cmake`` +command (requires an internet connection). The C/C++ libraries are pulled from +external repositories, built, and are (typically) statically-linked into an OCIO +dynamic library. All installs of these components are fully contained within your +build directory. Three ``OCIO_INSTALL_EXT_PACKAGES`` options are available:: @@ -153,37 +185,130 @@ Three ``OCIO_INSTALL_EXT_PACKAGES`` options are available:: current system. Existing Install Hints ----------------------- - -When using existing system libraries, the following CMake variables can be -defined to hint at non-standard install locations and preference of shared -or static linking: - -- ``-Dexpat_ROOT=`` (include and/or library root dir) -- ``-Dexpat_STATIC_LIBRARY=ON`` (prefer static lib) -- ``-Dyaml-cpp_ROOT=`` (include and/or library root dir) -- ``-Dyaml-cpp_STATIC_LIBRARY=ON`` (prefer static lib) -- ``-DImath_ROOT=`` (include and/or library root dir) -- ``-DImath_STATIC_LIBRARY=ON`` (prefer static lib) -- ``-DHalf_ROOT=`` (include and/or library root dir) -- ``-DHalf_STATIC_LIBRARY=ON`` (prefer static lib) -- ``-Dpystring_ROOT=`` (include and/or library root dir) -- ``-Dpystring_STATIC_LIBRARY=ON`` (prefer static lib) -- ``-Dlcms2_ROOT=`` (include and/or library root dir) -- ``-Dlcms2_STATIC_LIBRARY=ON`` (prefer static lib) -- ``-Dpybind11_ROOT=`` (include and/or library root dir) -- ``-DPython_EXECUTABLE=`` (Python executable) - -To hint at Python package locations, add paths to the ``PYTHONPATH`` -environment variable prior to configuring the build. +++++++++++++++++++++++ + +When using libraries already on your system, the CMake variable +``-D _ROOT=`` may be used to specify the path to the include and +library root directory rather than have CMake try to find it. The package names used +by OCIO are as follows (note that these are case-sensitive): + +Required: + +- ``expat`` +- ``yaml-cpp`` +- ``Imath`` +- ``pystring`` +- ``ZLIB`` +- ``minizip-ng`` + +Optional: + +- ``OpenEXR`` +- ``OpenImageIO`` +- ``lcms2`` +- ``pybind11`` +- ``openfx`` +- ``OSL`` +- ``Sphinx`` +- ``GLEW`` +- ``GLUT`` +- ``Python`` + +There are scenarios in which some of the dependencies may not be compiled into an +OCIO dynamic library. This is more likely when OCIO does not download the packages +itself. In these cases, it may be helpful to additionally specify the CMake variable +``-D _STATIC_LIBRARY=ON``. The following package names support this hint: +``expat``, ``yaml-cpp``, ``Imath``, ``lcms2``, ``ZLIB``, and ``minizip-ng``. + +Rather than using ``_ROOT``, and possibly ``_STATIC_LIBRARY``, you may instead use +``-D _LIBRARY=`` and ``-D _INCLUDE_DIR=``. +In this case, the library path will control whether a static or dynamic library is used. +It may also be used to handle situations where the library and/or include files are not +in the typical location relative to the root directory. + +The OCIO `CMake find modules `_ +may be consulted for more detail on the handling of a given package and the CMake +variables it uses. + +Please note that if you provide your own ``minizip-ng``, rather than having OCIO's CMake +download and build it, you will likely need to set its CMake variables the same way +that OCIO does (e.g., enable ZLib and turn off most other options). Using a ``minizip-ng`` +from various package managers (e.g., Homebrew) probably won't work. Please see the +settings that begin with ``-DMZ_`` that are used in the OCIO +`minizip-ng find module. `_ + +Please note that if you build a static OCIO library, it will not contain the libraries +for the external packages and so you will need to list those separately when linking your +client application. If you had OCIO download and build these packages, you will +find them under your build directory in ``ext/dist/lib``. The libraries that are +needed are: ``expat``, ``yaml-cpp``, ``Imath``, ``pystring``, ``ZLIB``, and ``minizip-ng``. + +The OCIO ``make install`` step will install CMake configuration files that may be used +by applications that consume OCIO to find and utilize OCIO during their own build process. + +For the Python packages required for the documentation, ensure that their locations +are in your ``PYTHONPATH`` environment variable prior to configuring the build. + +This custom variable is also available: + +- ``-DPython_EXECUTABLE=`` (Python executable for pybind11) + + +.. _enabling-optional-components: + +Enabling optional components +**************************** + +CMake Options ++++++++++++++ + +There are many options available in `CMake. +`_ + +Several of the most common ones are: + +- ``-DCMAKE_BUILD_TYPE=Release`` (Set to Debug, if necessary) +- ``-DBUILD_SHARED_LIBS=ON`` (Set to OFF to build OCIO as a static library) + +Here are the most common OCIO-specific CMake options (the default values are shown): + +- ``-DOCIO_BUILD_APPS=ON`` (Set to OFF to not build command-line tools) +- ``-DOCIO_USE_OIIO_FOR_APPS=OFF`` (Set ON to build tools with OpenImageIO rather than OpenEXR) +- ``-DOCIO_BUILD_PYTHON=ON`` (Set to OFF to not build the Python binding) +- ``-DOCIO_BUILD_OPENFX=OFF`` (Set to ON to build the OpenFX plug-ins) +- ``-DOCIO_USE_SSE=ON`` (Set to OFF to turn off SSE CPU performance optimizations) +- ``-DOCIO_BUILD_TESTS=ON`` (Set to OFF to not build the unit tests) +- ``-DOCIO_BUILD_GPU_TESTS=ON`` (Set to OFF to not build the GPU unit tests) +- ``-DOCIO_USE_HEADLESS=OFF`` (Set to ON to do headless GPU reendering) +- ``-DOCIO_WARNING_AS_ERROR=ON`` (Set to OFF to turn off warnings as errors) +- ``-DOCIO_BUILD_DOCS=OFF`` (Set to ON to build the documentation) +- ``-DOCIO_BUILD_FROZEN_DOCS=OFF`` (Set to ON to update the Python documentation) + +Several command-line tools (such as ``ocioconvert``) require reading or writing image files. +If ``OCIO_USE_OIIO_FOR_APPS=OFF``, these will be built using OpenEXR rather than OpenImageIO +and therefore you will be limited to using OpenEXR files with these tools rather than the +wider range of image file formats supported by OIIO. (Using OpenEXR for these tools works +around the issue of a circular dependency between OCIO and OIIO that can complicate some +build chains.) + +The CMake output prints information regarding which image library will be used for the +command-line tools (as well as a lot of other info about the build configuration). + + +Documentation ++++++++++++++ + +Instructions for installing the documentation pre-requisites and building the docs +are in the section on :ref:`contributing documentation. ` + .. _osx-and-linux: -OS X and Linux -^^^^^^^^^^^^^^ +MacOS and Linux +*************** While there is a huge range of possible setups, the following steps -should work on OS X and most Linux distros. To keep things simple, this guide +should work on macOS and most Linux distros. To keep things simple, this guide will use the following example paths - these will almost definitely be different for you: @@ -196,12 +321,12 @@ First make the build directory and cd to it:: $ mkdir /tmp/ociobuild $ cd /tmp/ociobuild -Next step is to run cmake, which looks for things such as the +Next step is to run ``cmake``, which looks for things such as the compiler's required arguments, optional requirements like Python, OpenImageIO etc For this example we will show how to install OCIO to a custom location -(instead of the default ``/usr/local``), we will thus run cmake with +(instead of the default ``/usr/local``), we will thus run ``cmake`` with ``CMAKE_INSTALL_PREFIX``. Still in ``/tmp/ociobuild``, run:: @@ -209,8 +334,8 @@ Still in ``/tmp/ociobuild``, run:: $ cmake -DCMAKE_INSTALL_PREFIX=/software/ocio /source/ocio The last argument is the location of the OCIO source code (containing -the main CMakeLists.txt file). You should see something along the -lines of:: +the main CMakeLists.txt file). You should see it conclude with something +along the lines of:: -- Configuring done -- Generating done @@ -231,25 +356,33 @@ the specified location:: $ make install If nothing went wrong, ``/software/ocio`` should look something like -this:: +this (on Linux or macOS):: $ cd /software/ocio $ ls - bin/ include/ lib/ + bin/ include/ lib/ share/ $ ls bin/ ociobakelut ociocheck (and others ...) $ ls include/ - OpenColorIO/ PyOpenColorIO/ pkgconfig/ + OpenColorIO/ $ ls lib/ - libOpenColorIO.a libOpenColorIO.dylib + cmake/ libOpenColorIO.dylib (and some more specific versions ...) + libOpenColorIOimageioapphelpers.a libOpenColorIOoglapphelpers.a + pkgconfig/ python/ + $ ls lib/pkgconfig + OpenColorIO.pc + $ ls lib/python/site-packages + PyOpenColorIO.so + $ ls share/ocio + setup_ocio.sh -.. _Windows 7 or newer: +.. _Windows: -Windows 7 or newer -^^^^^^^^^^^^^^^^^^ +Windows +******* While build environments may vary between users, the recommended way to build OCIO from source on -Windows is to use the scripts provided in the Windows +Windows 7 or newer is to use the scripts provided in the Windows `share `_ section of the OCIO repository. There are two scripts currently available. @@ -270,7 +403,7 @@ Run this command to execute the ocio_deps.bat script:: The second script is called `ocio.bat `_ and it provide a way to configure and build OCIO from source. Moreover, this script executes the -install step of cmake as well as the unit tests. The main use case is the following:: +install step of ``cmake`` as well as the unit tests. The main use case is the following:: ocio.bat --b --i --vcpkg --ocio --type Release @@ -282,39 +415,14 @@ For more information, please look at each script's documentation:: ocio_deps.bat --help -.. _enabling-optional-components: - -Enabling optional components -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The OpenColorIO library is probably not all you want - the Python -libraries bindings, the Nuke nodes and several applications are only -built if their dependencies are found. - -In the case of the Python bindings, the dependencies are the Python -headers for the version you wish to use. These may be picked up by -default - if so, when you run cmake you would see:: - - -- Python 2.6 okay, will build the Python bindings against .../include/python2.6 - -If not, you can point cmake to correct Python executable using the -``-D PYTHON=...`` cmake flag:: - - $ cmake -D PYTHON=/my/custom/python2.6 /source/ocio - -The applications included with OCIO have various dependencies - to -determine these, look at the CMake output when first run:: - - -- Not building ocioconvert. Requirement(s) found: OIIO:FALSE - - .. _quick-env-config: Quick environment configuration -******************************* +=============================== The quickest way to set the required :ref:`environment-setup` is to source the ``share/ocio/setup_ocio.sh`` script installed with OCIO. +On Windows, use the corresponding setup_ocio.bat file. For a simple single-user setup, add the following to ``~/.bashrc`` (assuming you are using bash, and the example install directory of @@ -336,7 +444,7 @@ configuration script etc), for example:: .. _environment-setup: Environment variables -********************* +===================== Note: For other user facing environment variables, see :ref:`using_env_vars`. @@ -345,7 +453,7 @@ Note: For other user facing environment variables, see :ref:`using_env_vars`. This variable needs to point to the global OCIO config file, e.g ``config.ocio`` -.. envvar:: DYLD_LIBRARY_PATH +.. envvar:: DYLD_LIBRARY_PATH (macOS) The ``lib/`` folder (containing ``libOpenColorIO.dylib``) must be on the ``DYLD_LIBRARY_PATH`` search path, or you will get an error @@ -356,11 +464,11 @@ Note: For other user facing environment variables, see :ref:`using_env_vars`. Reason: image not found This applies to anything that links against OCIO, including the - ``PyOpenColorIO`` Python bindings. + ``PyOpenColorIO`` Python binding. -.. envvar:: LD_LIBRARY_PATH +.. envvar:: LD_LIBRARY_PATH (Linux) - Equivalent to the ``DYLD_LIBRARY_PATH`` on Linux + The Linux equivalent of the macOS ``DYLD_LIBRARY_PATH``. .. envvar:: PYTHONPATH diff --git a/docs/upgrading_v2/_index.rst b/docs/releases/_index.rst similarity index 74% rename from docs/upgrading_v2/_index.rst rename to docs/releases/_index.rst index cc45f6ef7a..9d61474e7f 100644 --- a/docs/upgrading_v2/_index.rst +++ b/docs/releases/_index.rst @@ -4,10 +4,12 @@ .. _upgrading_to_v2: -Upgrading to v2 -=============== +Releases +======== .. toctree:: :caption: Upgrading to v2 - how_to \ No newline at end of file + ocio_2_2 + ocio_2_1 + ocio_2_0 diff --git a/docs/upgrading_v2/how_to.rst b/docs/releases/ocio_2_0.rst similarity index 97% rename from docs/upgrading_v2/how_to.rst rename to docs/releases/ocio_2_0.rst index 0a2ba7f6a0..2892605d03 100644 --- a/docs/upgrading_v2/how_to.rst +++ b/docs/releases/ocio_2_0.rst @@ -3,15 +3,15 @@ Copyright Contributors to the OpenColorIO Project. -Introduction -============ +OCIO 2.0 Release +================ OpenColorIO v2 is a major update, three years in development, and contains a large number of new features. This section describes the new features and their relevance for both config authors and application developers. Timeline -======== +******** OpenColorIO v2 was proposed to the community at SIGGRAPH 2017 and reached "feature complete" at SIGGRAPH 2020. The official 2.0.0 release was made in @@ -19,7 +19,7 @@ January 2021 after a period of stabilization and refinement. OCIO v2 is in the VFX Reference Platform for calendar year 2021. Demo Config -=========== +*********** There is a config file that illustrates many of the new OCIO v2 features described below. This is available in the configs section of the documentation as :ref:`ocio-v2_demo`. @@ -641,3 +641,19 @@ processed. **Developers**: This may be useful, for example, when displaying data color spaces on an HDR monitor. + + +Release Notes +============= + +For more detail, please see the GitHub release pages: + +`OCIO 2.0.0 `_ + +`OCIO 2.0.1 `_ + +`OCIO 2.0.2 `_ + +`OCIO 2.0.3 `_ + +`OCIO 2.0.4 `_ diff --git a/docs/releases/ocio_2_1.rst b/docs/releases/ocio_2_1.rst new file mode 100644 index 0000000000..5fcf6b4924 --- /dev/null +++ b/docs/releases/ocio_2_1.rst @@ -0,0 +1,173 @@ +.. + SPDX-License-Identifier: CC-BY-4.0 + Copyright Contributors to the OpenColorIO Project. + + +OCIO 2.1 Release +================ + +Timeline +******** + +OpenColorIO 2.1 was delivered in August 2021 and is in the VFX Reference Platform for +calendar year 2022. + +New Features +============ + +ACES 1.3 Gamut Compression +************************** + +ACES 1.3 introduced a scene-referred gamut compression algorithm that compresses +colors captured by a camera into the AP1 gamut. This avoids artifacts that may +occur downstream (such as in the ACES Output Transforms) for scene elements such +as colored lights. This supersedes the earlier "Blue Light Artifact Fix" LMT. + +`ACES RGC User Guide +`_ + +`ACES RGC Implementation Guide +`_ + +The implementation includes a BuiltinTransform for the ACES Reference Gamut Compression. +Here's what that looks like in Config YAML:: + + ! {style: ACES-LMT - ACES 1.3 Reference Gamut Compression} + +There is also a FixedFunctionTransform for the underlying gamut compression algorithm. +As described in the links above, it takes seven parameter values:: + + [ Limit_Cyan, Limit_Magenta, Limit_Yellow, Threshold_Cyan, Threshold_Magenta, Threshold_Yellow, Roll-off ]. + +Here is how that looks in Config YAML with the parameters set for the ACES 1.3 Reference Gamut +Compression:: + + ! {style: ACES_GamutComp13, params: [1.147, 1.264, 1.312, 0.815, 0.803, 0.88, 1.2]} + +And here's how it looks in a CTF file:: + + + +**Config authors**: These new transforms may be used in configs with version 2.1 or higher +and CTF files with version 2.1 or higher. + + +OpenFX OCIO plug-ins +******************** + +A framework to support OpenFX plug-ins has been added and example source code may be found +in the vendor/openfx directory. The initial set consists of two plug-ins, one for applying +a ColorSpaceTransform and another for applying a DisplayViewTransform. + +Some screenshots of the UI may be found in `PR #1371. +`_ + +**End users**: There are currently no pre-built executables available, so you will need to +compile these yourself. + +**Developers**: Set the CMake variable ``-D OCIO_BUILD_OPENFX=ON`` to build the plug-ins. + + +Support for PyPI (pip install) +****************************** + +Python wheel generation has been added and support for the `Python Package Index (PyPI). +`_ +This allows you to easily install the OCIO Python bindings without needing to build from +source or use one of the OS-specific package managers. The command is simply:: + + pip install opencolorio + + +Support for emitting Open Shading Language (OSL) +************************************************ + +The OCIO GPU Renderer may now emit shaders in `Open Shading Language +`_ format. There is a +new GpuLanguage enum: ``LANGUAGE_OSL_1``. + +Note that the OCIO library does not need to be compiled against the OSL library but running +the OSL unit tests does require OSL and OIIO. These will be built automatically if CMake is +able to find them or you set ``-D OSL_ROOT`` to indicate the installed location. + +Currently, Lut1D and Lut3D Transforms are not supported and will throw an exception if used. +All other transforms are supported. However, dynamic properties are currently locked to +their initial values and may not be adjusted. + + +Support for Apple Metal Shading Language and OpenGL ES +****************************************************** + +The OCIO GPU Renderer may now emit shaders in these other new languages. The new +GpuLanguage enums are: + +* ``GPU_LANGUAGE_MSL_2_0`` +* ``GPU_LANGUAGE_GLSL_ES_3_0`` +* ``GPU_LANGUAGE_GLSL_ES_1_0`` + + +Test suite for the Academy/ASC Common LUT Format (CLF) +****************************************************** + +The set of CLF test files was expanded and a set of Python scripts was added under +``share/clf`` which were developed by the ACES Common LUT Format Implementation Working Group. +The scripts allow use of the OpenColorIO renderers to process a sample image through each +CLF file in the test suite and then compare the reference images to a set of corresponding +images from another CLF implementation to see if the differences are within the tolerance +allowed by the `CLF Implementation Guide. `_ + + +Imath 3 support +*************** + +OCIO and its CI system now support Imath 3 for the Half data type dependency. + + +Noteworthy API updates +********************** + +getColorSpaceFromFilePath ++++++++++++++++++++++++++ + +``Config::getColorSpaceFromFilepath()`` is now the proper way to extract a color space from +a file path, regardless of whether the config is version 1, or version 2 or higher. It +works regardless of whether the config has FileRules defined. Therefore, the older +``Config::parseColorSpaceFromString()`` method (which does not work with FileRules) is +officially deprecated. + +Note that ``Config::getColorSpaceFromFilepath()`` always returns a color space, regardless +of whether the config's ``strictparsing`` attribute is true or false. This was a request from +app developers that always need a default (which is a common scenario). Please see +`Issue #1398 `_ +for more details on how to take special action if ``strictparsing`` is true. + + +getDefaultView +++++++++++++++ +There is a new ``Config::getDefaultView(display, colorspaceName)`` method that takes +advantage of the ViewingRules feature that was introduced in OCIO 2.0. It returns the +default view that is most appropriate for a given color space. If the color space is +known, developers should call this rather than ``Config::getDefaultView(display)``. + +The motivation is that the best view transform to use varies with the color space. For +example, a scene-referred color space typically wants some kind of tone-map such as an +ACES Output Transform. However, a display-referred color space will look wrong with such +a view transform since it has already been tone-mapped. + +One scenario where this new method is ideal is when an application needs to generate +thumbnails for a large number of images that are in a variety of color spaces. Note that +the config must have the Viewing Rules set in order to return different views, but if the +rules are not set, it will still return the same result as ``Config::getDefaultView(display)``, +so it may be used with either v1 or v2 configs. + + +Release Notes +============= + +For more detail, please see the GitHub release pages: + +`OCIO 2.1.0 `_ + +`OCIO 2.1.1 `_ + +`OCIO 2.1.2 `_ diff --git a/docs/releases/ocio_2_2.rst b/docs/releases/ocio_2_2.rst new file mode 100644 index 0000000000..beb5624017 --- /dev/null +++ b/docs/releases/ocio_2_2.rst @@ -0,0 +1,395 @@ +.. + SPDX-License-Identifier: CC-BY-4.0 + Copyright Contributors to the OpenColorIO Project. + + +OCIO 2.2 Release +================ + +Timeline +******** + +OpenColorIO 2.2 was delivered in October 2022 and is in the VFX Reference Platform for +calendar year 2023. + + +New Features +============ + +Built-in Configs +**************** + +The OCIO Configs Working Group has put a lot of effort into building new ACES configs that +take advantage of the features of OCIO v2 and that are informed by the learnings from the +previous ACES configs. The new configs are available from the project's GitHub repo: +`OpenColorIO-Config-ACES +`_ + +To make them easily accessible, they are built in to the library itself and may be +accessed directly from within applications that incorporate the OCIO 2.2 library. + +For Users ++++++++++ + +Wherever you are able to provide a file path to a config, you may now provide a URI-type +string to instead use one of the built-in configs. For example, you may use these strings +for the OCIO environment variable. + +To use the :ref:`aces_cg`, use this string for the config path:: + ocio://cg-config-v1.0.0_aces-v1.3_ocio-v2.1 + +To use the :ref:`aces_studio`, use this string for the config path:: + ocio://studio-config-v1.0.0_aces-v1.3_ocio-v2.1 + +This string will give you the current default config, which is currently the ACES CG Config:: + ocio://default + +In future releases, it is expected that updated versions of these configs will be added, +each with a unique name string. However, the previous strings will continue to be +supported for backwards compatibility. + +For Developers +++++++++++++++ + +The new URI-type strings may be passed into the existing APIs such as ``CreateFromEnv`` +and ``CreateFromFile``. There is also a new ``CreateFromBuiltinConfig``. No changes +should be needed, but please test that users of your application may use a path containing +a URI-type string rather than a path to a config.ocio file. + +If you'd like to offer the built-in configs from your user interface, there is an API to +access them through the new ``BuiltinConfigRegistry``. Here is basic Python code to +access the registry and print the strings to present in a UI:: + + registry = ocio.BuiltinConfigRegistry().getBuiltinConfigs() + for item in registry: + # The short_name is the URI-style name. + # The ui_name is the name to use in a user interface. + short_name, ui_name, isRecommended, isDefault = item + + # Don't present built-in configs to users if they are no longer recommended. + if isRecommended: + print(ui_name) + +Prints: + + Academy Color Encoding System - CG Config [COLORSPACES v1.0.0] [ACES v1.3] [OCIO v2.1] + + Academy Color Encoding System - Studio Config [COLORSPACES v1.0.0] [ACES v1.3] [OCIO v2.1] + +If your application saves the path to a config and the user enters ``ocio://default``, it +is recommended that you don't save that as is. Instead, call +``getDefaultBuiltinConfigName`` to get the name of the current default. This is +guaranteed to give the same results, whereas the default config could change somewhat +between releases. Prepend ``ocio://`` in order to save it as a valid config path. Here's +the Python code:: + + "ocio://" + ocio.BuiltinConfigRegistry().getDefaultBuiltinConfigName() + + +Config Archiving +**************** + +An OCIO config, including its external LUT files, may now be packaged into a single file. +This makes it easier to distribute configs and may slightly discourage tampering with the +contents. An archived config may be created with the new ``ocioarchive`` command-line +tool and is stored in a file with the extension ``.ocioz``. It is basically a compressed +ZIP archive of the config and its LUTs. + +To be archivable, the external LUT files must be contained within (or below) the config's +working directory. (In OCIO terminology, the "working directory" is the directory that +contains the config.ocio file.) + +A config is not archivable if any of the following are true: + +* It contains FileTransforms with a src outside the working directory +* The search path contains paths outside the working directory +* The search path contains paths that start with a context variable +* The working directory is not set (if archiving a Config object) + +Context variables are allowed but the intent is that they may only resolve to paths that +are within or below the working directory. This is because the archiving function will +only archive files that are within the working directory in order to ensure that if it is +later expanded, that it will not create any files outside this directory. + +For example, a context variable on the search path intended to contain the name of a +sub-directory under the working directory must have the form ``./$DIR_NAME`` rather than +just ``$DIR_NAME`` to be considered archivable. This is imperfect since there is no way to +prevent the context variable from creating a path outside the working dir, but it should +at least draw attention to the fact that the archive would fail if used with context vars +that try to abuse the intended functionality. + +All files within or below the working directory that end with an extension corresponding +to a LUT type supported by OCIO are added to the archive. This approach was taken since +the goal was for the archive to work with any combination of context variables that the +original config works with. Files with other extensions or no extension are not archived. + + +For Users ++++++++++ + +Wherever you are able to provide a file path to a config, you may now provide a path to a +.ocioz file. For example, you may use this for the OCIO environment variable. + +The ``ocioarchive`` command-line tool will allow you to archive a config or to expand an +existing archive. It will also allow you to list the contents of an archived config. Run +``ocioarchive --help`` to get a print-out of the various options. + +The print out from the ``ociocheck`` command-line tool now includes a new line-item +indicating whether the config is archivable. + +For Developers +++++++++++++++ + +The new .ocioz files may be passed into the existing APIs such as ``CreateFromEnv`` and +``CreateFromFile``. No changes should be needed, but please test that users of your +application may use a path containing a .ocioz file rather than a path to a config.ocio +file. + +The Config class has new ``isArchivable`` and ``archive`` methods. There is also an +``ExtractOCIOZArchive`` function. + + +Abstracting the Source of External LUT Files +******************************************** + +The new ConfigIOProxy class allows the calling program to supply the config and any +associated LUT files directly, without relying on the standard file system. This opens +the door to expanded ways in which OCIO may be used. + +The new config archiving feature was implemented using this mechanism. + +For Developers +++++++++++++++ + +Please refer to the ``ConfigIOProxy`` class. By implementing the ``getLutData``, +``getConfigData``, and ``getFastLutFileHash`` methods, you have control over how the +config is provided to OCIO. No file system access to a config is required. + +The ``CreateFromConfigIOProxy`` factory allows for the creation of a Config object from a +ConfigIOProxy object. + + +Converting To or From a Known Color Space +***************************************** + +An OCIO config defines its own self-contained universe of color spaces. But there are not +any requirements for color spaces which must always be included or how they must be named. +This poses difficulties for many applications which need to convert to or from certain +known standard color spaces. For example, a renderer might have a physical sun and sky +model which produces colors in a CIE space and it needs to convert those into the +rendering space defined by a user's custom OCIO config. Or an application may use an SDK +to debayer images from a digital cinema camera. The SDK produces images in a specific +color space which then needs to be processed into something viewable through a user's +custom OCIO config. + +For Developers +++++++++++++++ + +OCIO v2 introduced the Interchange Roles to help address this problem but these had +previously been optional and are unlikely to be included in OCIO v1 configs (although it +would be perfectly legal to add them). + +OCIO 2.2 introduces the new functions ``GetProcessorToBuiltinColorSpace`` and +``GetProcessorFromBuiltinColorSpace`` that will allow you to convert to or from any of the +color spaces in the built-in Default config (this is currently the ACES CG config +described above). This built-in config includes common spaces such as "Linear Rec.709 +(sRGB)", "sRGB - Texture", "ACEScg", and "ACES2065-1". + +If the source config defines the necessary Interchange Role (typically +``aces_interchange``), then the conversion will be well-defined and equivalent to calling +``GetProcessorFromConfigs`` with the source config and the Built-in config + +However, if the Interchange Roles are not present, heuristics will be used to try and +identify a common color space in the source config that may be used to allow the +conversion to proceed. If the heuristics fail to find a suitable space, an exception is +thrown. The heuristics may evolve, so the results returned by this function for a given +source config and color space may change in future releases of the library. However, the +Interchange Roles are required in config versions 2.2 and higher, so it is hoped that the +need for the heuristics will decrease over time. + +The current heuristics should work on any config (including an OCIO v1 config) that was +generated by editing one of the ACES configs or any config that uses one of the following +as its reference space: + +* ACES2065-1 +* ACEScg +* Scene-linear Rec.709 (sRGB) +* Scene-linear Rec.2020 +* Scene-linear P3-D65 + +And that has a color space either for any of the above spaces or for an sRGB texture space +that has "sRGB" (case-insensitive) in its color space name or one of its aliases. + +Note that the heuristics create a Processor and evaluate color values that must match +within a certain tolerance. No color space is selected purely based on its name alone. +If the heuristics fail to find a recognized color space, an exception is thrown. + + +Making the interchange roles required for config versions 2.2 or higher +*********************************************************************** + +For Users ++++++++++ + +Users were surveyed during the OCIO 2.2 development process as to whether the Interchange +Roles should become mandatory. The response was overwhelmingly in favor of doing this, +largely because it allows robust interchange of color spaces between configs or to +external known standard color spaces. + +Therefore, as described in the previous section, for config files of version 2.2 or +higher, it is mandatory to define the ``aces_interchange`` role. If the config includes +display color spaces, the ``cie_xyz_d65_interchange`` role is also required. + +Note that the ``cie_xyz_d65_interchange`` is only used in connection with display color +spaces (that is, with the display-referred connection space). It is not used for +scene-referred color spaces, and indeed it is an error if a scene-referred space is +assigned to that role. + +The ``ociocheck`` command-line tool has been updated to make these checks. In addition, +its reporting on other roles has been modified to be more lenient regarding roles which +are no longer considered essential. + +For Developers +++++++++++++++ + +The Config::validate method will log an error if the Config object does not meet these +requirements. Note that an exception is not thrown since it was felt that the Config's +``upgradeToLatestVersion`` method must always produce a valid config. + + +Determining if a Color Space is Linear +************************************** + +There have been many requests from developers that would like a standard way to determine +if a color space is linear, since this impacts what sort of processing is suitable. OCIO +v2 introduced a new ``encoding`` attribute for color spaces which contains this +information. However, this is optional and may not be set by all config authors. And it +won't be present in OCIO v1 configs, which are still widely used. + +For Developers +++++++++++++++ + +OCIO 2.2 adds a new ``isColorSpaceLinear`` method to the Config class which may be used +for this purpose. + +Note that since OCIO has both a scene-referred and a display-referred reference space, the +method also takes a ReferenceSpaceType enum to indicate which reference space the +linearity determination is with respect to. Typically developers will set this to +``REFERENCE_SPACE_SCENE``. + +The following algorithm is used to make the determination: + +* If the color space ``isdata`` attribute is true, return false. +* If the reference space type of the color space differs from the requested reference +space type, return false. +* If the color space's encoding attribute is present, return true if it matches the +expected reference space type (i.e., "scene-linear" for ``REFERENCE_SPACE_SCENE`` or +"display-linear" for ``REFERENCE_SPACE_DISPLAY``) and false otherwise. +* If the color space has no ``to_reference`` or ``from_reference`` transform, return true. +* Evaluate several points through the color space's transform and check if the output only +differs by a scale factor (which may be different per channel, e.g. allowing an arbitrary +matrix transform, with no offset). + +Note that the last step is a heuristic that may or may not be accurate. However, note +that the ``encoding`` attribute takes precedence and so config authors have the ultimate +control over the linearity determination. + + +Getting a Processor for a NamedTransform +**************************************** + +For Developers +++++++++++++++ + +A new config object was introduced in OCIO v2 called Named Transforms. These are used +when there is a need to apply a mathematical function which is not a conversion between +two specific color spaces. The most common example is applying a transfer function curve +to convert linear data to non-linear, or vice-versa. + +The new ACES configs include Named Transforms, so it is important for application +developers to start supporting this type of config object. The preferred method for doing +so is to add a new tool, similar to FileTransform that applies a Named Transform. + +What is new in OCIO 2.2 is that the code for applying these is now simpler with the +introduction of several new getProcessor methods on the Config class that will return a +Processor directly from a NamedTransform object. + +In addition, the NamedTransform class has a GetTransform method that returns a (regular) +Transform object for a given direction. It will create the transform from the inverse +direction if the transform for the requested direction is missing. + + +Circular OCIO / OIIO Build Dependency Solution +********************************************** + +A long-standing complaint has been regarding the circular build dependency between OCIO +and OpenImageIO. This is due to the fact that OIIO wants to use OCIO for color management +and OCIO wants to use OIIO in its command-line tools ``ocioconvert``, ``ociolutimage``, +and ``ociodisplay`` for reading and writing image files. These tools will not be built if +OIIO is not available when configuring the build. + +Furthermore, some package installers will not install these command-line tools due to the +dependency on OIIO. + +By default, OCIO will now build these tools with OpenEXR rather than relying on OIIO. + +For Users ++++++++++ + +If you have a version of OCIO that was not compiled with tools such as ``ocioconvert`` and +you want to use OCIO to process images, you could try using OpenImageIO's ``oiiotool``. +(Although note that ``ocioconvert`` has a few features that are not in ``oiiotool``, such +as GPU processing support.) Similarly if you have ``ocioconvert``, but it is compiled +with OpenEXR rather than OpenImageIO, you may use ``oiiotool`` to convert other image file +formats to/from OpenEXR. + +If you want to use ``oiiotool`` but it does not support a particular type of conversion, +you may be able to use ``ociowrite`` to export a CTF file and then use that with the +``--ociofiletransform`` option in ``oiiotool``. + +For Developers +++++++++++++++ + +In OCIO 2.2, by default, the build will now use OpenEXR rather than OpenImageIO for the +command-line tools that read or write images. This will limit the functionality of the +aforementioned command-line tools to only working with OpenEXR files. If you want support +for more file formats in these tools, you will still need to have OIIO available when +building OCIO and set the CMake variable ``-D OCIO_USE_OIIO_FOR_APPS=ON``. + + +Miscellaneous Improvements +************************** + +Here are some other improvements in OCIO 2.2: + +* Support for more types of ICC Monitor Profiles -- All of the parametric curve types are +now supported. + +* New hash function for calculating cache IDs -- The md5 algorithm has been replaced with +xxhash, which provides a considerable speed-up for various operations. The APIs that +return cache ID strings will obviously return different strings now, but please note that +these are not guaranteed to be unchanged across releases. (The 128-bit version of xxhash +was used, which is the same length as for md5.) + +* The command-line tools ``ocioconvert``, ``ociowrite``, and ``ocioperf`` now support +using an inverse DisplayViewTransform. + +* Add DisplayViewTransform and NamedTransform support to Baker. + +* Several new Built-in Transforms are available for version 2.2 config files, including +ARRI LogC4. + +* Preliminary support for ACES Metadata File (AMF) -- A prototype Python tool has been +added named ``pyocioamf`` that converts an AMF file into the OCIO native transform format +CTF. It uses a prototype ACES Reference config file that is serving as a database of ACES +Transform IDs for interpreting the AMF file. + +* Support for PyPI installation from source rather than pre-built binaries. + + +Release Notes +============= + +For more detail, please see the GitHub release pages: + +`OCIO 2.2.0 `_ diff --git a/docs/toc_redirect.rst b/docs/toc_redirect.rst index 3785c12f92..2dd5537956 100644 --- a/docs/toc_redirect.rst +++ b/docs/toc_redirect.rst @@ -30,7 +30,7 @@ .. toctree:: :hidden: - upgrading_v2/_index + releases/_index .. toctree:: :hidden: diff --git a/include/OpenColorIO/OpenColorIO.h b/include/OpenColorIO/OpenColorIO.h index 514fcc3db0..a7d073f788 100644 --- a/include/OpenColorIO/OpenColorIO.h +++ b/include/OpenColorIO/OpenColorIO.h @@ -459,14 +459,25 @@ class OCIOEXPORT Config const char * getEnvironmentVarDefault(const char * name) const; void clearEnvironmentVars(); + /** + * \brief The EnvironmentMode controls the behavior of loadEnvironment. + * * ENV_ENVIRONMENT_LOAD_PREDEFINED - Only update vars already added to the Context. + * * ENV_ENVIRONMENT_LOAD_ALL - Load all env. vars into the Context. + * + * \note Loading ALL the env. vars may reduce performance and reduce cache efficiency. + * + * Client programs generally will not use these methods because the EnvironmentMode is + * set automatically when a Config is loaded. If the Config has an "environment" + * section, the mode is set to LOAD_PREDEFINED, and otherwise set to LOAD_ALL. + */ void setEnvironmentMode(EnvironmentMode mode) noexcept; EnvironmentMode getEnvironmentMode() const noexcept; + /// Initialize the environment/context variables in the Config's Context. void loadEnvironment() noexcept; const char * getSearchPath() const; /** - * \brief Set all search paths as a concatenated string, ':' to separate the - * paths. + * \brief Set all search paths as a concatenated string, use ':' to separate the paths. * * See \ref addSearchPath for a more robust and platform-agnostic method of * setting the search paths. @@ -3442,8 +3453,9 @@ class OCIOEXPORT Context void setWorkingDir(const char * dirname); const char * getWorkingDir() const; - /// Add (or update) a context variable. But it removes it if the value argument - /// is null. + /// Add (or update) a context variable. But it removes it if the value argument is null. + /// Note that a Context StringVar is the same thing as a Config EnvironmentVar and these + /// are both often referred to as a "context var". void setStringVar(const char * name, const char * value) noexcept; /// Get the context variable value. It returns an empty string if the context /// variable is null or does not exist. @@ -3459,13 +3471,11 @@ class OCIOEXPORT Context /// Add to the instance all the context variables from ctx. void addStringVars(const ConstContextRcPtr & ctx) noexcept; - + /// See \ref Config::setEnvironmentMode. void setEnvironmentMode(EnvironmentMode mode) noexcept; - - EnvironmentMode getEnvironmentMode() const noexcept; - /// Seed all string vars with the current environment. + /// Seed string vars with the current environment, based on the EnvironmentMode setting. void loadEnvironment() noexcept; /// Resolve all the context variables from the string. It could be color space diff --git a/include/OpenColorIO/OpenColorTypes.h b/include/OpenColorIO/OpenColorTypes.h index 9976ac821d..c400568eaa 100644 --- a/include/OpenColorIO/OpenColorTypes.h +++ b/include/OpenColorIO/OpenColorTypes.h @@ -456,11 +456,12 @@ enum GpuLanguage GPU_LANGUAGE_MSL_2_0 ///< Metal Shading Language }; +/// Controls which environment variables are loaded into a Context object. enum EnvironmentMode { ENV_ENVIRONMENT_UNKNOWN = 0, - ENV_ENVIRONMENT_LOAD_PREDEFINED, - ENV_ENVIRONMENT_LOAD_ALL + ENV_ENVIRONMENT_LOAD_PREDEFINED, ///< Only load vars in the config's environment section + ENV_ENVIRONMENT_LOAD_ALL ///< Load all env. vars (note: may reduce performance) }; /// A RangeTransform may be set to clamp the values, or not. From 38d7daa12b7773a9c183dcedc3173ab6a147265c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= <105517825+cedrik-fuoco-adsk@users.noreply.github.com> Date: Thu, 5 Jan 2023 10:26:45 -0500 Subject: [PATCH 13/13] Adsk Contrib - OCIO cmake improvements (#1736) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * - Refactoring how OCIO search for minizip-ng. The first step is to search for an external minizip-ng. If not found, search for minizip-ng with MZ_COMPAT=ON (libminizip). If it is not found either, download and install minizip-ng with MZ_COMPAT=OFF. - Removing the minizip-ng part for the includes for minizip-ng headers. Signed-off-by: Cédrik Fuoco * Update comments Signed-off-by: Cédrik Fuoco * Improved find_package in Config mode (adding it back) Added missing scripts to install minizip-ng and zlib for the analysis workflow Signed-off-by: Cédrik Fuoco * Adding +x permissions for install_minizip_ng and zlib Fixing path to find zlib in install_minizip-ng.sh Signed-off-by: Cédrik Fuoco * Changing target name to match the one used by minizip-ng library (+ using the imported target instead of creating a new one when minizip-ng is found) Signed-off-by: Cédrik Fuoco * First pass for the OpenColorIOConfig.cmake file with the required dependencies only. A few extra fixes for OpenEXR, ZLIB and Minizip-ng. Signed-off-by: Cédrik Fuoco * Adding a informative message when building static ocio instead of per module. Signed-off-by: Cédrik Fuoco * Adding an extra step to test the consumer app with static OpenColorIO for Windows, Linux and MacOS. Signed-off-by: Cédrik Fuoco * Re-using the same test instead of creating a new one by removing the condition on build-shared. Signed-off-by: Cédrik Fuoco * Fixing spacing, typo and adding back the NOT in the condition. (it was removed for debugging purpose) Signed-off-by: Cédrik Fuoco * Changing directory where we share OCIO custom find modules (now in /share/cmake/modules). Adding a cmake macro when installing OCIO since it is needed by some custom find modules. The find modules are only installed when building OCIO as a static library. The config.cmake.in files now only looks for the dependency when OCIO was built as a static library. Tentative (ci-workflow): Adding cmake-consumer test for static builds. Overhaul of the Findzlib module to be more inline with the FindZLIB from cmake and to be more robust. Signed-off-by: Cédrik Fuoco * Adding missing backward slashes and saving the build path in an existing step instead of creating a new step. Adding a check for CMake version for a section in Findzlib.cmake. Re-phrasing some comments. Signed-off-by: Cédrik Fuoco * Prevent the download of the dependencies in the scenario where static OCIO is linked to a consumer project. Since OCIO_INSTALL_EXT_PACKAGES is not defined, our find module tries to download the dependencies, but we don't want that mecanism for consumer project. Signed-off-by: Cédrik Fuoco * Changing path where OCIO install its own custom find module. Removing custom Findzlib and making modifications to use CMake FindZLIB. Created a InstallZLIB module which does the download and install part if OCIO_INSTALL_EXT_PACAKGES is ALL or MISSING. Tweaked config.cmake.in to use CMake FindZLIB. Signed-off-by: Cédrik Fuoco * Adding more details in comments Signed-off-by: Cédrik Fuoco * Removing an extra "shell" property in CI workflow. Signed-off-by: Cédrik Fuoco * Fix issues discovered with the failing CI workflow: Cmake-consumer test now prefer the static version of the dependencies. Fix an issue where yaml-cpp is not found by a consumer app (variable spelled incorectly in Findyaml-cpp). Fix an issue expat library is not found by a consumer app on Windows. Adding support for OCIO's _STATIC_LIBRARY for ZLIB while supporting ZLIB_USE_STATIC_LIBS (CMake 3.24+) from CMake's FindZLIB. Signed-off-by: Cédrik Fuoco * Removing pystring_STATIC_LIBRARY does not exists in CI workflow. Detecting if the build is Debug in the find module that OCIO installs since they can't rely on variables set by OCIO CMakefiles. Fix issue with yaml-cpp library naming in debug. Signed-off-by: Cédrik Fuoco * Fix issues on Windows with expat and minizip-ng library naming when building static OCIO. Signed-off-by: Cédrik Fuoco * Added option for macOS CI job in order to get more info on a failed job. Will be reverted once the issue is found. Signed-off-by: Cédrik Fuoco * Fixing a issue on macOS. Improving ZLIB usage comments. Bumping minizip-ng to the latest version - 3.0.7. Bumping ZLIB to the latest version 2.1.13 to fix a vulnerability (CVE-2022-37434) Signed-off-by: Cédrik Fuoco * Proposing to remove Findminizip module since external minizip-ng build need to be done with the same option as the internal build. Otherwise, linking and symbols issues are going to happend if the other libraries are not linked in correctly. It is going to simplify the maintainability of OCIO. Signed-off-by: Cédrik Fuoco * Removing findminizip.cmake from the install since it does not exist anymore. Signed-off-by: Cédrik Fuoco Signed-off-by: Cédrik Fuoco Signed-off-by: Cédrik Fuoco <105517825+cedrik-fuoco-adsk@users.noreply.github.com> (cherry picked from commit 91761f256b18365b9b2f25fb0f083c592ea2628e) Signed-off-by: Cédrik Fuoco --- .github/workflows/ci_workflow.yml | 95 +++++- CMakeLists.txt | 29 ++ share/cmake/modules/FindExtPackages.cmake | 106 ++++++- share/cmake/modules/FindImath.cmake | 11 +- share/cmake/modules/FindOpenEXR.cmake | 17 +- share/cmake/modules/Findexpat.cmake | 60 +++- share/cmake/modules/Findlcms2.cmake | 2 +- share/cmake/modules/Findminizip-ng.cmake | 270 +++++++++--------- share/cmake/modules/Findminizip.cmake | 172 ----------- share/cmake/modules/Findopenfx.cmake | 2 +- share/cmake/modules/Findpybind11.cmake | 2 +- share/cmake/modules/Findpystring.cmake | 10 +- share/cmake/modules/Findyaml-cpp.cmake | 38 +-- .../{Findzlib.cmake => InstallZLIB.cmake} | 78 ++--- src/cmake/Config.cmake.in | 123 ++++++++ 15 files changed, 611 insertions(+), 404 deletions(-) delete mode 100644 share/cmake/modules/Findminizip.cmake rename share/cmake/modules/{Findzlib.cmake => InstallZLIB.cmake} (73%) diff --git a/.github/workflows/ci_workflow.yml b/.github/workflows/ci_workflow.yml index 890021741b..77527cd723 100644 --- a/.github/workflows/ci_workflow.yml +++ b/.github/workflows/ci_workflow.yml @@ -287,11 +287,12 @@ jobs: --target install \ --config ${{ matrix.build-type }} \ -- -j$(nproc) + echo "ocio_build_path=$(pwd)" >> $GITHUB_ENV working-directory: _build - name: Test run: ctest -V -C ${{ matrix.build-type }} working-directory: _build - - name: Test CMake Consumer + - name: Test CMake Consumer with shared OCIO if: matrix.build-shared == 'ON' run: | cmake . \ @@ -301,6 +302,34 @@ jobs: --config ${{ matrix.build-type }} ./consumer working-directory: _build/tests/cmake-consumer-dist + - name: Test CMake Consumer with static OCIO + if: matrix.build-shared == 'OFF' + # The yaml-cpp_VERSION is set below because Findyaml-cpp.cmake needs it but is unable to + # extract it from the headers, like the other modules. + # + # Prefer the static version of each dependencies by using _STATIC_LIBRARY. + # Alternatively, this can be done by setting _LIBRARY and _INCLUDE_DIR to + # the static version of the package. + run: | + cmake . \ + -DCMAKE_PREFIX_PATH=../../../_install \ + -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ + -Dexpat_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -Dexpat_STATIC_LIBRARY=ON \ + -DImath_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -DImath_STATIC_LIBRARY=ON \ + -Dpystring_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -Dyaml-cpp_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -Dyaml-cpp_STATIC_LIBRARY=ON \ + -Dyaml-cpp_VERSION=0.7.0 \ + -DZLIB_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -DZLIB_STATIC_LIBRARY=ON \ + -Dminizip-ng_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -Dminizip-ng_STATIC_LIBRARY=ON + cmake --build . \ + --config ${{ matrix.build-type }} + ./consumer + working-directory: _build/tests/cmake-consumer-dist # --------------------------------------------------------------------------- # macOS @@ -424,11 +453,12 @@ jobs: --target install \ --config ${{ matrix.build-type }} \ -- -j$(sysctl -n hw.ncpu) + echo "ocio_build_path=$(pwd)" >> $GITHUB_ENV working-directory: _build - name: Test run: ctest -V -C ${{ matrix.build-type }} working-directory: _build - - name: Test CMake Consumer + - name: Test CMake Consumer with shared OCIO if: matrix.build-shared == 'ON' run: | cmake . \ @@ -438,6 +468,34 @@ jobs: --config ${{ matrix.build-type }} ./consumer working-directory: _build/tests/cmake-consumer-dist + - name: Test CMake Consumer with static OCIO + if: matrix.build-shared == 'OFF' + # The yaml-cpp_VERSION is set below because Findyaml-cpp.cmake needs it but is unable to + # extract it from the headers, like the other modules. + # + # Prefer the static version of each dependencies by using _STATIC_LIBRARY. + # Alternatively, this can be done by setting _LIBRARY and _INCLUDE_DIR to + # the static version of the package. + run: | + cmake . \ + -DCMAKE_PREFIX_PATH=../../../_install \ + -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ + -Dexpat_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -Dexpat_STATIC_LIBRARY=ON \ + -DImath_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -DImath_STATIC_LIBRARY=ON \ + -Dpystring_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -Dyaml-cpp_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -Dyaml-cpp_STATIC_LIBRARY=ON \ + -Dyaml-cpp_VERSION=0.7.0 \ + -DZLIB_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -DZLIB_STATIC_LIBRARY=ON \ + -Dminizip-ng_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -Dminizip-ng_STATIC_LIBRARY=ON + cmake --build . \ + --config ${{ matrix.build-type }} + ./consumer + working-directory: _build/tests/cmake-consumer-dist # --------------------------------------------------------------------------- # Windows @@ -567,13 +625,14 @@ jobs: cmake --build . \ --target install \ --config ${{ matrix.build-type }} + echo "ocio_build_path=$(pwd)" >> $GITHUB_ENV shell: bash working-directory: _build - name: Test run: ctest -V -C ${{ matrix.build-type }} shell: bash working-directory: _build - - name: Test CMake Consumer + - name: Test CMake Consumer with shared OCIO if: matrix.build-shared == 'ON' run: | cmake . \ @@ -585,3 +644,33 @@ jobs: ./${{ matrix.build-type }}/consumer shell: bash working-directory: _build/tests/cmake-consumer-dist + - name: Test CMake Consumer with static OCIO + if: matrix.build-shared == 'OFF' + # The yaml-cpp_VERSION is set below because Findyaml-cpp.cmake needs it but is unable to + # extract it from the headers, like the other modules. + # + # Prefer the static version of each dependencies by using _STATIC_LIBRARY. + # Alternatively, this can be done by setting _LIBRARY and _INCLUDE_DIR to + # the static version of the package. + run: | + cmake . \ + -DCMAKE_PREFIX_PATH=../../../_install \ + -DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \ + -Dexpat_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -Dexpat_STATIC_LIBRARY=ON \ + -DImath_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -DImath_STATIC_LIBRARY=ON \ + -Dpystring_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -Dyaml-cpp_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -Dyaml-cpp_STATIC_LIBRARY=ON \ + -Dyaml-cpp_VERSION=0.7.0 \ + -DZLIB_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -DZLIB_STATIC_LIBRARY=ON \ + -Dminizip-ng_ROOT=${{ env.ocio_build_path }}/ext/dist \ + -Dminizip-ng_STATIC_LIBRARY=ON + cmake --build . \ + --config ${{ matrix.build-type }} + export PATH=../../../_install/bin:$PATH + ./${{ matrix.build-type }}/consumer + shell: bash + working-directory: _build/tests/cmake-consumer-dist diff --git a/CMakeLists.txt b/CMakeLists.txt index d112bb3af4..17e188db2b 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -251,6 +251,15 @@ if(OCIO_BUILD_STATIC) endif() endif() +if (NOT BUILD_SHARED_LIBS AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + message(STATUS "Note that building the static version of OpenColorIO does not embed the dependencies\ + into the library file. The needed dependencies must be linked to the consumer + application or shared library that uses static OpenColorIO. + + The following mandatory dependencies MUST be linked to the consumer application or shared library: + expat, yaml-cpp, Imath, pystring, minizip-ng and ZLIB") +endif() + ############################################################################### # Find or install external dependencies @@ -299,6 +308,8 @@ set(OCIO_TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets.cmake") set(OCIO_VERSION_CONFIG "${CMAKE_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake") set(OCIO_PROJECT_CONFIG "${CMAKE_BINARY_DIR}/${PROJECT_NAME}Config.cmake") set(OCIO_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") +set(OCIO_CUSTOM_FIND_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/share/OpenColorIO/cmake/modules") +set(OCIO_CUSTOM_MACROS_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/share/OpenColorIO/cmake/macros") # Version fetched from the top level project() write_basic_package_version_file( @@ -321,6 +332,24 @@ install( FILE ${OCIO_TARGETS_EXPORT_NAME} ) +if (NOT BUILD_SHARED_LIBS) + # Install custom macros used in the find modules. + install(FILES + ${CMAKE_CURRENT_LIST_DIR}/share/cmake/macros/VersionUtils.cmake + DESTINATION ${OCIO_CUSTOM_MACROS_MODULE_DIR} + ) + + # Install custom Find modules. + install(FILES + ${CMAKE_CURRENT_LIST_DIR}/share/cmake/modules/Findexpat.cmake + ${CMAKE_CURRENT_LIST_DIR}/share/cmake/modules/FindImath.cmake + ${CMAKE_CURRENT_LIST_DIR}/share/cmake/modules/Findpystring.cmake + ${CMAKE_CURRENT_LIST_DIR}/share/cmake/modules/Findminizip-ng.cmake + ${CMAKE_CURRENT_LIST_DIR}/share/cmake/modules/Findyaml-cpp.cmake + DESTINATION ${OCIO_CUSTOM_FIND_MODULE_DIR} + ) +endif() + install( FILES "${OCIO_PROJECT_CONFIG}" "${OCIO_VERSION_CONFIG}" DESTINATION "${OCIO_CONFIG_INSTALL_DIR}" diff --git a/share/cmake/modules/FindExtPackages.cmake b/share/cmake/modules/FindExtPackages.cmake index b777e5bb8f..5455a08ce6 100644 --- a/share/cmake/modules/FindExtPackages.cmake +++ b/share/cmake/modules/FindExtPackages.cmake @@ -21,6 +21,17 @@ set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY ON CACHE BOOL set(CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY ON CACHE BOOL "Disable CMake System Package Registry when finding packages") +if (APPLE) + # Store the previous value of CMAKE_FIND_FRAMEWORK and CMAKE_FIND_APPBUNDLE. + set(_PREVIOUS_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK}) + set(_PREVIOUS_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE}) + + # Prioritize other paths before Frameworks and Appbundle for find_path, find_library and + # find_package. + set(CMAKE_FIND_FRAMEWORK LAST) + set(CMAKE_FIND_APPBUNDLE LAST) +endif() + ############################################################################### ### Packages and versions ### @@ -41,14 +52,93 @@ find_package(pystring 1.1.3 REQUIRED) set(_Imath_ExternalProject_VERSION "3.1.5") find_package(Imath 3.0 REQUIRED) -# ZLIB -# https://github.com/madler/zlib -set(_zlib_ExternalProject_VERSION "1.2.12") -find_package(zlib REQUIRED) +############################################################################### +### ZLIB (https://github.com/madler/zlib) +### +### The following variables can be set: +### ZLIB_ROOT Location of ZLIB library file and includes folder. +### Alternatively, ZLIB_LIBRARY and ZLIB_INCLUDE_DIR can be used. +### +### ZLIB_LIBRARY Location of ZLIB library file. +### ZLIB_INCLUDE_DIR Location of ZLIB includes folder. +### +### ZLIB_VERSION ZLIB Version (CMake 3.26+) +### ZLIB_VERSION_STRING ZLIB Version (CMake < 3.26) +### +############################################################################### +# ZLIB 1.2.13 is used since it fixes a critical vulnerability. +# See https://nvd.nist.gov/vuln/detail/CVE-2022-37434 +# See https://github.com/madler/zlib/releases/tag/v1.2.13 +set(_ZLIB_FIND_VERSION "1.2.13") +set(_ZLIB_ExternalProject_VERSION ${_ZLIB_FIND_VERSION}) + +if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) + # ZLIB_USE_STATIC_LIBS is supported only from CMake 3.24+. + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0") + if (ZLIB_STATIC_LIBRARY) + set(ZLIB_USE_STATIC_LIBS "${ZLIB_STATIC_LIBRARY}") + endif() + else() # For CMake < 3.24 since ZLIB_USE_STATIC_LIBS is not available. + if(NOT ZLIB_LIBRARY) + if(DEFINED CMAKE_FIND_LIBRARY_PREFIXES) + set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") + else() + set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES) + endif() + + if(DEFINED CMAKE_FIND_LIBRARY_SUFFIXES) + set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}") + else() + set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + endif() + + # Prefix/suffix for windows. + if(WIN32) + list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "" "lib") + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a") + endif() + + # Check if static lib is preferred. + if(ZLIB_STATIC_LIBRARY OR ZLIB_USE_STATIC_LIBS) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a) + endif() + endif() + endif() + endif() + + set(_ZLIB_REQUIRED REQUIRED) + # Override REQUIRED if package can be installed + if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) + set(_ZLIB_REQUIRED "") + endif() + + find_package(ZLIB ${_ZLIB_FIND_VERSION} ${_ZLIB_REQUIRED}) + + # Restore the original find library ordering + if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}") + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES) + endif() + + if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES) + set(CMAKE_FIND_LIBRARY_PREFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES}") + else() + set(CMAKE_FIND_LIBRARY_PREFIXES) + endif() +endif() + +if(NOT ZLIB_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + include(InstallZLIB) +endif() +############################################################################### # minizip-ng # https://github.com/zlib-ng/minizip-ng -find_package(minizip-ng 3.0.6 REQUIRED) +find_package(minizip-ng 3.0.7 REQUIRED) if(OCIO_BUILD_APPS) @@ -157,3 +247,9 @@ if(OCIO_BUILD_TESTS) message(WARNING "Could NOT find OpenImageIO. Skipping build of the OSL unit tests.") endif() endif() + +if (APPLE) + # Restore CMAKE_FIND_FRAMEWORK and CMAKE_FIND_APPBUNDLE values. + set(CMAKE_FIND_FRAMEWORK ${_PREVIOUS_CMAKE_FIND_FRAMEWORK}) + set(CMAKE_FIND_APPBUNDLE ${_PREVIOUS_CMAKE_FIND_APPBUNDLE}) +endif() diff --git a/share/cmake/modules/FindImath.cmake b/share/cmake/modules/FindImath.cmake index 1510bbdf70..30f5b4e465 100644 --- a/share/cmake/modules/FindImath.cmake +++ b/share/cmake/modules/FindImath.cmake @@ -25,6 +25,15 @@ ############################################################################### ### Try to find package ### +# BUILD_TYPE_DEBUG variable is currently set in one of the OCIO's CMake files. +# Now that some OCIO's find module are installed with the library itself (with static build), +# a consumer app don't have access to the variables set by an OCIO's CMake files. Therefore, some +# OCIO's find modules must detect the build type by itselves. +set(BUILD_TYPE_DEBUG OFF) +if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]") + set(BUILD_TYPE_DEBUG ON) +endif() + if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) set(_Imath_REQUIRED_VARS Imath_LIBRARY) set(_Imath_LIB_VER "${Imath_FIND_VERSION_MAJOR}_${Imath_FIND_VERSION_MINOR}") @@ -131,7 +140,7 @@ endif() ############################################################################### ### Install package from source ### -if(NOT Imath_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) +if(NOT Imath_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) include(ExternalProject) include(GNUInstallDirs) diff --git a/share/cmake/modules/FindOpenEXR.cmake b/share/cmake/modules/FindOpenEXR.cmake index 8c14635413..a8b8448fd6 100644 --- a/share/cmake/modules/FindOpenEXR.cmake +++ b/share/cmake/modules/FindOpenEXR.cmake @@ -45,6 +45,10 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) if(OpenEXR_FOUND) get_target_property(OpenEXR_LIBRARY OpenEXR::OpenEXR LOCATION) get_target_property(OpenEXR_INCLUDE_DIR OpenEXR::OpenEXR INTERFACE_INCLUDE_DIRECTORIES) + + # IMPORTED_GLOBAL property must be set to TRUE since alisasing a non-global imported target + # is not possible until CMake 3.18+. + set_target_properties(OpenEXR::OpenEXR PROPERTIES IMPORTED_GLOBAL TRUE) endif() # Override REQUIRED if package can be installed @@ -77,7 +81,7 @@ macro(set_target_location target_name) endif() endmacro() -if(NOT OpenEXR_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) +if(NOT OpenEXR_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) include(ExternalProject) include(GNUInstallDirs) @@ -85,13 +89,14 @@ if(NOT OpenEXR_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") # Required dependency - # OCIO custom module to find ZLIB. (Findzlib) - find_package(zlib) if(NOT ZLIB_FOUND) - message(STATUS "ZLib is required to build OpenEXR.") - return() + find_package(ZLIB) + if(NOT ZLIB_FOUND) + message(STATUS "ZLib is required to build OpenEXR.") + return() + endif() endif() - + find_package(Threads) if(NOT Threads_FOUND) message(STATUS "Threads is required to build OpenEXR.") diff --git a/share/cmake/modules/Findexpat.cmake b/share/cmake/modules/Findexpat.cmake index 59e5c2e102..8e23cbba0b 100644 --- a/share/cmake/modules/Findexpat.cmake +++ b/share/cmake/modules/Findexpat.cmake @@ -25,6 +25,15 @@ ############################################################################### ### Try to find package ### +# BUILD_TYPE_DEBUG variable is currently set in one of the OCIO's CMake files. +# Now that some OCIO's find module are installed with the library itself (with static build), +# a consumer app don't have access to the variables set by an OCIO's CMake files. Therefore, some +# OCIO's find modules must detect the build type by itselves. +set(BUILD_TYPE_DEBUG OFF) +if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]") + set(BUILD_TYPE_DEBUG ON) +endif() + if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) set(_expat_REQUIRED_VARS expat_LIBRARY) @@ -87,21 +96,58 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) expat/include ) + + # Expat uses prefix "lib" on all platform by default. + # Library name doesn't change in debug. + + # For Windows, see https://github.com/libexpat/libexpat/blob/R_2_2_8/expat/win32/README.txt. + # libexpat.lib + # The "w" indicates the UTF-16 version of the library. + # Lib names to search for - set(_expat_LIB_NAMES expat libexpat) + set(_expat_LIB_NAMES libexpat expat) + if(WIN32 AND BUILD_TYPE_DEBUG) - # Prefer Debug lib names (Windows only) - list(INSERT _expat_LIB_NAMES 0 expatd) + # Prefer Debug lib names. The library name changes only on Windows. + list(INSERT _expat_LIB_NAMES 0 libexpatd libexpatwd expatd expatwd) + elseif(WIN32) + # libexpat(w).dll/.lib + list(APPEND _expat_LIB_NAMES libexpatw expatw) endif() if(expat_STATIC_LIBRARY) + # Looking for both "lib" prefix and CMAKE_STATIC_LIBRARY_PREFIX. # Prefer static lib names - set(_expat_STATIC_LIB_NAMES + set(_expat_STATIC_LIB_NAMES + "libexpat${CMAKE_STATIC_LIBRARY_SUFFIX}" "${CMAKE_STATIC_LIBRARY_PREFIX}expat${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(WIN32 AND BUILD_TYPE_DEBUG) - # Prefer static Debug lib names (Windows only) + # Prefer static Debug lib names. The library name changes only on Windows. + list(INSERT _expat_STATIC_LIB_NAMES 0 + "libexpatdMD${CMAKE_STATIC_LIBRARY_SUFFIX}" + "libexpatdMT${CMAKE_STATIC_LIBRARY_SUFFIX}" + "libexpatd${CMAKE_STATIC_LIBRARY_SUFFIX}" + "libexpatwdMD${CMAKE_STATIC_LIBRARY_SUFFIX}" + "libexpatwdMT${CMAKE_STATIC_LIBRARY_SUFFIX}" + "libexpatwd${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}expatdMD${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}expatdMT${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}expatd${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}expatwdMD${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}expatwdMT${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}expatwd${CMAKE_STATIC_LIBRARY_SUFFIX}") + elseif (WIN32) list(INSERT _expat_STATIC_LIB_NAMES 0 - "${CMAKE_STATIC_LIBRARY_PREFIX}expatd${CMAKE_STATIC_LIBRARY_SUFFIX}") + "libexpatMD${CMAKE_STATIC_LIBRARY_SUFFIX}" + "libexpatMT${CMAKE_STATIC_LIBRARY_SUFFIX}" + "libexpatwMD${CMAKE_STATIC_LIBRARY_SUFFIX}" + "libexpatwMT${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}expatMD${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}expatMT${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}expatwMD${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}expatwMT${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) endif() endif() @@ -162,7 +208,7 @@ endif() ############################################################################### ### Install package from source ### -if(NOT expat_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) +if(NOT expat_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) include(ExternalProject) include(GNUInstallDirs) diff --git a/share/cmake/modules/Findlcms2.cmake b/share/cmake/modules/Findlcms2.cmake index b7049ce4f4..f35fcf14f4 100644 --- a/share/cmake/modules/Findlcms2.cmake +++ b/share/cmake/modules/Findlcms2.cmake @@ -97,7 +97,7 @@ endif() ############################################################################### ### Install package from source ### -if(NOT lcms2_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) +if(NOT lcms2_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) include(ExternalProject) set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") diff --git a/share/cmake/modules/Findminizip-ng.cmake b/share/cmake/modules/Findminizip-ng.cmake index 0915ad8b18..b961d1c9ac 100644 --- a/share/cmake/modules/Findminizip-ng.cmake +++ b/share/cmake/modules/Findminizip-ng.cmake @@ -3,12 +3,6 @@ # # Locate or install minizip-ng # -# This module will try to do the following: -# 1) Locate minizip-ng -# 2) If minizip-ng cannot be found, it will try to find minizip (minizip-ng with MZ_COMPAT=ON) -# 3) If minizip-ng with MZ_COMPAT=ON cannot be found, minizip-ng will be downloaded, built and -# installed. -# # Variables defined by this module: # minizip-ng_FOUND - If FALSE, do not try to link to minizip-ng # minizip-ng_LIBRARY - minizip-ng library to link to @@ -32,6 +26,15 @@ ############################################################################### ### Try to find package ### +# BUILD_TYPE_DEBUG variable is currently set in one of the OCIO's CMake files. +# Now that some OCIO's find module are installed with the library itself (with static build), +# a consumer app don't have access to the variables set by an OCIO's CMake files. Therefore, some +# OCIO's find modules must detect the build type by itselves. +set(BUILD_TYPE_DEBUG OFF) +if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]") + set(BUILD_TYPE_DEBUG ON) +endif() + if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) if(NOT DEFINED minizip-ng_ROOT) # Search for minizip-ng-config.cmake @@ -106,23 +109,22 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) minizip-ng/include ) - # Lib names to search for - set(_minizip-ng_LIB_NAMES minizip-ng) + # Minizip-ng uses prefix "lib" on all platform by default. + # Library name doesn't change in debug. - if(BUILD_TYPE_DEBUG) - # Prefer Debug lib names (Windows only) - list(INSERT _minizip-ng_LIB_NAMES 0 minizip-ngd) - endif() + # Lib names to search for. + # Search for "minizip" since the library could be named "minizip" if it was built + # with MZ_COMPAT=ON. + set(_minizip-ng_LIB_NAMES libminizip-ng minizip-ng libminizip minizip) if(minizip-ng_STATIC_LIBRARY) - # Prefer static lib names + # Looking for both "lib" prefix and CMAKE_STATIC_LIBRARY_PREFIX. + # Prefer static lib names. set(_minizip-ng_STATIC_LIB_NAMES - "${CMAKE_STATIC_LIBRARY_PREFIX}minizip-ng${CMAKE_STATIC_LIBRARY_SUFFIX}") - if(WIN32 AND BUILD_TYPE_DEBUG) - # Prefer static Debug lib names (Windows only) - list(INSERT _minizip-ng_STATIC_LIB_NAMES 0 - "${CMAKE_STATIC_LIBRARY_PREFIX}minizip-ngd${CMAKE_STATIC_LIBRARY_SUFFIX}") - endif() + "libminizip-ng${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}minizip-ng${CMAKE_STATIC_LIBRARY_SUFFIX}" + "libminizip${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}minizip${CMAKE_STATIC_LIBRARY_SUFFIX}") endif() # Find library @@ -138,7 +140,23 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) ) # Get version from header or pkg-config - set(minizip-ng_VERSION "${minizip-ng_FIND_VERSION}") + if(minizip-ng_INCLUDE_DIR) + list(GET minizip-ng_INCLUDE_DIR 0 _minizip-ng_INCLUDE_DIR) + if(EXISTS "${_minizip-ng_INCLUDE_DIR}/mz.h") + set(_minizip-ng_CONFIG "${_minizip-ng_INCLUDE_DIR}/mz.h") + endif() + endif() + + if(_minizip-ng_CONFIG) + file(STRINGS "${_minizip-ng_CONFIG}" _minizip-ng_VER_SEARCH + REGEX "^[ \t]*#define[ \t]+MZ_VERSION[ \t]+\\(\"[.0-9]+\"\\).*$") + if(_minizip-ng_VER_SEARCH) + string(REGEX REPLACE ".*#define[ \t]+MZ_VERSION[ \t]+\\(\"([.0-9]+)\"\\).*" + "\\1" minizip-ng_VERSION "${_minizip-ng_VER_SEARCH}") + endif() + elseif(PC_minizip-ng_FOUND) + set(minizip-ng_VERSION "${PC_minizip-ng_VERSION}") + endif() endif() # Override REQUIRED if package can be installed @@ -156,128 +174,120 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) ) endif() -if(NOT minizip-ng_FOUND) - # Looking for an external minizip-ng that might be built using MZ_COMPAT=ON. - # But do not download it if it cannot be found. - find_package(minizip ${minizip-ng_FIND_VERSION} REQUIRED) +############################################################################### +### Create target +if(NOT TARGET MINIZIP::minizip-ng) + add_library(MINIZIP::minizip-ng UNKNOWN IMPORTED GLOBAL) + set(_minizip-ng_TARGET_CREATE TRUE) endif() -if(NOT minizip_FOUND AND NOT TARGET MINIZIP::minizip) - ############################################################################### - ### Create target - - if(NOT TARGET MINIZIP::minizip-ng) - add_library(MINIZIP::minizip-ng UNKNOWN IMPORTED GLOBAL) - set(_minizip-ng_TARGET_CREATE TRUE) - endif() - - ############################################################################### - ### Install package from source ### - if(NOT minizip-ng_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) - include(ExternalProject) - include(GNUInstallDirs) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") - - # Set find_package standard args - set(minizip-ng_FOUND TRUE) - set(minizip-ng_VERSION ${minizip-ng_FIND_VERSION}) - - set(minizip-ng_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}/minizip-ng") +############################################################################### +### Install package from source ### + +if(NOT minizip-ng_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + include(ExternalProject) + include(GNUInstallDirs) + + set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") + set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") + + # Set find_package standard args + set(minizip-ng_FOUND TRUE) + set(minizip-ng_VERSION ${minizip-ng_FIND_VERSION}) + + set(minizip-ng_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}/minizip-ng") + + # Minizip-ng use a hardcoded lib prefix instead of CMAKE_STATIC_LIBRARY_PREFIX + set(_minizip-ng_LIB_PREFIX "lib") + + set(minizip-ng_LIBRARY + "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${_minizip-ng_LIB_PREFIX}minizip-ng${_minizip-ng_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") + + if(_minizip-ng_TARGET_CREATE) + set(minizip-ng_CMAKE_ARGS + ${minizip-ng_CMAKE_ARGS} + -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} + -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} + -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} + -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} + -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + # Since the other modules create a subfolder for the includes by default and since + # minizip-ng does not, a suffix is added to CMAKE_INSTALL_INCLUDEDIR in order to + # install the headers under a subdirectory named "minizip-ng". + # Note that this does not affect external builds for minizip-ng. + -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}/minizip-ng + -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} + -DBUILD_SHARED_LIBS=OFF + -DMZ_OPENSSL=OFF + -DMZ_LIBBSD=OFF + -DMZ_BUILD_TESTS=OFF + -DMZ_COMPAT=OFF + -DMZ_BZIP2=OFF + -DMZ_LZMA=OFF + -DMZ_LIBCOMP=OFF + -DMZ_ZSTD=OFF + -DMZ_PKCRYPT=OFF + -DMZ_WZAES=OFF + -DMZ_SIGNING=OFF + -DMZ_ZLIB=ON + -DMZ_ICONV=OFF + -DMZ_FETCH_LIBS=OFF + -DMZ_FORCE_FETCH_LIBS=OFF + -DZLIB_LIBRARY=${ZLIB_LIBRARIES} + -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS} + ) - # Minizip-ng use a hardcoded lib prefix instead of CMAKE_STATIC_LIBRARY_PREFIX - set(_minizip-ng_LIB_PREFIX "lib") + if(CMAKE_TOOLCHAIN_FILE) + set(minizip-ng_CMAKE_ARGS + ${minizip-ng_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() - set(minizip-ng_LIBRARY - "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${_minizip-ng_LIB_PREFIX}minizip-ng${_minizip-ng_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(APPLE) + string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") - if(_minizip-ng_TARGET_CREATE) set(minizip-ng_CMAKE_ARGS ${minizip-ng_CMAKE_ARGS} - -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} - -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} - -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} - -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} - -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} - # Since the other modules create a subfolder for the includes by default and since - # minizip-ng does not, a suffix is added to CMAKE_INSTALL_INCLUDEDIR in order to - # install the headers under a subdirectory named "minizip-ng". - # Note that this does not affect external builds for minizip-ng. - -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}/minizip-ng - -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} - -DBUILD_SHARED_LIBS=OFF - -DMZ_OPENSSL=OFF - -DMZ_LIBBSD=OFF - -DMZ_BUILD_TESTS=OFF - -DMZ_COMPAT=OFF - -DMZ_BZIP2=OFF - -DMZ_LZMA=OFF - -DMZ_LIBCOMP=OFF - -DMZ_ZSTD=OFF - -DMZ_PKCRYPT=OFF - -DMZ_WZAES=OFF - -DMZ_SIGNING=OFF - -DMZ_ZLIB=ON - -DMZ_ICONV=OFF - -DMZ_FETCH_LIBS=OFF - -DMZ_FORCE_FETCH_LIBS=OFF - -DZLIB_LIBRARY=${ZLIB_LIBRARIES} - -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} + -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} ) + endif() - if(CMAKE_TOOLCHAIN_FILE) - set(minizip-ng_CMAKE_ARGS - ${minizip-ng_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) - endif() - - if(APPLE) - string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") - - set(minizip-ng_CMAKE_ARGS - ${minizip-ng_CMAKE_ARGS} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} - -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} - ) - endif() - - if (ANDROID) - set(minizip-ng_CMAKE_ARGS - ${minizip-ng_CMAKE_ARGS} - -DANDROID_PLATFORM=${ANDROID_PLATFORM} - -DANDROID_ABI=${ANDROID_ABI} - -DANDROID_STL=${ANDROID_STL}) - endif() + if (ANDROID) + set(minizip-ng_CMAKE_ARGS + ${minizip-ng_CMAKE_ARGS} + -DANDROID_PLATFORM=${ANDROID_PLATFORM} + -DANDROID_ABI=${ANDROID_ABI} + -DANDROID_STL=${ANDROID_STL}) endif() + endif() - # Hack to let imported target be built from ExternalProject_Add - file(MAKE_DIRECTORY ${minizip-ng_INCLUDE_DIR}) - - ExternalProject_Add(minizip-ng_install - GIT_REPOSITORY "https://github.com/zlib-ng/minizip-ng.git" - GIT_TAG "${minizip-ng_VERSION}" - GIT_CONFIG advice.detachedHead=false - GIT_SHALLOW TRUE - PREFIX "${_EXT_BUILD_ROOT}/libminizip-ng" - BUILD_BYPRODUCTS ${minizip-ng_LIBRARY} - CMAKE_ARGS ${minizip-ng_CMAKE_ARGS} - EXCLUDE_FROM_ALL TRUE - BUILD_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} --build . - --config ${CMAKE_BUILD_TYPE} - --target install - --parallel - ) + # Hack to let imported target be built from ExternalProject_Add + file(MAKE_DIRECTORY ${minizip-ng_INCLUDE_DIR}) + + ExternalProject_Add(minizip-ng_install + GIT_REPOSITORY "https://github.com/zlib-ng/minizip-ng.git" + GIT_TAG "${minizip-ng_VERSION}" + GIT_CONFIG advice.detachedHead=false + GIT_SHALLOW TRUE + PREFIX "${_EXT_BUILD_ROOT}/libminizip-ng" + BUILD_BYPRODUCTS ${minizip-ng_LIBRARY} + CMAKE_ARGS ${minizip-ng_CMAKE_ARGS} + EXCLUDE_FROM_ALL TRUE + BUILD_COMMAND "" + INSTALL_COMMAND + ${CMAKE_COMMAND} --build . + --config ${CMAKE_BUILD_TYPE} + --target install + --parallel + ) - add_dependencies(MINIZIP::minizip-ng minizip-ng_install) - message(STATUS "Installing minizip-ng: ${minizip-ng_LIBRARY} (version \"${minizip-ng_VERSION}\")") - endif() + add_dependencies(MINIZIP::minizip-ng minizip-ng_install) + message(STATUS "Installing minizip-ng: ${minizip-ng_LIBRARY} (version \"${minizip-ng_VERSION}\")") endif() ############################################################################### diff --git a/share/cmake/modules/Findminizip.cmake b/share/cmake/modules/Findminizip.cmake deleted file mode 100644 index 1a75747177..0000000000 --- a/share/cmake/modules/Findminizip.cmake +++ /dev/null @@ -1,172 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright Contributors to the OpenColorIO Project. -# -# Locate minizip-ng with MZ_COMPAT=ON. -# -# This module DOES NOT install minizip-ng with MZ_COMPAT=ON if it is not found. -# -# Note: This option changes the name for the library file to "libminizip", but it is still -# actually minizip-ng. OCIO uses the API from minizip-ng. -# -# Variables defined by this module: -# minizip_FOUND - If FALSE, do not try to link to minizip -# minizip_LIBRARY - minizip library to link to -# minizip_INCLUDE_DIR - Where to find mz.h and other headers -# minizip_VERSION - The version of the library -# -# This module set the variables below because this is still minizip-ng. The librarie become -# "minizip" because of the cmake option MZ_COMPAT=ON. -# -# minizip-ng_FOUND - If FALSE, do not try to link to minizip-ng -# minizip-ng_LIBRARY - minizip-ng library to link to -# minizip-ng_INCLUDE_DIR - Where to find mz.h and other headers -# minizip-ng_VERSION - The version of the library -# -# Targets defined by this module: -# MINIZIP::minizip-ng - IMPORTED target, if found -# -############################################################################### -### Try to find package ### - -if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) - - if(NOT DEFINED minizip_ROOT) - # Search for minizip-config.cmake - find_package(minizip ${minizip_FIND_VERSION} CONFIG QUIET) - endif() - - if (minizip_FOUND) - get_target_property(minizip_INCLUDE_DIR MINIZIP::minizip INTERFACE_INCLUDE_DIRECTORIES) - get_target_property(minizip_LIBRARY MINIZIP::minizip LOCATION) - - if (NOT minizip_LIBRARY) - # Lib names to search for - set(_minizip_LIB_NAMES minizip) - - if(BUILD_TYPE_DEBUG) - # Prefer Debug lib names (Windows only) - list(INSERT _minizip_LIB_NAMES 0 minizipd) - endif() - - if(minizip_STATIC_LIBRARY) - # Prefer static lib names - set(_minizip_STATIC_LIB_NAMES - "${CMAKE_STATIC_LIBRARY_PREFIX}minizip${CMAKE_STATIC_LIBRARY_SUFFIX}") - if(WIN32 AND BUILD_TYPE_DEBUG) - # Prefer static Debug lib names (Windows only) - list(INSERT _minizip_STATIC_LIB_NAMES 0 - "${CMAKE_STATIC_LIBRARY_PREFIX}minizipd${CMAKE_STATIC_LIBRARY_SUFFIX}") - endif() - endif() - - # Find library - find_library(minizip_LIBRARY - NAMES - ${_minizip_STATIC_LIB_NAMES} - ${_minizip_LIB_NAMES} - HINTS - ${minizip_ROOT} - ${PC_minizip_LIBRARY_DIRS} - PATH_SUFFIXES - lib64 lib - ) - endif() - else() - list(APPEND _minizip_REQUIRED_VARS minizip_INCLUDE_DIR) - - # Search for minizip.pc - find_package(PkgConfig QUIET) - pkg_check_modules(PC_minizip QUIET "minizip>=${minizip_FIND_VERSION}") - - # Find include directory - find_path(minizip_INCLUDE_DIR - NAMES - mz.h - HINTS - ${minizip_ROOT} - ${PC_minizip_INCLUDE_DIRS} - PATH_SUFFIXES - include - minizip/include - ) - - # Lib names to search for - set(_minizip_LIB_NAMES minizip) - - if(BUILD_TYPE_DEBUG) - # Prefer Debug lib names (Windows only) - list(INSERT _minizip_LIB_NAMES 0 minizipd) - endif() - - if(minizip_STATIC_LIBRARY) - # Prefer static lib names - set(_minizip_STATIC_LIB_NAMES - "${CMAKE_STATIC_LIBRARY_PREFIX}minizip${CMAKE_STATIC_LIBRARY_SUFFIX}") - if(WIN32 AND BUILD_TYPE_DEBUG) - # Prefer static Debug lib names (Windows only) - list(INSERT _minizip_STATIC_LIB_NAMES 0 - "${CMAKE_STATIC_LIBRARY_PREFIX}minizipd${CMAKE_STATIC_LIBRARY_SUFFIX}") - endif() - endif() - - # Find library - find_library(minizip_LIBRARY - NAMES - ${_minizip_STATIC_LIB_NAMES} - ${_minizip_LIB_NAMES} - HINTS - ${minizip_ROOT} - ${PC_minizip_LIBRARY_DIRS} - PATH_SUFFIXES - lib64 - lib - ) - - # Get version from header or pkg-config - set(minizip_VERSION "${minizip_FIND_VERSION}") - endif() - - # Override REQUIRED if package can be installed - if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) - set(minizip_FIND_REQUIRED FALSE) - endif() - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(minizip - REQUIRED_VARS - minizip_LIBRARY - minizip_INCLUDE_DIR - VERSION_VAR - minizip_VERSION - ) -endif() - -############################################################################### -### Create target - -if(minizip_FOUND AND NOT TARGET MINIZIP::minizip-ng) - add_library(MINIZIP::minizip-ng UNKNOWN IMPORTED GLOBAL) - set(_minizip_TARGET_CREATE TRUE) -endif() - -############################################################################### - -############################################################################### -### Configure target ### - -if(minizip_FOUND AND _minizip_TARGET_CREATE) - set_target_properties(MINIZIP::minizip-ng PROPERTIES - IMPORTED_LOCATION "${minizip_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${minizip_INCLUDE_DIR}" - ) - - # This is still minizip-ng even though the library is called minizip because of MZ_COMPAT=ON. - set(minizip-ng_LIBRARY ${minizip_LIBRARY}) - set(minizip-ng_INCLUDE_DIR ${minizip_INCLUDE_DIR}) - set(minizip-ng_FOUND ${minizip_FOUND}) - set(minizip-ng_VERSION ${minizip_VERSION}) - - mark_as_advanced(minizip_INCLUDE_DIR minizip_LIBRARY minizip_VERSION) - - target_link_libraries(MINIZIP::minizip-ng INTERFACE ZLIB::ZLIB) -endif() \ No newline at end of file diff --git a/share/cmake/modules/Findopenfx.cmake b/share/cmake/modules/Findopenfx.cmake index f989e0f7ae..8b0eefb344 100644 --- a/share/cmake/modules/Findopenfx.cmake +++ b/share/cmake/modules/Findopenfx.cmake @@ -58,7 +58,7 @@ endif() ############################################################################### ### Install package from source ### -if(NOT openfx_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) +if(NOT openfx_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) include(ExternalProject) include(GNUInstallDirs) diff --git a/share/cmake/modules/Findpybind11.cmake b/share/cmake/modules/Findpybind11.cmake index 316496096c..e6c2f35a86 100644 --- a/share/cmake/modules/Findpybind11.cmake +++ b/share/cmake/modules/Findpybind11.cmake @@ -134,7 +134,7 @@ endif() ############################################################################### ### Install package from source ### -if(NOT pybind11_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) +if(NOT pybind11_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) include(ExternalProject) include(GNUInstallDirs) diff --git a/share/cmake/modules/Findpystring.cmake b/share/cmake/modules/Findpystring.cmake index 702ac1e812..bbd5e1fd27 100644 --- a/share/cmake/modules/Findpystring.cmake +++ b/share/cmake/modules/Findpystring.cmake @@ -66,7 +66,7 @@ endif() ############################################################################### ### Install package from source ### -if(NOT pystring_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) +if(NOT pystring_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) include(ExternalProject) set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") @@ -127,14 +127,6 @@ if(NOT pystring_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) -DANDROID_STL=${ANDROID_STL}) endif() - if(NOT BUILD_SHARED_LIBS) - #TODO: Find a way to merge in the static libs when built with internal pystring - message(WARNING - "Building STATIC libOpenColorIO using the in-built pystring. " - "pystring symbols are NOT included in the output binary!" - ) - endif() - # Hack to let imported target be built from ExternalProject_Add file(MAKE_DIRECTORY ${pystring_INCLUDE_DIR}) diff --git a/share/cmake/modules/Findyaml-cpp.cmake b/share/cmake/modules/Findyaml-cpp.cmake index 023e14fc07..59558ce6a9 100644 --- a/share/cmake/modules/Findyaml-cpp.cmake +++ b/share/cmake/modules/Findyaml-cpp.cmake @@ -25,6 +25,15 @@ ############################################################################### ### Try to find package ### +# BUILD_TYPE_DEBUG variable is currently set in one of the OCIO's CMake files. +# Now that some OCIO's find module are installed with the library itself (with static build), +# a consumer app don't have access to the variables set by an OCIO's CMake files. Therefore, some +# OCIO's find modules must detect the build type by itselves. +set(BUILD_TYPE_DEBUG OFF) +if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]") + set(BUILD_TYPE_DEBUG ON) +endif() + if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) set(_yaml-cpp_REQUIRED_VARS yaml-cpp_LIBRARY) @@ -66,22 +75,21 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) # Lib names to search for set(_yaml-cpp_LIB_NAMES yaml-cpp) - if(WIN32 AND BUILD_TYPE_DEBUG AND NOT MINGW) - # Prefer Debug lib names (Windows only) + if(BUILD_TYPE_DEBUG) + # Prefer Debug lib names. list(INSERT _yaml-cpp_LIB_NAMES 0 yaml-cppd) endif() if(yaml-cpp_STATIC_LIBRARY) # Prefer static lib names - if(WIN32 AND NOT MINGW) - set(_yaml-cpp_LIB_SUFFIX "md") - endif() set(_yaml-cpp_STATIC_LIB_NAMES - "libyaml-cpp${_yaml-cpp_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") - if(WIN32 AND BUILD_TYPE_DEBUG AND NOT MINGW) - # Prefer static Debug lib names (Windows only) + "${CMAKE_STATIC_LIBRARY_PREFIX}yaml-cpp${CMAKE_STATIC_LIBRARY_SUFFIX}") + + # Starting from 0.7.0, all platforms uses the suffix "d" for debug. + # See https://github.com/jbeder/yaml-cpp/blob/master/CMakeLists.txt#L141 + if(BUILD_TYPE_DEBUG) list(INSERT _yaml-cpp_STATIC_LIB_NAMES 0 - "libyaml-cpp${_yaml-cpp_LIB_SUFFIX}d${CMAKE_STATIC_LIBRARY_SUFFIX}") + "${CMAKE_STATIC_LIBRARY_PREFIX}yaml-cppd${CMAKE_STATIC_LIBRARY_SUFFIX}") endif() endif() @@ -91,7 +99,7 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) ${_yaml-cpp_STATIC_LIB_NAMES} ${_yaml-cpp_LIB_NAMES} HINTS - ${_yaml-cpp_ROOT} + ${yaml-cpp_ROOT} ${PC_yaml-cpp_LIBRARY_DIRS} PATH_SUFFIXES lib64 @@ -130,7 +138,7 @@ endif() ############################################################################### ### Install package from source ### -if(NOT yaml-cpp_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) +if(NOT yaml-cpp_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) include(ExternalProject) include(GNUInstallDirs) @@ -213,14 +221,6 @@ if(NOT yaml-cpp_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) -DANDROID_STL=${ANDROID_STL}) endif() - if(NOT BUILD_SHARED_LIBS) - #TODO: Find a way to merge in the static libs when built with internal yamlcpp - message(WARNING - "Building STATIC libOpenColorIO using the in-built yaml-cpp. " - "yaml-cpp symbols are NOT included in the output binary!" - ) - endif() - set(yaml-cpp_GIT_TAG "yaml-cpp-${yaml-cpp_VERSION}") # Hack to let imported target be built from ExternalProject_Add diff --git a/share/cmake/modules/Findzlib.cmake b/share/cmake/modules/InstallZLIB.cmake similarity index 73% rename from share/cmake/modules/Findzlib.cmake rename to share/cmake/modules/InstallZLIB.cmake index 546cea341a..954563ec4e 100644 --- a/share/cmake/modules/Findzlib.cmake +++ b/share/cmake/modules/InstallZLIB.cmake @@ -1,75 +1,58 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. # -# Locate or install minizip-ng +# Install ZLIB +# +# Except for the variable ZLIB_VERSION_STRING, OCIO sets the same variables as the +# CMake's FindZLIB when installing ZLIB manually. # # Variables defined by this module: -# ZLIB_FOUND - If FALSE, do not try to link to minizip-ng +# ZLIB_FOUND - If FALSE, do not try to link to zlib # ZLIB_LIBRARIES - ZLIB library to link to # ZLIB_INCLUDE_DIRS - Where to find zlib.h and other headers # ZLIB_VERSION - The version of the library # # Targets defined by this module: -# ZLIB::ZLIB - IMPORTED target, if found -# -# This module is named GetZLIB because it is not used with find_package(). -# It must be included using include(). -# -# The reason is that CMake provide a FindZLIB already and the current file is -# using it. +# ZLIB::ZLIB - Properties: +# IMPORTED_LOCATION ${ZLIB_LIBRARIES} +# INTERFACE_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRS} # ############################################################################### -### Try to find package ### - -# Assign the rigtt name for ZLIB depending on the OS. -if(WIN32) - set(_ZLIB_LIB_NAME "zlib") - set(_ZLIB_STATIC_LIB_NAME "zlibstatic") -else() - set(_ZLIB_LIB_NAME "z") - set(_ZLIB_STATIC_LIB_NAME "z") -endif() - -if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) - set(_ZLIB_REQUIRED_VARS ZLIB_LIBRARIES) - - if(NOT DEFINED ZLIB_ROOT) - # Save old value of CMAKE_MODULE_PATH - set(_ZLIB__CMAKE_MODULE_PATH_OLD_ ${CMAKE_MODULE_PATH}) - # Force find_package to use CMAKE module and not custom modules. - set(CMAKE_MODULE_PATH "${CMAKE_ROOT}/Modules") - - # Use CMake FindZLIB module - find_package(ZLIB ${zlib_FIND_VERSION}) - - # Restore CMAKE_MODULE_PATH - set(CMAKE_MODULE_PATH ${_ZLIB__CMAKE_MODULE_PATH_OLD_}) - endif() -endif() ############################################################################### ### Create target - +############################################################################### if(NOT TARGET ZLIB::ZLIB) + add_library(ZLIB::ZLIB UNKNOWN IMPORTED GLOBAL) set(_ZLIB_TARGET_CREATE TRUE) endif() ############################################################################### -### Install package from source ### -if(NOT ZLIB_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) +### Install package from source +############################################################################### +if(NOT ZLIB_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) include(ExternalProject) include(GNUInstallDirs) set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") + if(WIN32) + set(_ZLIB_LIB_NAME "zlib") + set(_ZLIB_STATIC_LIB_NAME "zlibstatic") + else() + set(_ZLIB_LIB_NAME "z") + set(_ZLIB_STATIC_LIB_NAME "z") + endif() + # Set find_package standard args set(ZLIB_FOUND TRUE) - if(_zlib_ExternalProject_VERSION) - set(ZLIB_VERSION ${_zlib_ExternalProject_VERSION}) + if(_ZLIB_ExternalProject_VERSION) + set(ZLIB_VERSION ${_ZLIB_ExternalProject_VERSION}) else() - set(ZLIB_VERSION ${zlib_FIND_VERSION}) + set(ZLIB_VERSION ${ZLIB_FIND_VERSION}) endif() + set(ZLIB_INCLUDE_DIRS "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") # Windows need the "d" suffix at the end. @@ -149,22 +132,19 @@ if(NOT ZLIB_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) COMMAND ${CMAKE_COMMAND} -E remove -f ${_EXT_DIST_ROOT}/${_ZLIB_INSTALL_LIBDIR}/zlib.lib ${_EXT_DIST_ROOT}/bin/zlib.dll ) - add_library(ZLIB::ZLIB STATIC IMPORTED GLOBAL) add_dependencies(ZLIB::ZLIB ZLIB_install) - set_property(TARGET ZLIB::ZLIB PROPERTY - IMPORTED_LOCATION "${ZLIB_LIBRARIES}" - ) - target_include_directories(ZLIB::ZLIB INTERFACE "${CMAKE_INSTALL_BINDIR}/include") - + + # Setting those variables to follow the same naming as the other OCIO custom find modules. set(ZLIB_LIBRARY ${ZLIB_LIBRARIES}) set(ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIRS}) message(STATUS "Installing ZLIB: ${ZLIB_LIBRARIES} (version \"${ZLIB_VERSION}\")") endif() + ############################################################################### ### Configure target ### - +############################################################################### if(_ZLIB_TARGET_CREATE) set_target_properties(ZLIB::ZLIB PROPERTIES IMPORTED_LOCATION ${ZLIB_LIBRARIES} diff --git a/src/cmake/Config.cmake.in b/src/cmake/Config.cmake.in index feabdeb2e3..6a4932a836 100644 --- a/src/cmake/Config.cmake.in +++ b/src/cmake/Config.cmake.in @@ -2,6 +2,129 @@ include(CMakeFindDependencyMacro) +if (NOT @BUILD_SHARED_LIBS@) # NOT @BUILD_SHARED_LIBS@ + if (APPLE) + # Store the previous value of CMAKE_FIND_FRAMEWORK and CMAKE_FIND_APPBUNDLE. + set(_PREVIOUS_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK}) + set(_PREVIOUS_CMAKE_FIND_APPBUNDLE ${CMAKE_FIND_APPBUNDLE}) + + # Prioritize other paths before Frameworks and Appbundle for find_path, find_library and + # find_package. + set(CMAKE_FIND_FRAMEWORK LAST) + set(CMAKE_FIND_APPBUNDLE LAST) + endif() + + # Get the install directory. + set(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_DIR}") + # Get the install directory. Since the current file is under + # /lib/cmake/OpenColorIO going back three directory. + foreach(i RANGE 1 3) + get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) + if(_IMPORT_PREFIX STREQUAL "/") + set(_IMPORT_PREFIX "") + break() + endif() + endforeach() + + # Append OCIO custom find module path. + list(APPEND CMAKE_MODULE_PATH "${_IMPORT_PREFIX}/share/OpenColorIO/cmake/modules") + list(APPEND CMAKE_MODULE_PATH "${_IMPORT_PREFIX}/share/OpenColorIO/cmake/macros") + + ######################## + # Required dependencies + ######################## + + if (NOT expat::expat) + find_dependency(expat @expat_VERSION@) + endif() + + if (NOT Imath::Imath) + find_dependency(Imath @Imath_VERSION@) + endif() + + if (NOT pystring::pystring) + find_dependency(pystring @pystring_VERSION@) + endif() + + if (NOT yaml-cpp) + find_dependency(yaml-cpp @yaml-cpp_VERSION@) + endif() + + if (NOT ZLIB::ZLIB) + # ZLIB_VERSION is available starting CMake 3.26+. + # ZLIB_VERSION_STRING is still available for backward compatibility. + # See https://cmake.org/cmake/help/git-stage/module/FindZLIB.html + + # ZLIB_USE_STATIC_LIBS is supported only from CMake 3.24+. + if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0") + if (ZLIB_STATIC_LIBRARY) + set(ZLIB_USE_STATIC_LIBS "${ZLIB_STATIC_LIBRARY}") + endif() + else() # For CMake < 3.24 since ZLIB_USE_STATIC_LIBS is not available. + if(NOT ZLIB_LIBRARY) + if(DEFINED CMAKE_FIND_LIBRARY_PREFIXES) + set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") + else() + set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES) + endif() + + if(DEFINED CMAKE_FIND_LIBRARY_SUFFIXES) + set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}") + else() + set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + endif() + + # Prefix/suffix for windows. + if(WIN32) + list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "" "lib") + list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a") + endif() + + # Check if static lib is preferred. + if(ZLIB_STATIC_LIBRARY OR ZLIB_USE_STATIC_LIBS) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a) + endif() + endif() + endif() + endif() + + if (@ZLIB_VERSION@) # @ZLIB_VERSION@ + find_dependency(ZLIB @ZLIB_VERSION@) + else() + find_dependency(ZLIB @ZLIB_VERSION_STRING@) + endif() + + # Restore the original find library ordering + if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}") + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES) + endif() + + if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES) + set(CMAKE_FIND_LIBRARY_PREFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES}") + else() + set(CMAKE_FIND_LIBRARY_PREFIXES) + endif() + endif() + + if (NOT MINIZIP::minizip-ng) + find_dependency(minizip-ng @minizip-ng_VERSION@) + endif() + + # Remove OCIO custom find module path. + list(REMOVE_AT CMAKE_MODULE_PATH -1) + + if (APPLE) + # Restore CMAKE_FIND_FRAMEWORK and CMAKE_FIND_APPBUNDLE values. + set(CMAKE_FIND_FRAMEWORK ${_PREVIOUS_CMAKE_FIND_FRAMEWORK}) + set(CMAKE_FIND_APPBUNDLE ${_PREVIOUS_CMAKE_FIND_APPBUNDLE}) + endif() +endif() + include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake) include(FindPackageHandleStandardArgs)