Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions docs/quick_start/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,18 @@ this script on Windows.
Automated Installation
++++++++++++++++++++++

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.
Dependencies listed above with a preceeding * can be automatically installed at
configure time using the ``OCIO_INSTALL_EXT_PACKAGES`` option in your ``cmake``
command (requires an internet connection). The C/C++ libraries are downloaded from
their official releases, built, and are (typically) statically-linked into an OCIO
dynamic library. All installs of these components are fully contained within your
build directory: they are installed in ``<build>/ext/dist``, along with the CMake
configuration files of each package, and are then located with ``find_package``.
Subsequent CMake runs reuse them unless their build settings change.

To build a dependency from local sources instead of downloading it (e.g. on a
machine without internet access), set ``OCIO_<package>_SOURCE_DIR`` to the
location of the extracted sources, e.g. ``-DOCIO_yaml-cpp_SOURCE_DIR=<path>``.

Three ``OCIO_INSTALL_EXT_PACKAGES`` options are available::

Expand Down
31 changes: 18 additions & 13 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,27 @@
from setuptools.command.build_ext import build_ext


# Extract the project version from CMake generated ABI header.
# Extract the project version from the top level CMakeLists.txt, the same way CMake builds
# OCIO_VERSION_FULL_STR in OpenColorABI.h. Running a CMake configuration instead would build the
# missing dependencies at configure time.
def get_version():
VERSION_REGEX = re.compile(
r"^\s*#\s*define\s+OCIO_VERSION_FULL_STR\s+\"(.*)\"\s*$", re.MULTILINE)
r"^\s*project\(\s*OpenColorIO\s+VERSION\s+([0-9.]+)\s", re.MULTILINE)
RELEASE_TYPE_REGEX = re.compile(
r"^\s*set\(\s*OpenColorIO_VERSION_RELEASE_TYPE\s+\"(.*)\"\s*\)", re.MULTILINE)

here = os.path.abspath(os.path.dirname(__file__))

with tempfile.TemporaryDirectory() as tmpdir:
try:
subprocess.check_call(["cmake", here], cwd=tmpdir)
path = os.path.join(tmpdir, "include", "OpenColorIO", "OpenColorABI.h")
with open(path) as f:
match = VERSION_REGEX.search(f.read())
return match.group(1)
except Exception as e:
raise RuntimeError(
"Unable to find OpenColorIO version: {}".format(str(e))
)
try:
with open(os.path.join(here, "CMakeLists.txt")) as f:
content = f.read()
version = VERSION_REGEX.search(content).group(1)
release_type = RELEASE_TYPE_REGEX.search(content).group(1)
return version + release_type
except Exception as e:
raise RuntimeError(
"Unable to find OpenColorIO version: {}".format(str(e))
)


# Call CMake find_package from a dummy script and return whether the package
Expand Down Expand Up @@ -146,6 +149,8 @@ def build_extension(self, ext):
cmake_args += [
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), extdir),
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_{}={}".format(cfg.upper(), bindir),
# Only the requested configuration of the dependencies is needed.
"-DCMAKE_CONFIGURATION_TYPES={}".format(cfg),
]
build_args += ["--config", cfg]

Expand Down
6 changes: 2 additions & 4 deletions share/ci/scripts/multi/install_lcms2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ else
git checkout tags/lcms${LCMS2_VERSION} -b lcms${LCMS2_VERSION}
fi

cp ../share/cmake/projects/Buildlcms2.cmake CMakeLists.txt

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release \
${INSTALL_TARGET:+"-DCMAKE_INSTALL_PREFIX="${INSTALL_TARGET}""} \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
../.
-DOCIO_DEP_SOURCE_DIR="$(pwd)/.." \
../../share/cmake/projects/lcms2
cmake --build . \
--target install \
--config Release \
Expand Down
6 changes: 2 additions & 4 deletions share/ci/scripts/multi/install_pystring.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ else
git checkout tags/v${PYSTRING_VERSION} -b v${PYSTRING_VERSION}
fi

cp ../share/cmake/projects/Buildpystring.cmake CMakeLists.txt

mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release \
${INSTALL_TARGET:+"-DCMAKE_INSTALL_PREFIX="${INSTALL_TARGET}""} \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
../.
-DOCIO_DEP_SOURCE_DIR="$(pwd)/.." \
../../share/cmake/projects/pystring
cmake --build . \
--target install \
--config Release \
Expand Down
26 changes: 26 additions & 0 deletions share/cmake/deps/Imath.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.
#
# Build Imath
#
# Global targets defined by the Imath CMake configuration files:
# Imath::Imath
# Imath::ImathConfig
#

set(_Imath_URL_HASH_3.2.1 "SHA256=b2c8a44c3e4695b74e9644c76f5f5480767355c6f98cde58ba0e82b4ad8c63ce")

set(_Imath_VERSION ${OCIO_Imath_RECOMMENDED_VERSION})

ocio_build_dependency(Imath
VERSION ${_Imath_VERSION}
URL "https://github.com/AcademySoftwareFoundation/Imath/archive/refs/tags/v${_Imath_VERSION}.tar.gz"
URL_HASH "${_Imath_URL_HASH_${_Imath_VERSION}}"
CMAKE_ARGS
-DBUILD_TESTING=OFF
-DPYTHON=OFF
-DDOCS=OFF
-DIMATH_HALF_USE_LOOKUP_TABLE=OFF
)

ocio_find_built_dependency(Imath ${_Imath_VERSION} EXACT)
47 changes: 47 additions & 0 deletions share/cmake/deps/OpenEXR.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.
#
# Build OpenEXR
#
# Global targets defined by the OpenEXR CMake configuration files:
# OpenEXR::OpenEXR
# OpenEXR::OpenEXRCore
# OpenEXR::OpenEXRUtil
# OpenEXR::Iex
# OpenEXR::IlmThread
# (and their *Config interface targets)
#
# Depending on user options when configuring OCIO, OpenEXR can be used to
# build libOpenColorIOimageioapphelpers.
#

set(_OpenEXR_URL_HASH_3.4.0 "SHA256=d7b31637d7adc359f5e5a7517ba918cb5997bc1a4ae7a808ec874cdf91da93c0")

set(_OpenEXR_VERSION ${OCIO_OpenEXR_RECOMMENDED_VERSION})

set(_OpenEXR_CMAKE_ARGS
-DBUILD_TESTING=OFF
-DOPENEXR_BUILD_EXAMPLES=OFF
-DOPENEXR_BUILD_TOOLS=OFF
-DOPENEXR_INSTALL_PKG_CONFIG=OFF
-DOPENEXR_FORCE_INTERNAL_DEFLATE=ON
-DOPENEXR_FORCE_INTERNAL_OPENJPH=ON
# OpenEXR 3.4.0 would use OpenJPH 0.22.0 by default, request the latest version at release
# time including build fixes.
-DOPENEXR_OPENJPH_TAG=0.23.1
)

# Build against the Imath used by OCIO, otherwise OpenEXR would download its own copy, which might
# result in version conflicts. An Imath built by OCIO is found through CMAKE_PREFIX_PATH.
if(Imath_DIR)
list(APPEND _OpenEXR_CMAKE_ARGS -DImath_DIR=${Imath_DIR})
endif()

ocio_build_dependency(OpenEXR
VERSION ${_OpenEXR_VERSION}
URL "https://github.com/AcademySoftwareFoundation/openexr/archive/refs/tags/v${_OpenEXR_VERSION}.tar.gz"
URL_HASH "${_OpenEXR_URL_HASH_${_OpenEXR_VERSION}}"
CMAKE_ARGS ${_OpenEXR_CMAKE_ARGS}
)

ocio_find_built_dependency(OpenEXR ${_OpenEXR_VERSION} EXACT)
74 changes: 74 additions & 0 deletions share/cmake/deps/ZLIB.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.
#
# Build ZLIB
#
# Global targets defined by CMake's FindZLIB module:
# ZLIB::ZLIB
#

set(_ZLIB_URL_HASH_1.3.1 "SHA256=9a93b2b7dfdac77ceba5a558a580e74667dd6fede4585b91eefb60f03b72df23")

set(_ZLIB_VERSION ${OCIO_ZLIB_RECOMMENDED_VERSION})

ocio_build_dependency(ZLIB
VERSION ${_ZLIB_VERSION}
URL "https://github.com/madler/zlib/releases/download/v${_ZLIB_VERSION}/zlib-${_ZLIB_VERSION}.tar.gz"
URL_HASH "${_ZLIB_URL_HASH_${_ZLIB_VERSION}}"
CMAKE_ARGS
# ZLIB requires an old CMake version that has no knowledge of this policy.
-DCMAKE_POLICY_DEFAULT_CMP0042=NEW
-DZLIB_BUILD_EXAMPLES=OFF
)

