Skip to content

Commit

Permalink
Upgrade to CMake 3.12, Add support for ext CMake configs (AcademySoft…
Browse files Browse the repository at this point in the history
…wareFoundation#1061)

Signed-off-by: Michael Dolan <[email protected]>
  • Loading branch information
michdolan authored Jul 20, 2020
1 parent 9360e40 commit 346b11c
Show file tree
Hide file tree
Showing 38 changed files with 1,006 additions and 1,030 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/analysis_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ jobs:
<${{ matrix.compiler-desc }}
cxx=${{ matrix.cxx-standard }},
docs=${{ matrix.build-docs }}>'
# Don't run on OCIO forks
if: github.repository == 'AcademySoftwareFoundation/OpenColorIO'
# GH-hosted VM. The build runs in CentOS 7 'container' defined below.
runs-on: ubuntu-latest
container:
Expand Down Expand Up @@ -145,6 +147,8 @@ jobs:

linux_sonarcloud:
name: 'Linux CentOS 7 VFX CY2020 SonarCloud <GCC 6.3.1>'
# Don't run on OCIO forks
if: github.repository == 'AcademySoftwareFoundation/OpenColorIO'
# GH-hosted VM. The build runs in CentOS 7 'container' defined below.
runs-on: ubuntu-latest
container:
Expand Down
86 changes: 48 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.

cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.12)

