Skip to content

Commit a2e204b

Browse files
Adsk contrib - Scripts to facilitate building OCIO on Windows (#1646)
* Scripts to facilitate OCIO builds on Windows Signed-off-by: Cedrik Fuoco <[email protected]> * Fixed an issue with spaces in python path Signed-off-by: Cedrik Fuoco <[email protected]> * Using delayed variable expansion instead of normal expansion for variables that can changes based on arguments Signed-off-by: Cedrik Fuoco <[email protected]> * Updating the quick start > installations documentation to mention the windows scripts and re-writing obsolete section. Signed-off-by: Cedrik Fuoco <[email protected]> Co-authored-by: Doug Walker <[email protected]>
1 parent b80361c commit a2e204b

File tree

4 files changed

+828
-140
lines changed

4 files changed

+828
-140
lines changed

docs/quick_start/installation.rst

Lines changed: 88 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,70 @@
55
.. _installation:
66

77
Installation
8-
============
9-
10-
The easy way
118
************
129

13-
While prebuilt binaries are not yet available for all platforms, OCIO
14-
is available via several platform's package managers.
10+
Although OpenColorIO is available through a variety of package managers, please note that the
11+
version available through a given package manager may be significantly outdated when compared to
12+
the current official OCIO release. Even two years after the introduction of OpenColorIO v2, several
13+
package managers continue to install OCIO 1.1.1.
14+
15+
.. _Python:
16+
17+
Python
18+
^^^^^^
19+
20+
If you only need the Python bindings, the simplest solution is to take advantage of the pre-built
21+
wheels in the Python Package Installer (PyPi) `here <https://pypi.org/project/opencolorio>`__. It
22+
can be installed by using this command::
23+
24+
pip install opencolorio
25+
26+
OpenImageIO
27+
^^^^^^^^^^^
28+
29+
If you only need to apply color conversions to images, please note that OpenImageIO's oiiotool has
30+
most of the functionality of the ocioconvert command-line tool (although not everything, such as
31+
GPU processing). OpenImageIO is available via several package managers (including brew and vcpkg).
32+
33+
**Homebrew**::
34+
35+
brew install openimageio
1536

16-
Please note that the package managers are still installing the previous
17-
stable release, 1.1.1. If you want OCIO v2, you currently must build from source.
18-
See :ref:`building-from-source`.
37+
**Vcpkg**::
1938

39+
vcpkg install openimageio[opencolorio,tools]:x64-windows --recurse
2040

21-
Fedora and RHEL
22-
^^^^^^^^^^^^^^^
41+
Installing OpenColorIO using existing packages
42+
**********************************************
2343

24-
In Fedora Core 15 and above, the following command will install OpenColorIO::
44+
Linux
45+
^^^^^
2546

26-
yum install OpenColorIO
47+
When it comes to Linux distributions, relatively few of the Linux distribution repositories have been
48+
updated to OCIO v2. The **latest Fedora** is one good option as it offers the most
49+
recent release of OpenColorIO v2. Information about the package can be found on
50+
`fedoraproject website <https://packages.fedoraproject.org/pkgs/OpenColorIO/OpenColorIO/index.html>`__.
2751

28-
Providing you are using the `Fedora EPEL repository
29-
<http://fedoraproject.org/wiki/EPEL>`__ (see the `FAQ for instructions
30-
<http://fedoraproject.org/wiki/EPEL/FAQ#Using_EPEL>`__), this same
31-
command will work for RedHat Enterprise Linux 6 and higher (including
32-
RHEL derivatives such as CentOS 6 and Scientific Linux 6)
52+
For the other distributions, information about which release of OpenColorIO is available can be
53+
verified on `pkgs.org <https://pkgs.org/search/?q=OpenColorIO>`__.
54+
55+
**The recommendation is to build OpenColorIO from source**. You may build from source using the
56+
instructions below. See :ref:`building-from-source`.
57+
58+
Windows 7 or newer using vcpkg
59+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
60+
61+
Vcpkg can be used to install OpenColorIO on Windows. In order to do that, Vcpkg must be installed
62+
by following the `official instructions <https://vcpkg.io/en/getting-started.html>`__. Once Vcpkg
63+
is installed, OpenColorIO and some of the tools can be installed with the following command::
64+
65+
vcpkg install opencolorio[tools]:x64-windows
66+
67+
Note that this package **does not** install ocioconvert, ociodisplay, ociolutimage and the Python
68+
bindings.
69+
70+
The three missing tools can be built from source by following the steps in the :ref:`Windows 7 or newer`
71+
section while the Python bindings can be install using the pip command in the :ref:`Python` section.
3372

3473
OS X using Homebrew
3574
^^^^^^^^^^^^^^^^^^^
@@ -45,18 +84,16 @@ Then simply run the following command to install::
4584

4685
brew install opencolorio
4786

48-
To build with the Python library use this command::
49-
50-
brew install opencolorio --with-python
51-
87+
Homebrew does not install the Python binding or the command-line tools that depend on OpenImageIO
88+
such as ocioconvert, ociodisplay and ociolutimage.
5289

5390
.. _building-from-source:
5491

5592
Building from source
5693
********************
5794

5895
Dependencies
59-
************
96+
^^^^^^^^^^^^
6097

6198
The basic requirements for building OCIO are the following. Note that, by
6299
default, cmake will try to install all of the items labelled with * and so
@@ -74,7 +111,7 @@ it is not necessary to install those items manually:
74111
Some optional components also depend on:
75112

76113
- \*Little CMS >= 2.2 (for ociobakelut ICC profile baking)
77-
- \*pybind11 >= 2.6.1 (for the Python bindings)
114+
- \*pybind11 >= 2.9.2 (for the Python bindings)
78115
- Python >= 2.7 (for the Python bindings)
79116
- Python 3.7 or 3.8 (for the docs, with the following PyPi packages)
80117
- Sphinx
@@ -98,7 +135,7 @@ available for all supported platforms. Use GitBash
98135
this script on Windows.
99136

100137
Automated Installation
101-
^^^^^^^^^^^^^^^^^^^^^^
138+
----------------------
102139

103140
Listed dependencies with a preceeding * can be automatically installed at
104141
build time using the ``OCIO_INSTALL_EXT_PACKAGES`` option in your cmake
@@ -119,7 +156,7 @@ Three ``OCIO_INSTALL_EXT_PACKAGES`` options are available::
119156
current system.
120157

121158
Existing Install Hints
122-
^^^^^^^^^^^^^^^^^^^^^^
159+
----------------------
123160

124161
When using existing system libraries, the following CMake variables can be
125162
defined to hint at non-standard install locations and preference of shared
@@ -209,133 +246,44 @@ this::
209246
$ ls lib/
210247
libOpenColorIO.a libOpenColorIO.dylib
211248

212-
.. _windows-build:
213-
214-
Windows Build
215-
^^^^^^^^^^^^^
216-
217-
While build environments may vary between user, here is an example batch file
218-
for compiling on Windows as provided by `@hodoulp <https://github.com/hodoulp>`__::
219-
220-
@echo off
221-
222-
223-
REM Grab the repo name, default is ocio
224-
set repo_name=ocio
225-
if not %1.==. set repo_name=%1
226-
227-
228-
REM Using cygwin to have Linux cool command line tools
229-
set CYGWIN=nodosfilewarning
230-
231-
set CMAKE_PATH=D:\OpenSource\3rdParty\cmake-3.12.2
232-
set GLUT_PATH=D:\OpenSource\3rdParty\freeglut-3.0.0-2
233-
set GLEW_PATH=D:\OpenSource\3rdParty\glew-1.9.0
234-
set PYTHON_PATH=C:\Python27
235-
236-
REM Add glut & glew dependencies to have GPU unit tests
237-
set PATH=%GLEW_PATH%\bin;%GLUT_PATH%\bin;D:\Tools\cygwin64\bin;%CMAKE_PATH%\bin;%PATH%
238-
239-
REM Add Ninja & jom to speed-up command line build i.e. one is enough
240-
set PATH=D:\OpenSource\3rdParty\ninja;D:\OpenSource\3rdParty\jom;%PYTHONPATH%;%PATH%
241-
242-
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64
243-
REM call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64
244-
245-
set OCIO_PATH=D:\OpenSource\%repo_name%
246-
247-
D:
248-
249-
IF NOT EXIST %OCIO_PATH% (
250-
echo %OCIO_PATH% does not exist
251-
exit /b
252-
)
253-
cd %OCIO_PATH%
254-
255-
256-
set CMAKE_BUILD_TYPE=Release
257-
258-
echo *******
259-
echo *********************************************
260-
echo ******* Building %OCIO_PATH%
261-
echo **
262-
echo **
263-
set are_you_sure = Y
264-
set /P are_you_sure=Build in %CMAKE_BUILD_TYPE% ([Y]/N)?
265-
if not %are_you_sure%==Y set CMAKE_BUILD_TYPE=Debug
266-
249+
.. _Windows 7 or newer:
267250

268-
set BUILD_PATH=%OCIO_PATH%\build_rls
269-
set COMPILED_THIRD_PARTY_HOME=D:/OpenSource/3rdParty/compiled-dist_rls
270-
set OCIO_BUILD_PYTHON=1
251+
Windows 7 or newer
252+
^^^^^^^^^^^^^^^^^^
271253

272-
if not %CMAKE_BUILD_TYPE%==Release (
273-
set BUILD_PATH=%OCIO_PATH%\build_dbg
274-
set COMPILED_THIRD_PARTY_HOME=D:/OpenSource/3rdParty/compiled-dist_dbg
275-
set OCIO_BUILD_PYTHON=0
276-
)
254+
While build environments may vary between users, the recommended way to build OCIO from source on
255+
Windows is to use the scripts provided in the Windows
256+
`share <https://github.com/AcademySoftwareFoundation/OpenColorIO/tree/main/share/dev/windows>`_
257+
section of the OCIO repository. There are two scripts currently available.
277258

278-
set INSTALL_PATH=%COMPILED_THIRD_PARTY_HOME%/OpenColorIO-2.0.0
259+
The first script is called
260+
`ocio_deps.bat <https://github.com/AcademySoftwareFoundation/OpenColorIO/tree/main/share/dev/windows/ocio_deps.bat>`_
261+
and it provides some automation to install the most difficult dependencies. Those dependencies are:
279262

280-
IF NOT EXIST %BUILD_PATH% ( mkdir %BUILD_PATH% )
281-
cd %BUILD_PATH%
263+
- `Vcpkg <https://vcpkg.io/en/index.html>`_
264+
- OpenImageIO
265+
- Freeglut
266+
- Glew
267+
- Python dependencies for documentation
282268

283-
echo **
284-
echo **
269+
Run this command to execute the ocio_deps.bat script::
285270

286-
REM cmake -G "Visual Studio 14 2015 Win64"
287-
REM cmake -G "Visual Studio 15 2017 Win64"
288-
REM cmake -G "Ninja"
289-
cmake -G "NMake Makefiles JOM" ^
290-
-DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE% ^
291-
-DCMAKE_INSTALL_PREFIX=%INSTALL_PATH% ^
292-
-DBUILD_SHARED_LIBS=ON ^
293-
-DOCIO_BUILD_APPS=ON ^
294-
-DOCIO_BUILD_TESTS=ON ^
295-
-DOCIO_BUILD_GPU_TESTS=ON ^
296-
-DOCIO_BUILD_DOCS=OFF ^
297-
-DOCIO_USE_SSE=ON ^
298-
-DOCIO_WARNING_AS_ERROR=ON ^
299-
-DOCIO_BUILD_PYTHON=%OCIO_BUILD_PYTHON% ^
300-
-DPython_LIBRARY=%PYTHON_PATH%\libs\python27.lib ^
301-
-DPython_INCLUDE_DIR=%PYTHON_PATH%\include ^
302-
-DPython_EXECUTABLE=%PYTHON_PATH%\python.exe ^
303-
-DOCIO_BUILD_JAVA=OFF ^
304-
-DCMAKE_PREFIX_PATH=%COMPILED_THIRD_PARTY_HOME%\OpenImageIO-1.9.0;%COMPILED_THIRD_PARTY_HOME%/ilmbase-2.2.0 ^
305-
%OCIO_PATH%
271+
ocio_deps.bat --vcpkg <path to current vcpkg installation or where it should be installed>
306272

307-
REM Add OCIO & OIIO
308-
set PATH=%BUILD_PATH%\src\OpenColorIO;%INSTALL_PATH%\bin;%COMPILED_THIRD_PARTY_HOME%\OpenImageIO-1.9.0\bin;%PATH%
273+
The second script is called
274+
`ocio.bat <https://github.com/AcademySoftwareFoundation/OpenColorIO/tree/main/share/dev/windows/ocio.bat>`_
275+
and it provide a way to configure and build OCIO from source. Moreover, this script executes the
276+
install step of cmake as well as the unit tests. The main use case is the following::
309277

278+
ocio.bat --b <path to build folder> --i <path to install folder>
279+
--vcpkg <path to vcpkg installation> --ocio <path to ocio repository> --type Release
310280

311-
REM Find the current branch
312-
set GITBRANCH=
313-
for /f %%I in ('git.exe rev-parse --abbrev-ref HEAD 2^> NUL') do set GITBRANCH=%%I
314281

315-
if not "%GITBRANCH%" == "" prompt $C%GITBRANCH%$F $P$G
282+
For more information, please look at each script's documentation::
316283

317-
TITLE %repo_name% (%GITBRANCH%)
284+
ocio.bat --help
318285

319-
echo *******
320-
echo *********************************************
321-
if not "%GITBRANCH%" == "" echo branch = %GITBRANCH%
322-
echo *
323-
echo Mode = %CMAKE_BUILD_TYPE%
324-
echo Build path = %BUILD_PATH%
325-
echo Install path = %INSTALL_PATH%
326-
echo *
327-
echo compile = jom all
328-
echo test = ctest -V
329-
echo doc = jom doc
330-
echo install = jom install
331-
echo *********************************************
332-
echo *******
333-
334-
You could create a desktop shortcut with the following command:
335-
``%comspec% /k "C:\Users\hodoulp\ocio.bat" ocio``
336-
337-
Also look to the Appveyor config script at the root of repository for an example
338-
build sequence.
286+
ocio_deps.bat --help
339287

340288
.. _enabling-optional-components:
341289

share/dev/windows/README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Building OCIO on Windows using MS Visual Studio 2022
2+
3+
# Manual steps for installing pre-requisites
4+
- Install Microsoft Visual Studio
5+
- Install Python
6+
- Install CMake
7+
- Install Doxygen (optional: only for python documentations)
8+
9+
## Microsoft Visual Studio (Desktop development with C++)
10+
Please use the official Microsoft Visual Studio installer.
11+
> See https://visualstudio.microsoft.com/downloads/
12+
13+
## Python
14+
Please use the official Python installer
15+
> See https://www.python.org/downloads/
16+
17+
**Make sure to check the option to add Python to PATH environment variable while running the installer**
18+
19+
## Cmake
20+
Please use the official CMake installer.
21+
> See https://cmake.org/download/
22+
>
23+
> Example: https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1-windows-x86_64.msi
24+
25+
**Make sure to check the option to add CMake to PATH environment variable while running the installer**
26+
27+
### Doxygen (optional: for editing the documentation)
28+
Please use the official Doxygen installer.
29+
> See https://www.doxygen.nl/download.html
30+
>
31+
> Example: https://www.doxygen.nl/files/doxygen-1.9.3-setup.exe
32+
33+
34+
# Running the script to install the remaining pre-requisites
35+
36+
## Using ocio_deps.bat
37+
**ocio_deps.bat** script can be used to verify and install the rest of OCIO dependencies.
38+
<br/>
39+
The script can be used to install the following:
40+
- Vcpkg
41+
- OpenImageIO
42+
- FreeGLUT
43+
- Glew
44+
- Python documentation dependencies (six, testresources, recommonmark, sphinx-press-theme, sphinx-tabs, and breathe)
45+
46+
Run ocio script and follow the steps.
47+
```bash
48+
ocio_deps.bat --vcpkg <path to vcpkg root>
49+
50+
See ocio_deps --help:
51+
52+
Mandatory option:
53+
--vcpkg path to an existing vcpkg installation or path where you want to install vcpkg
54+
```
55+
56+
# Running the script to build and install OCIO
57+
## Using ocio.bat
58+
**Ocio.bat** can be used to build and install OCIO.
59+
```bash
60+
# Options can be removed by modifying the value inside ocio.bat script.
61+
# see the top of ocio.bat file
62+
63+
# Produce a release build using the default build and install paths.
64+
ocio.bat --vcpkg <vcpkg directory> --type Release --ocio <path to OCIO source>
65+
# Produce a debug build using the default build and install paths.
66+
ocio.bat --vcpkg <vcpkg directory> --type Debug --ocio <path to OCIO source>
67+
# Produce a release build using a custom build path (--b) and a custom install paths (--i).
68+
ocio.bat --vcpkg <vcpkg directory> --type Release --b C:\ocio\__build --i C:\ocio\__install --ocio <path to OCIO source>
69+
70+
See ocio --help:
71+
72+
Mandatory options:
73+
--vcpkg path to an existing vcpkg installation
74+
75+
--ocio path to OCIO source code
76+
77+
Optional options depending on the environment:
78+
--python Python installation location
79+
80+
--msvs path where to find vcvars64.bat from Microsoft Visual Studio
81+
Default: C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build
82+
83+
--b build location
84+
Default: C:\Users\cfuoco\AppData\Local\Temp\OCIO\build
85+
86+
--i installation location
87+
Default: C:\Users\cfuoco\AppData\Local\Temp\OCIO\install
88+
89+
--type Release or Debug
90+
Default: Release
91+
--configure Run cmake configure or not
92+
Default: false
93+
```

0 commit comments

Comments
 (0)