# ZLIB 1.3.1 always installs both a shared and a static library. Remove the shared one, so that
# anything searching ZLIB in ${OCIO_EXT_DIST_ROOT} (e.g. minizip-ng, or consumers of a static
# OCIO) uses the static library OCIO links with. The shared library is named zlib on Windows.
foreach(_ZLIB_NAME z zd zlib zlibd)
file(GLOB _ZLIB_SHARED_FILES
"${OCIO_EXT_DIST_ROOT}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}${_ZLIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}*"
"${OCIO_EXT_DIST_ROOT}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}${_ZLIB_NAME}.*${CMAKE_SHARED_LIBRARY_SUFFIX}"
"${OCIO_EXT_DIST_ROOT}/bin/${CMAKE_SHARED_LIBRARY_PREFIX}${_ZLIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}")
if(WIN32)
# Import library of the DLL.
list(APPEND _ZLIB_SHARED_FILES
"${OCIO_EXT_DIST_ROOT}/lib/${CMAKE_IMPORT_LIBRARY_PREFIX}${_ZLIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX}")
endif()
if(_ZLIB_SHARED_FILES)
file(REMOVE ${_ZLIB_SHARED_FILES})
endif()
endforeach()

# Discard the results of a previous search, e.g. a system ZLIB rejected for being too old, as
# find_library and find_path don't search again when the cache variables are already set.
foreach(_ZLIB_VAR ZLIB_LIBRARY ZLIB_LIBRARY_RELEASE ZLIB_LIBRARY_DEBUG ZLIB_INCLUDE_DIR)
unset(${_ZLIB_VAR})
unset(${_ZLIB_VAR} CACHE)
endforeach()

# ZLIB 1.3.1 doesn't provide CMake configuration files. Point CMake's FindZLIB module to the static
# library, as it would do with ZLIB_USE_STATIC_LIBS (CMake 3.24+). The static library is named
# zlibstatic on Windows.
set(_ZLIB_NAMES z zlibstatic)
foreach(_ZLIB_CONFIG RELEASE DEBUG)
set(_ZLIB_STATIC_NAMES "")
foreach(_ZLIB_NAME ${_ZLIB_NAMES})
list(APPEND _ZLIB_STATIC_NAMES
"${CMAKE_STATIC_LIBRARY_PREFIX}${_ZLIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}")
endforeach()

find_library(ZLIB_LIBRARY_${_ZLIB_CONFIG}
NAMES ${_ZLIB_STATIC_NAMES}
PATHS "${OCIO_EXT_DIST_ROOT}/lib"
NO_DEFAULT_PATH)

# The Debug library has a "d" suffix.
list(TRANSFORM _ZLIB_NAMES APPEND "d")
endforeach()

find_path(ZLIB_INCLUDE_DIR
NAMES zlib.h
PATHS "${OCIO_EXT_DIST_ROOT}/include"
NO_DEFAULT_PATH)

find_package(ZLIB ${_ZLIB_VERSION} EXACT MODULE REQUIRED)
37 changes: 37 additions & 0 deletions share/cmake/deps/expat.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.
#
# Build expat
#
# Global targets defined by the expat CMake configuration files:
# expat::expat
#

set(_expat_URL_HASH_2.7.2 "SHA256=21b778b34ec837c2ac285aef340f9fb5fa063a811b21ea4d2412a9702c88995c")

set(_expat_VERSION ${OCIO_expat_RECOMMENDED_VERSION})
string(REPLACE "." "_" _expat_TAG "R_${_expat_VERSION}")

set(_expat_CMAKE_ARGS
-DEXPAT_BUILD_DOCS=OFF
-DEXPAT_BUILD_EXAMPLES=OFF
-DEXPAT_BUILD_TESTS=OFF
-DEXPAT_BUILD_TOOLS=OFF
-DEXPAT_SHARED_LIBS=OFF
)

# expat ignores CMAKE_DEBUG_POSTFIX and only uses a Debug postfix on Windows. With multi-config
# generators, the Debug and Release libraries must not collide.
get_property(_expat_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_expat_IS_MULTI_CONFIG AND NOT WIN32)
list(APPEND _expat_CMAKE_ARGS -DEXPAT_DEBUG_POSTFIX=d)
endif()