project(OpenColorIO
VERSION 2.0.0
Expand Down Expand Up @@ -85,65 +85,67 @@ option(OCIO_WARNING_AS_ERROR "Set build error level for CI testing" OFF)
###############################################################################
# GPU configuration

include(PackageUtils)

if(OCIO_BUILD_GPU_TESTS OR OCIO_BUILD_APPS)
set(OCIO_GL_ENABLED ON)
set(OCIO_USE_GLVND OFF)
set(OCIO_EGL_HEADLESS OFF)

find_package(OpenGL REQUIRED COMPONENTS OpenGL)
find_package(OpenGL COMPONENTS OpenGL)
if(NOT OpenGL_OpenGL_FOUND AND NOT OPENGL_GLU_FOUND)
message(WARNING "OpenGL not found; GPU rendering disabled")
package_root_message(OpenGL)
set(OCIO_GL_ENABLED OFF)
endif()

# OpenGL_egl_Library is defined iff GLVND is supported (CMake 10+).
if(OPENGL_egl_LIBRARY)
message(STATUS "GLVND supported")
set(OCIO_USE_GLVND ON)
else()
message(STATUS "GLVND not supported; legacy OpenGL libraries used")
set(OCIO_USE_GLVND OFF)
endif()

if(NOT APPLE)
find_package(GLEW QUIET)
find_package(GLEW)
if(NOT GLEW_FOUND)
message(WARNING "GLEW not found")
package_root_message(GLEW)
set(OCIO_GL_ENABLED OFF)
endif()
endif()
find_package(GLUT QUIET)
endif()

find_package(GLUT)
if(NOT GLUT_FOUND)
message(WARNING "GLUT not found")
package_root_message(GLUT)
set(OCIO_GL_ENABLED OFF)
endif()

set(OCIO_EGL_HEADLESS OFF)
if(${OCIO_USE_HEADLESS})
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
if(NOT ${OCIO_USE_GLVND})
message(STATUS "Can't find EGL without GLVND support; can't render headlessly")
set(OCIO_USE_HEADLESS OFF)
set(OCIO_EGL_HEADLESS OFF)
else()
set(OCIO_EGL_HEADLESS ON)
find_package(OpenGL COMPONENTS EGL)
if(NOT OpenGL_EGL_FOUND)
message(WARNING "EGL component missing; can't render headlessly")
if(NOT OCIO_GL_ENABLED)
message(WARNING "GPU rendering disabled")
else()
# OpenGL_egl_Library is defined iff GLVND is supported (CMake 10+).
if(OPENGL_egl_LIBRARY)
message(STATUS "GLVND supported")
set(OCIO_USE_GLVND ON)
else()
message(STATUS "GLVND not supported; legacy OpenGL libraries used")
endif()

if(OCIO_USE_HEADLESS)
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
if(NOT OCIO_USE_GLVND)
message(STATUS "Can't find EGL without GLVND support; can't render headlessly")
set(OCIO_USE_HEADLESS OFF)
set(OCIO_EGL_HEADLESS OFF)
else()
add_compile_definitions(OCIO_HEADLESS_ENABLED)
find_package(OpenGL COMPONENTS EGL)
if(NOT OpenGL_EGL_FOUND)
message(WARNING "EGL component missing; can't render headlessly")
set(OCIO_USE_HEADLESS OFF)
else()
add_compile_definitions(OCIO_HEADLESS_ENABLED)
set(OCIO_EGL_HEADLESS ON)
message(STATUS "EGL enabled")
endif()
endif()
else()
message(WARNING "OS system is not Linux; can't render headlessly")
endif()
else()
message(WARNING "OS system is not Linux; can't render headlessly")
set(OCIO_EGL_HEADLESS OFF)
endif()
endif()
endif()

message(STATUS "GL enabled " ${OCIO_GL_ENABLED})
message(STATUS "EGL enabled " ${OCIO_EGL_HEADLESS})

###############################################################################
# Optimization / internal linking preferences

Expand Down Expand Up @@ -249,12 +251,20 @@ if(OCIO_BUILD_STATIC)
endif()
endif()

###############################################################################
# Find or install external dependencies
# Some required targets may be created by third-party CMake configs, which
# don't generally produce global targets. To guarantee all imported targets are
# global, this module is included at the project root level.

include(FindExtPackages)

###############################################################################
# Progress to other sources

add_subdirectory(ext)
add_subdirectory(tests)
add_subdirectory(include)
add_subdirectory(ext)
add_subdirectory(src)
if(OCIO_BUILD_DOCS)
add_subdirectory(docs)
Expand Down
19 changes: 4 additions & 15 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@ if(NOT OCIO_BUILD_PYTHON)
message(FATAL_ERROR "Doc generation requires that the python bindings be built")
endif()

###############################################################################
### External Python dependencies ###

include(FindPythonPackage)

# Sphinx
# https://pypi.python.org/pypi/Sphinx
set(SPHINX_MIN_VERSION 1.8.5)
find_package(Sphinx ${SPHINX_MIN_VERSION} REQUIRED)
if(NOT SPHINX_FOUND)
message(FATAL_ERROR "Doc generation requires Sphinx")
endif()

###############################################################################
### Setup PYTHONPATH ###

Expand Down Expand Up @@ -135,7 +122,7 @@ add_custom_target(rst_extraction

add_custom_target(docs ALL
COMMAND
${PYT_PRE_CMD} "${SPHINX_EXECUTABLE}" -b html . "${CMAKE_CURRENT_BINARY_DIR}/build-html"
${PYT_PRE_CMD} "${Sphinx_EXECUTABLE}" -b html . "${CMAKE_CURRENT_BINARY_DIR}/build-html"
DEPENDS
OpenColorIO
PyOpenColorIO
Expand All @@ -158,11 +145,13 @@ install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/build-html/
### PDF target ###

find_package(LATEX)
package_root_message(LATEX)

if(PDFLATEX_COMPILER)

add_custom_target(latex
COMMAND
${PYT_PRE_CMD} "${SPHINX_EXECUTABLE}" -b latex . "${CMAKE_CURRENT_BINARY_DIR}/build-latex"
${PYT_PRE_CMD} "${Sphinx_EXECUTABLE}" -b latex . "${CMAKE_CURRENT_BINARY_DIR}/build-latex"
DEPENDS
OpenColorIO
PyOpenColorIO
Expand Down
29 changes: 16 additions & 13 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Dependencies

The basic requirements for building OCIO are:

- cmake >= 3.10
- cmake >= 3.12
- \*Expat >= 2.2.5 (XML parser for CDL/CLF/CTF)
- \*yaml-cpp >= 0.6.3 (YAML parser for Configs)
- \*IlmBase (Half only) >= 2.3.0 (for half domain LUTs)
Expand All @@ -64,10 +64,11 @@ The basic requirements for building OCIO are:
Some optional components also depend on:

- \*Little CMS >= 2.2 (for ociobakelut ICC profile baking)
- Python 2.x (for the Python bindings and docs)
- \*pybind11 >= 2.4.3 (for the Python bindings)
- Python >= 2.7 (for the Python bindings and docs)
- \*Sphinx >= 1.8.5
- OpenImageIO >= 2.1.9 (for apps including ocioconvert)
- Nuke 6.x or newer (for the Nuke nodes)
- OpenImageIO (for apps including ocioconvert)

Automated Installation
^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -97,16 +98,18 @@ 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_DIRS=<path>`` (include and/or library root dir)
- ``-DEXPAT_STATIC_LIBRARY=ON`` (prefer static lib)
- ``-DYAMLCPP_DIRS=<path>`` (include and/or library root dir)
- ``-DYAMLCPP_STATIC_LIBRARY=ON`` (prefer static lib)
- ``-DILMBASE_DIRS=<path>`` (include and/or library root dir)
- ``-DILMBASE_STATIC_LIBRARY=ON`` (prefer static lib)
- ``-DPYSTRING_DIRS=<path>`` (include and/or library root dir)
- ``-DPYSTRING_STATIC_LIBRARY=ON`` (prefer static lib)
- ``-DLCMS2_DIRS=<path>`` (include and/or library root dir)
- ``-DLCMS2_STATIC_LIBRARY=ON`` (prefer static lib)
- ``-DExpat_ROOT=<path>`` (include and/or library root dir)
- ``-DExpat_STATIC_LIBRARY=ON`` (prefer static lib)
- ``-Dyaml-cpp_ROOT=<path>`` (include and/or library root dir)
- ``-Dyaml-cpp_STATIC_LIBRARY=ON`` (prefer static lib)
- ``-DHalf_ROOT=<path>`` (include and/or library root dir)
- ``-DHalf_STATIC_LIBRARY=ON`` (prefer static lib)
- ``-Dpystring_ROOT=<path>`` (include and/or library root dir)
- ``-Dpystring_STATIC_LIBRARY=ON`` (prefer static lib)
- ``-Dlcms2_ROOT=<path>`` (include and/or library root dir)
- ``-Dlcms2_STATIC_LIBRARY=ON`` (prefer static lib)
- ``-pybind11_ROOT=<path>`` (include and/or library root dir)
- ``-DPYTHON_EXECUTABLE=<path>`` (Python executable)
- ``-DNUKE_INSTALL_PATH=<path>`` (or use ``NDK_PATH`` environment variable)

To hint at Python package locations, add paths to the ``PYTHONPATH``
Expand Down
33 changes: 1 addition & 32 deletions ext/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,8 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.


###############################################################################
### External third-party C/C++ dependencies. ###

# Expat
# https://github.com/libexpat/libexpat
set(EXPAT_MIN_VERSION 2.2.5)
find_package(Expat ${EXPAT_MIN_VERSION} REQUIRED)

# yaml-cpp
# https://github.com/jbeder/yaml-cpp
set(YAMLCPP_MIN_VERSION 0.6.3)
find_package(YamlCpp ${YAMLCPP_MIN_VERSION} REQUIRED)

# IlmBase (Half part only)
# https://github.com/openexr/openexr
set(ILMBASE_MIN_VERSION 2.3.0)
find_package(IlmBase ${ILMBASE_MIN_VERSION} REQUIRED)

# Pystring
# https://github.com/imageworks/pystring
set(PYSTRING_MIN_VERSION 1.1.3)
find_package(Pystring ${PYSTRING_MIN_VERSION} REQUIRED)

if(OCIO_BUILD_APPS)
# LCMS2
# https://github.com/mm2/Little-CMS
set(LCMS2_MIN_VERSION 2.2)
find_package(LCMS2 ${LCMS2_MIN_VERSION} REQUIRED)
endif()

###############################################################################
### External (modified) third-party C/C++ dependencies. ###
### External (modified) third-party C/C++ dependencies ###

# Sample ICC (modified)
add_subdirectory(sampleicc)
4 changes: 2 additions & 2 deletions share/ci/scripts/linux/install_expat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ fi
mkdir build
cd build

cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_BUILD_TYPE=Release \
cmake -DCMAKE_BUILD_TYPE=Release \
-DEXPAT_BUILD_TOOLS=OFF \
-DEXPAT_BUILD_EXAMPLES=OFF \
-DEXPAT_BUILD_TESTS=OFF \
-DEXPAT_SHARED_LIBS=ON \
-DEXPAT_BUILD_DOCS=OFF \
-DCMAKE_C_FLAGS="-fPIC" \
-DCMAKE_CXX_FLAGS="-fPIC" \
../expat/.
Expand Down
5 changes: 2 additions & 3 deletions share/ci/scripts/linux/install_lcms2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ else
git checkout tags/lcms${LCMS2_VERSION} -b lcms${LCMS2_VERSION}
fi

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

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
-DBUILD_SHARED_LIBS:BOOL=ON \
cmake -DBUILD_SHARED_LIBS=ON \
-DCMAKE_C_FLAGS="-fPIC" \
../.
make -j4
Expand Down
7 changes: 1 addition & 6 deletions share/ci/scripts/linux/install_oiio.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ set -ex

OIIO_VERSION="$1"

# TODO: Remove this when the aswf-docker containers are upgraded to the newer
# version of OpenJpeg. OIIO has deprecated v1 support.
sudo yum -y install openjpeg2-devel

git clone https://github.com/OpenImageIO/oiio.git
cd oiio

Expand All @@ -22,8 +18,7 @@ fi

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
-DOIIO_BUILD_TOOLS=OFF \
cmake -DOIIO_BUILD_TOOLS=OFF \
-DOIIO_BUILD_TESTS=OFF \
-DVERBOSE=ON \
-DSTOP_ON_WARNING=OFF \
Expand Down
4 changes: 2 additions & 2 deletions share/ci/scripts/linux/install_openexr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ fi

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
-DBUILD_TESTING=OFF \
cmake -DBUILD_TESTING=OFF \
-DOPENEXR_BUILD_UTILS=OFF \
-DOPENEXR_VIEWERS_ENABLE=OFF \
-DINSTALL_OPENEXR_EXAMPLES=OFF \
-DPYILMBASE_ENABLE=OFF \
-DCMAKE_C_FLAGS="-fPIC" \
-DCMAKE_CXX_FLAGS="-fPIC" \
Expand Down
5 changes: 2 additions & 3 deletions share/ci/scripts/linux/install_pybind11.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ fi

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
-DPYBIND11_INSTALL:BOOL=ON \
-DPYBIND11_TEST:BOOL=OFF \
cmake -DPYBIND11_INSTALL=ON \
-DPYBIND11_TEST=OFF \
../.
make -j4
sudo make install
Expand Down
5 changes: 2 additions & 3 deletions share/ci/scripts/linux/install_pystring.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ else
git checkout tags/v${PYSTRING_VERSION} -b v${PYSTRING_VERSION}
fi

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

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
-DBUILD_SHARED_LIBS:BOOL=ON \
cmake -DBUILD_SHARED_LIBS=ON \
-DCMAKE_CXX_FLAGS="-fPIC" \
../.
make -j4
Expand Down
3 changes: 1 addition & 2 deletions share/ci/scripts/linux/install_yaml-cpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ fi

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local \
-DBUILD_SHARED_LIBS=ON \
cmake -DBUILD_SHARED_LIBS=ON \
-DYAML_CPP_BUILD_TESTS=OFF \
-DYAML_CPP_BUILD_TOOLS=OFF \
-DYAML_CPP_BUILD_CONTRIB=OFF \
Expand Down
Loading

0 comments on commit 346b11c

Please sign in to comment.