ocio_build_dependency(expat
VERSION ${_expat_VERSION}
URL "https://github.com/libexpat/libexpat/releases/download/${_expat_TAG}/expat-${_expat_VERSION}.tar.xz"
URL_HASH "${_expat_URL_HASH_${_expat_VERSION}}"
CMAKE_ARGS ${_expat_CMAKE_ARGS}
)

ocio_find_built_dependency(expat ${_expat_VERSION} EXACT)
22 changes: 22 additions & 0 deletions share/cmake/deps/lcms2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.
#
# Build lcms2
#
# Global targets defined by the lcms2 CMake configuration files:
# lcms2::lcms2
#

set(_lcms2_URL_HASH_2.17 "SHA256=6e6f6411db50e85ae8ff7777f01b2da0614aac13b7b9fcbea66dc56a1bc71418")

set(_lcms2_VERSION ${OCIO_lcms2_RECOMMENDED_VERSION})

# Little-CMS only provides Autotools and Meson builds.
ocio_build_dependency(lcms2
VERSION ${_lcms2_VERSION}
URL "https://github.com/mm2/Little-CMS/archive/refs/tags/lcms${_lcms2_VERSION}.tar.gz"
URL_HASH "${_lcms2_URL_HASH_${_lcms2_VERSION}}"
PROJECT_DIR "${PROJECT_SOURCE_DIR}/share/cmake/projects/lcms2"
)

ocio_find_built_dependency(lcms2 ${_lcms2_VERSION} EXACT)
61 changes: 61 additions & 0 deletions share/cmake/deps/minizip-ng.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.
#
# Build minizip-ng
#
# Global targets defined by the minizip-ng CMake configuration files:
# MINIZIP::minizip-ng
#
# Link against the following target:
# ZLIB::ZLIB
#

set(_minizip-ng_URL_HASH_4.0.10 "SHA256=c362e35ee973fa7be58cc5e38a4a6c23cc8f7e652555daf4f115a9eb2d3a6be7")

set(_minizip-ng_VERSION ${OCIO_minizip-ng_RECOMMENDED_VERSION})

set(_minizip-ng_CMAKE_ARGS
-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
-DCMAKE_DISABLE_FIND_PACKAGE_ZLIBNG=ON
)

# Build against the ZLIB used by OCIO (minizip-ng records the library path in its exported
# targets). Pass the per-configuration libraries to support multi-config generators.
get_target_property(_minizip-ng_ZLIB_INCLUDE_DIRS ZLIB::ZLIB INTERFACE_INCLUDE_DIRECTORIES)
list(GET _minizip-ng_ZLIB_INCLUDE_DIRS 0 _minizip-ng_ZLIB_INCLUDE_DIR)
list(APPEND _minizip-ng_CMAKE_ARGS -DZLIB_INCLUDE_DIR=${_minizip-ng_ZLIB_INCLUDE_DIR})

get_target_property(_minizip-ng_ZLIB_LOCATION ZLIB::ZLIB IMPORTED_LOCATION)
if(_minizip-ng_ZLIB_LOCATION)
list(APPEND _minizip-ng_CMAKE_ARGS -DZLIB_LIBRARY=${_minizip-ng_ZLIB_LOCATION})
endif()
foreach(_minizip-ng_CONFIG RELEASE DEBUG)
get_target_property(_minizip-ng_ZLIB_LOCATION ZLIB::ZLIB IMPORTED_LOCATION_${_minizip-ng_CONFIG})
if(_minizip-ng_ZLIB_LOCATION)
list(APPEND _minizip-ng_CMAKE_ARGS
-DZLIB_LIBRARY_${_minizip-ng_CONFIG}=${_minizip-ng_ZLIB_LOCATION})
endif()
endforeach()

ocio_build_dependency(minizip-ng
VERSION ${_minizip-ng_VERSION}
URL "https://github.com/zlib-ng/minizip-ng/archive/refs/tags/${_minizip-ng_VERSION}.tar.gz"
URL_HASH "${_minizip-ng_URL_HASH_${_minizip-ng_VERSION}}"
CMAKE_ARGS ${_minizip-ng_CMAKE_ARGS}
)

ocio_find_built_dependency(minizip-ng ${_minizip-ng_VERSION} EXACT)
Loading
Loading