From 346b11c9a69fcf4934e3d7bdc6c27bf139c2b0ca Mon Sep 17 00:00:00 2001 From: Michael Dolan Date: Mon, 20 Jul 2020 13:31:33 -0400 Subject: [PATCH] Upgrade to CMake 3.12, Add support for ext CMake configs (#1061) Signed-off-by: Michael Dolan --- .github/workflows/analysis_workflow.yml | 4 + CMakeLists.txt | 86 ++++--- docs/CMakeLists.txt | 19 +- docs/installation.rst | 29 ++- ext/CMakeLists.txt | 33 +-- share/ci/scripts/linux/install_expat.sh | 4 +- share/ci/scripts/linux/install_lcms2.sh | 5 +- share/ci/scripts/linux/install_oiio.sh | 7 +- share/ci/scripts/linux/install_openexr.sh | 4 +- share/ci/scripts/linux/install_pybind11.sh | 5 +- share/ci/scripts/linux/install_pystring.sh | 5 +- share/ci/scripts/linux/install_yaml-cpp.sh | 3 +- share/cmake/macros/PackageUtils.cmake | 11 + share/cmake/modules/FindExpat.cmake | 211 ---------------- share/cmake/modules/FindExtPackages.cmake | 52 ++++ share/cmake/modules/FindHalf.cmake | 226 ++++++++++++++++++ share/cmake/modules/FindIlmBase.cmake | 216 ----------------- share/cmake/modules/FindOpenImageIO.cmake | 36 --- share/cmake/modules/FindSphinx.cmake | 31 ++- share/cmake/modules/FindYamlCpp.cmake | 221 ----------------- share/cmake/modules/Findexpat.cmake | 218 +++++++++++++++++ .../{FindLCMS2.cmake => Findlcms2.cmake} | 124 +++++----- share/cmake/modules/Findpybind11.cmake | 103 ++++---- ...{FindPystring.cmake => Findpystring.cmake} | 104 ++++---- share/cmake/modules/Findyaml-cpp.cmake | 219 +++++++++++++++++ .../{BuildLCMS2.cmake => Buildlcms2.cmake} | 0 ...uildPystring.cmake => Buildpystring.cmake} | 4 +- share/cmake/scripts/PatchOpenEXR.cmake | 9 + src/CMakeLists.txt | 7 +- src/OpenColorIO/CMakeLists.txt | 4 +- src/apps/CMakeLists.txt | 4 +- src/apps/ocioconvert/CMakeLists.txt | 4 +- src/apps/ociodisplay/CMakeLists.txt | 2 +- src/apps/ociolutimage/CMakeLists.txt | 2 +- src/apps/ocioperf/CMakeLists.txt | 4 +- src/bindings/python/CMakeLists.txt | 5 - src/libutils/oiiohelpers/CMakeLists.txt | 9 +- tests/cpu/CMakeLists.txt | 6 +- 38 files changed, 1006 insertions(+), 1030 deletions(-) create mode 100644 share/cmake/macros/PackageUtils.cmake delete mode 100644 share/cmake/modules/FindExpat.cmake create mode 100644 share/cmake/modules/FindExtPackages.cmake create mode 100644 share/cmake/modules/FindHalf.cmake delete mode 100644 share/cmake/modules/FindIlmBase.cmake delete mode 100755 share/cmake/modules/FindOpenImageIO.cmake delete mode 100644 share/cmake/modules/FindYamlCpp.cmake create mode 100644 share/cmake/modules/Findexpat.cmake rename share/cmake/modules/{FindLCMS2.cmake => Findlcms2.cmake} (51%) rename share/cmake/modules/{FindPystring.cmake => Findpystring.cmake} (57%) create mode 100644 share/cmake/modules/Findyaml-cpp.cmake rename share/cmake/projects/{BuildLCMS2.cmake => Buildlcms2.cmake} (100%) rename share/cmake/projects/{BuildPystring.cmake => Buildpystring.cmake} (81%) create mode 100644 share/cmake/scripts/PatchOpenEXR.cmake diff --git a/.github/workflows/analysis_workflow.yml b/.github/workflows/analysis_workflow.yml index 3b4853f2d8..9c4cf9dc7a 100644 --- a/.github/workflows/analysis_workflow.yml +++ b/.github/workflows/analysis_workflow.yml @@ -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: @@ -145,6 +147,8 @@ jobs: linux_sonarcloud: name: 'Linux CentOS 7 VFX CY2020 SonarCloud ' + # 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: diff --git a/CMakeLists.txt b/CMakeLists.txt index 396e567f7a..b2369569cb 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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 @@ -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) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 1228407f5c..c3991bf16c 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -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 ### @@ -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 @@ -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 diff --git a/docs/installation.rst b/docs/installation.rst index f96d715159..dff5be6042 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -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) @@ -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 ^^^^^^^^^^^^^^^^^^^^^^ @@ -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=`` (include and/or library root dir) -- ``-DEXPAT_STATIC_LIBRARY=ON`` (prefer static lib) -- ``-DYAMLCPP_DIRS=`` (include and/or library root dir) -- ``-DYAMLCPP_STATIC_LIBRARY=ON`` (prefer static lib) -- ``-DILMBASE_DIRS=`` (include and/or library root dir) -- ``-DILMBASE_STATIC_LIBRARY=ON`` (prefer static lib) -- ``-DPYSTRING_DIRS=`` (include and/or library root dir) -- ``-DPYSTRING_STATIC_LIBRARY=ON`` (prefer static lib) -- ``-DLCMS2_DIRS=`` (include and/or library root dir) -- ``-DLCMS2_STATIC_LIBRARY=ON`` (prefer static lib) +- ``-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) +- ``-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) +- ``-pybind11_ROOT=`` (include and/or library root dir) +- ``-DPYTHON_EXECUTABLE=`` (Python executable) - ``-DNUKE_INSTALL_PATH=`` (or use ``NDK_PATH`` environment variable) To hint at Python package locations, add paths to the ``PYTHONPATH`` diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index 10bcf488d3..8a270d60ed 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -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) diff --git a/share/ci/scripts/linux/install_expat.sh b/share/ci/scripts/linux/install_expat.sh index 3d76a5f0ef..66c4df9f2a 100755 --- a/share/ci/scripts/linux/install_expat.sh +++ b/share/ci/scripts/linux/install_expat.sh @@ -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/. diff --git a/share/ci/scripts/linux/install_lcms2.sh b/share/ci/scripts/linux/install_lcms2.sh index 71d9568953..6baa691d6d 100755 --- a/share/ci/scripts/linux/install_lcms2.sh +++ b/share/ci/scripts/linux/install_lcms2.sh @@ -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 diff --git a/share/ci/scripts/linux/install_oiio.sh b/share/ci/scripts/linux/install_oiio.sh index 2f53b59f7f..637cdd19de 100755 --- a/share/ci/scripts/linux/install_oiio.sh +++ b/share/ci/scripts/linux/install_oiio.sh @@ -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 @@ -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 \ diff --git a/share/ci/scripts/linux/install_openexr.sh b/share/ci/scripts/linux/install_openexr.sh index 675a1068ef..9684f5bcd7 100755 --- a/share/ci/scripts/linux/install_openexr.sh +++ b/share/ci/scripts/linux/install_openexr.sh @@ -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" \ diff --git a/share/ci/scripts/linux/install_pybind11.sh b/share/ci/scripts/linux/install_pybind11.sh index 9fa196bf11..c91cd8bd09 100755 --- a/share/ci/scripts/linux/install_pybind11.sh +++ b/share/ci/scripts/linux/install_pybind11.sh @@ -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 diff --git a/share/ci/scripts/linux/install_pystring.sh b/share/ci/scripts/linux/install_pystring.sh index 8a2dcdc0c8..b5e1684e2a 100755 --- a/share/ci/scripts/linux/install_pystring.sh +++ b/share/ci/scripts/linux/install_pystring.sh @@ -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 diff --git a/share/ci/scripts/linux/install_yaml-cpp.sh b/share/ci/scripts/linux/install_yaml-cpp.sh index 420db742e3..3c7780f7d7 100755 --- a/share/ci/scripts/linux/install_yaml-cpp.sh +++ b/share/ci/scripts/linux/install_yaml-cpp.sh @@ -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 \ diff --git a/share/cmake/macros/PackageUtils.cmake b/share/cmake/macros/PackageUtils.cmake new file mode 100644 index 0000000000..60b7212b62 --- /dev/null +++ b/share/cmake/macros/PackageUtils.cmake @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. +# +# General CMake utility macros. +# + +macro(package_root_message package) + if(NOT "${${package}_FOUND}") + message(STATUS "Use \"${package}_ROOT\" to specify an install location") + endif() +endmacro() diff --git a/share/cmake/modules/FindExpat.cmake b/share/cmake/modules/FindExpat.cmake deleted file mode 100644 index 07270469d8..0000000000 --- a/share/cmake/modules/FindExpat.cmake +++ /dev/null @@ -1,211 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright Contributors to the OpenColorIO Project. -# -# Locate or install expat -# -# Variables defined by this module: -# EXPAT_FOUND - If FALSE, do not try to link to expat -# EXPAT_LIBRARY - Where to find expat -# EXPAT_INCLUDE_DIR - Where to find expat.h -# EXPAT_VERSION - The version of the library -# -# Targets defined by this module: -# expat::expat - IMPORTED target, if found -# -# By default, the dynamic libraries of expat will be found. To find the static -# ones instead, you must set the EXPAT_STATIC_LIBRARY variable to TRUE -# before calling find_package(Expat ...). -# -# If expat is not installed in a standard path, you can use the EXPAT_DIRS -# variable to tell CMake where to find it. If it is not found and -# OCIO_INSTALL_EXT_PACKAGES is set to MISSING or ALL, expat will be downloaded, -# built, and statically-linked into libOpenColorIO at build time. -# - -if(NOT TARGET expat::expat) - add_library(expat::expat UNKNOWN IMPORTED GLOBAL) - set(_EXPAT_TARGET_CREATE TRUE) -endif() - -############################################################################### -### Try to find package ### - -if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) - # Try to use pkg-config to get the version - find_package(PkgConfig QUIET) - pkg_check_modules(PC_EXPAT QUIET expat) - - set(_EXPAT_SEARCH_DIRS - ${EXPAT_DIRS} - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - ) - - # Find include directory - find_path(EXPAT_INCLUDE_DIR - NAMES - expat.h - HINTS - ${_EXPAT_SEARCH_DIRS} - ${PC_EXPAT_INCLUDE_DIRS} - PATH_SUFFIXES - include - expat/include - ) - - # Lib names to search for - set(_EXPAT_LIB_NAMES expat libexpat) - if(WIN32 AND BUILD_TYPE_DEBUG) - # Prefer Debug lib names (Windows only) - list(INSERT _EXPAT_LIB_NAMES 0 expatd) - endif() - - if(EXPAT_STATIC_LIBRARY) - # Prefer static lib names - set(_EXPAT_STATIC_LIB_NAMES - "${CMAKE_STATIC_LIBRARY_PREFIX}expat${CMAKE_STATIC_LIBRARY_SUFFIX}") - if(WIN32 AND BUILD_TYPE_DEBUG) - # Prefer static Debug lib names (Windows only) - list(INSERT _EXPAT_STATIC_LIB_NAMES 0 - "${CMAKE_STATIC_LIBRARY_PREFIX}expatd${CMAKE_STATIC_LIBRARY_SUFFIX}") - endif() - endif() - - # Find library - find_library(EXPAT_LIBRARY - NAMES - ${_EXPAT_STATIC_LIB_NAMES} - ${_EXPAT_LIB_NAMES} - HINTS - ${_EXPAT_SEARCH_DIRS} - ${PC_EXPAT_LIBRARY_DIRS} - PATH_SUFFIXES - lib64 lib - ) - - # Get version from header or config file - # if(PC_EXPAT_FOUND) - # set(EXPAT_VERSION "${PC_EXPAT_VERSION}") - if(EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h") - file(STRINGS "${EXPAT_INCLUDE_DIR}/expat.h" _EXPAT_VER_SEARCH - REGEX "^[ \t]*#define[ \t]+XML_(MAJOR|MINOR|MICRO)_VERSION[ \t]+[0-9]+.*$") - if(_EXPAT_VER_SEARCH) - foreach(_VER_PART MAJOR MINOR MICRO) - string(REGEX REPLACE ".*#define[ \t]+XML_${_VER_PART}_VERSION[ \t]+([0-9]+).*" - "\\1" EXPAT_VERSION_${_VER_PART} "${_EXPAT_VER_SEARCH}") - if(NOT EXPAT_VERSION_${_VER_PART}) - set(EXPAT_VERSION_${_VER_PART} 0) - endif() - endforeach() - set(EXPAT_VERSION - "${EXPAT_VERSION_MAJOR}.${EXPAT_VERSION_MINOR}.${EXPAT_VERSION_MICRO}") - endif() - elseif(PC_EXPAT_FOUND) - set(EXPAT_VERSION "${PC_EXPAT_VERSION}") - endif() - - # Override REQUIRED if package can be installed - if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) - set(Expat_FIND_REQUIRED FALSE) - endif() - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(Expat - REQUIRED_VARS - EXPAT_INCLUDE_DIR - EXPAT_LIBRARY - VERSION_VAR - EXPAT_VERSION - ) - set(EXPAT_FOUND ${Expat_FOUND}) -endif() - -############################################################################### -### Install package from source ### - -if(NOT EXPAT_FOUND) - include(ExternalProject) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") - - # Set find_package standard args - set(EXPAT_FOUND TRUE) - set(EXPAT_VERSION ${Expat_FIND_VERSION}) - set(EXPAT_INCLUDE_DIR "${_EXT_DIST_ROOT}/include") - - # Set the expected library name - if(WIN32 AND BUILD_TYPE_DEBUG) - set(_EXPAT_LIB_SUFFIX "d") - endif() - set(EXPAT_LIBRARY - "${_EXT_DIST_ROOT}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}expat${_EXPAT_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") - - if(_EXPAT_TARGET_CREATE) - if(UNIX) - set(EXPAT_C_FLAGS "${EXPAT_C_FLAGS} -fPIC") - set(EXPAT_CXX_FLAGS "${EXPAT_CXX_FLAGS} -fPIC") - endif() - - if(MSVC) - set(EXPAT_C_FLAGS "${EXPAT_C_FLAGS} /EHsc") - set(EXPAT_CXX_FLAGS "${EXPAT_CXX_FLAGS} /EHsc") - endif() - - string(STRIP "${EXPAT_C_FLAGS}" EXPAT_C_FLAGS) - string(STRIP "${EXPAT_CXX_FLAGS}" EXPAT_CXX_FLAGS) - - set(EXPAT_CMAKE_ARGS - ${EXPAT_CMAKE_ARGS} - -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DBUILD_examples:BOOL=OFF - -DBUILD_tests:BOOL=OFF - -DBUILD_shared:BOOL=OFF - -DBUILD_doc:BOOL=OFF - -DCMAKE_C_FLAGS=${EXPAT_C_FLAGS} - -DCMAKE_CXX_FLAGS=${EXPAT_CXX_FLAGS} - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - ) - if(CMAKE_TOOLCHAIN_FILE) - set(EXPAT_CMAKE_ARGS - ${EXPAT_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) - endif() - - # Hack to let imported target be built from ExternalProject_Add - file(MAKE_DIRECTORY ${EXPAT_INCLUDE_DIR}) - - ExternalProject_Add(expat_install - GIT_REPOSITORY "https://github.com/libexpat/libexpat.git" - GIT_TAG "R_${Expat_FIND_VERSION_MAJOR}_${Expat_FIND_VERSION_MINOR}_${Expat_FIND_VERSION_PATCH}" - GIT_CONFIG advice.detachedHead=false - GIT_SHALLOW TRUE - PREFIX "${_EXT_BUILD_ROOT}/libexpat" - BUILD_BYPRODUCTS ${EXPAT_LIBRARY} - SOURCE_SUBDIR expat - CMAKE_ARGS ${EXPAT_CMAKE_ARGS} - EXCLUDE_FROM_ALL TRUE - ) - - add_dependencies(expat::expat expat_install) - message(STATUS "Installing Expat: ${EXPAT_LIBRARY} (version ${EXPAT_VERSION})") - endif() -endif() - -############################################################################### -### Configure target ### - -if(_EXPAT_TARGET_CREATE) - set_target_properties(expat::expat PROPERTIES - IMPORTED_LOCATION ${EXPAT_LIBRARY} - INTERFACE_INCLUDE_DIRECTORIES ${EXPAT_INCLUDE_DIR} - ) - - mark_as_advanced(EXPAT_INCLUDE_DIR EXPAT_LIBRARY EXPAT_VERSION) -endif() diff --git a/share/cmake/modules/FindExtPackages.cmake b/share/cmake/modules/FindExtPackages.cmake new file mode 100644 index 0000000000..743db41f56 --- /dev/null +++ b/share/cmake/modules/FindExtPackages.cmake @@ -0,0 +1,52 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. +# +# All find modules used in this module support typical find_package +# behavior or installation of packages from external projects, as configured +# by the OCIO_INSTALL_EXT_PACKAGES option. +# + +# expat +# https://github.com/libexpat/libexpat +find_package(expat 2.2.8 REQUIRED) + +# yaml-cpp +# https://github.com/jbeder/yaml-cpp +find_package(yaml-cpp 0.6.3 REQUIRED) + +# Half (OpenEXR/IlmBase) +# https://github.com/openexr/openexr +find_package(Half 2.4.0 REQUIRED) + +# pystring +# https://github.com/imageworks/pystring +find_package(pystring 1.1.3 REQUIRED) + +if(OCIO_BUILD_APPS) + # lcms2 + # https://github.com/mm2/Little-CMS + find_package(lcms2 2.2 REQUIRED) +endif() + +if(OCIO_BUILD_PYTHON) + # pybind11 + # https://github.com/pybind/pybind11 + find_package(pybind11 2.4.3 REQUIRED) +endif() + +if(OCIO_BUILD_DOCS) + find_package(PythonInterp 2.7 QUIET) + + if(PYTHONINTERP_FOUND) + if(PYTHON_VERSION_MAJOR GREATER_EQUAL 3) + set(Sphinx_MIN_VERSION 2.0.0) + else() + # Last release with Python 2.7 support + set(Sphinx_MIN_VERSION 1.8.5) + endif() + + # Sphinx + # https://pypi.python.org/pypi/Sphinx + find_package(Sphinx ${Sphinx_MIN_VERSION} REQUIRED) + endif() +endif() diff --git a/share/cmake/modules/FindHalf.cmake b/share/cmake/modules/FindHalf.cmake new file mode 100644 index 0000000000..01bb30d9cc --- /dev/null +++ b/share/cmake/modules/FindHalf.cmake @@ -0,0 +1,226 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. +# +# Locate or install ilmbase +# +# Variables defined by this module: +# Half_FOUND - If FALSE, do not try to link to ilmbase +# Half_LIBRARY - Half library to link to +# Half_INCLUDE_DIR - Where to find half.h +# Half_VERSION - The version of the library +# +# Targets defined by this module: +# IlmBase::Half - IMPORTED target, if found +# +# By default, the dynamic libraries of ilmbase will be found. To find the +# static ones instead, you must set the Half_STATIC_LIBRARY variable to +# TRUE before calling find_package(Half ...). +# +# If IlmBase is not installed in a standard path, you can use the +# Half_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, IlmBase will be +# downloaded, built, and statically-linked into libOpenColorIO at build time. +# + +# IlmBase components may have the version in their name +set(_Half_LIB_VER "${Half_FIND_VERSION_MAJOR}_${Half_FIND_VERSION_MINOR}") + +############################################################################### +### Try to find package ### + +if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) + set(_Half_REQUIRED_VARS Half_LIBRARY) + + if(NOT DEFINED Half_ROOT) + # Search for IlmBaseConfig.cmake + find_package(IlmBase ${Half_FIND_VERSION} CONFIG QUIET) + endif() + + if(Half_FOUND) + get_target_property(Half_LIBRARY IlmBase::Half LOCATION) + else() + list(APPEND _Half_REQUIRED_VARS Half_INCLUDE_DIR) + + # Search for IlmBase.pc + find_package(PkgConfig QUIET) + pkg_check_modules(PC_IlmBase QUIET "IlmBase>=${Half_FIND_VERSION}") + + # Find include directory + find_path(Half_INCLUDE_DIR + NAMES + OpenEXR/half.h + HINTS + ${Half_ROOT} + ${PC_Half_INCLUDE_DIRS} + PATH_SUFFIXES + include + OpenEXR/include + ) + + # Lib names to search for + set(_Half_LIB_NAMES "Half-${_Half_LIB_VER}" Half) + if(BUILD_TYPE_DEBUG) + # Prefer Debug lib names + list(INSERT _Half_LIB_NAMES 0 "Half-${_Half_LIB_VER}_d") + endif() + + if(Half_STATIC_LIBRARY) + # Prefer static lib names + set(_Half_STATIC_LIB_NAMES + "${CMAKE_STATIC_LIBRARY_PREFIX}Half-${_Half_LIB_VER}${CMAKE_STATIC_LIBRARY_SUFFIX}" + "${CMAKE_STATIC_LIBRARY_PREFIX}Half${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + if(BUILD_TYPE_DEBUG) + # Prefer static Debug lib names + list(INSERT _Half_STATIC_LIB_NAMES 0 + "${CMAKE_STATIC_LIBRARY_PREFIX}Half-${_Half_LIB_VER}_d${CMAKE_STATIC_LIBRARY_SUFFIX}") + endif() + endif() + + # Find library + find_library(Half_LIBRARY + NAMES + ${_Half_STATIC_LIB_NAMES} + ${_Half_LIB_NAMES} + HINTS + ${Half_ROOT} + ${PC_Half_LIBRARY_DIRS} + PATH_SUFFIXES + lib64 lib + ) + + # Get version from config header file + if(Half_INCLUDE_DIR) + if(EXISTS "${Half_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h") + set(_Half_CONFIG "${Half_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h") + elseif(EXISTS "${Half_INCLUDE_DIR}/OpenEXR/OpenEXRConfig.h") + set(_Half_CONFIG "${Half_INCLUDE_DIR}/OpenEXR/OpenEXRConfig.h") + endif() + endif() + + if(_Half_CONFIG) + file(STRINGS "${_Half_CONFIG}" _Half_VER_SEARCH + REGEX "^[ \t]*#define[ \t]+(OPENEXR|ILMBASE)_VERSION_STRING[ \t]+\"[.0-9]+\".*$") + if(_Half_VER_SEARCH) + string(REGEX REPLACE ".*#define[ \t]+(OPENEXR|ILMBASE)_VERSION_STRING[ \t]+\"([.0-9]+)\".*" + "\\2" Half_VERSION "${_Half_VER_SEARCH}") + endif() + elseif(PC_Half_FOUND) + set(Half_VERSION "${PC_Half_VERSION}") + endif() + endif() + + # Override REQUIRED if package can be installed + if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) + set(Half_FIND_REQUIRED FALSE) + endif() + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(Half + REQUIRED_VARS + ${_Half_REQUIRED_VARS} + VERSION_VAR + Half_VERSION + ) +endif() + +############################################################################### +### Create target + +if (NOT TARGET IlmBase::Half) + add_library(IlmBase::Half UNKNOWN IMPORTED GLOBAL) + set(_Half_TARGET_CREATE TRUE) +endif() + +############################################################################### +### Install package from source ### + +if(NOT Half_FOUND) + 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(Half_FOUND TRUE) + set(Half_VERSION ${Half_FIND_VERSION}) + set(Half_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") + + # Set the expected library name. "_d" is appended to Debug Windows builds + # <= OpenEXR 2.3.0. In newer versions, it is appended to Debug libs on + # all platforms. + if(BUILD_TYPE_DEBUG AND (WIN32 OR Half_VERSION VERSION_GREATER "2.3.0")) + set(_Half_LIB_SUFFIX "_d") + endif() + + set(Half_LIBRARY + "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}Half-${_Half_LIB_VER}${_Half_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") + + if(_Half_TARGET_CREATE) + if(UNIX) + set(Half_CXX_FLAGS "${Half_CXX_FLAGS} -fPIC") + endif() + + if(MSVC) + set(Half_CXX_FLAGS "${Half_CXX_FLAGS} /EHsc") + endif() + + string(STRIP "${Half_CXX_FLAGS}" Half_CXX_FLAGS) + + set(Half_CMAKE_ARGS + ${Half_CMAKE_ARGS} + -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DBUILD_SHARED_LIBS=OFF + -DBUILD_TESTING=OFF + -DOPENEXR_VIEWERS_ENABLE=OFF + -DPYILMBASE_ENABLE=OFF + -DCMAKE_CXX_FLAGS=${Half_CXX_FLAGS} + -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + ) + + if(CMAKE_TOOLCHAIN_FILE) + set(Half_CMAKE_ARGS + ${Half_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() + + # Hack to let imported target be built from ExternalProject_Add + file(MAKE_DIRECTORY ${Half_INCLUDE_DIR}) + + ExternalProject_Add(ilmbase_install + GIT_REPOSITORY "https://github.com/openexr/openexr.git" + GIT_TAG "v${Half_VERSION}" + GIT_CONFIG advice.detachedHead=false + GIT_SHALLOW TRUE + PREFIX "${_EXT_BUILD_ROOT}/openexr" + BUILD_BYPRODUCTS ${Half_LIBRARY} + CMAKE_ARGS ${Half_CMAKE_ARGS} + PATCH_COMMAND + ${CMAKE_COMMAND} -P "${CMAKE_SOURCE_DIR}/share/cmake/scripts/PatchOpenEXR.cmake" + BUILD_COMMAND + ${CMAKE_COMMAND} --build . + --config ${CMAKE_BUILD_TYPE} + --target Half + INSTALL_COMMAND + ${CMAKE_COMMAND} -DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_BUILD_TYPE} + -P "IlmBase/Half/cmake_install.cmake" + EXCLUDE_FROM_ALL TRUE + ) + + add_dependencies(IlmBase::Half ilmbase_install) + message(STATUS "Installing Half (IlmBase): ${Half_LIBRARY} (version \"${Half_VERSION}\")") + endif() +endif() + +############################################################################### +### Configure target ### + +if(_Half_TARGET_CREATE) + set_target_properties(IlmBase::Half PROPERTIES + IMPORTED_LOCATION ${Half_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${Half_INCLUDE_DIR} + ) + + mark_as_advanced(Half_INCLUDE_DIR Half_LIBRARY Half_VERSION) +endif() diff --git a/share/cmake/modules/FindIlmBase.cmake b/share/cmake/modules/FindIlmBase.cmake deleted file mode 100644 index 74bcd20df0..0000000000 --- a/share/cmake/modules/FindIlmBase.cmake +++ /dev/null @@ -1,216 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright Contributors to the OpenColorIO Project. -# -# Locate or install ilmbase -# -# Variables defined by this module: -# ILMBASE_FOUND - If FALSE, do not try to link to ilmbase -# ILMBASE_LIBRARY - Where to find Half -# ILMBASE_INCLUDE_DIR - Where to find half.h -# ILMBASE_VERSION - The version of the library -# -# Targets defined by this module: -# ilmbase::ilmbase - IMPORTED target, if found -# -# By default, the dynamic libraries of ilmbase will be found. To find the -# static ones instead, you must set the ILMBASE_STATIC_LIBRARY variable to -# TRUE before calling find_package(IlmBase ...). -# -# If ilmbase is not installed in a standard path, you can use the -# ILMBASE_DIRS variable to tell CMake where to find it. If it is not found -# and OCIO_INSTALL_EXT_PACKAGES is set to MISSING or ALL, ilmbase will be -# downloaded, built, and statically-linked into libOpenColorIO at build time. -# - -if (NOT TARGET ilmbase::ilmbase) - add_library(ilmbase::ilmbase UNKNOWN IMPORTED GLOBAL) - set(_ILMBASE_TARGET_CREATE TRUE) -endif() - -# IlmBase components may have the version in their name -set(_ILMBASE_LIB_VER "${IlmBase_FIND_VERSION_MAJOR}_${IlmBase_FIND_VERSION_MINOR}") - -############################################################################### -### Try to find package ### - -if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) - set(_ILMBASE_SEARCH_DIRS - ${ILMBASE_DIRS} - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - ) - - # Find include directory - find_path(ILMBASE_INCLUDE_DIR - NAMES - OpenEXR/half.h - HINTS - ${_ILMBASE_SEARCH_DIRS} - PATH_SUFFIXES - include - OpenEXR/include - ) - - # Lib names to search for - set(_ILMBASE_LIB_NAMES "Half-${_ILMBASE_LIB_VER}" Half) - if(BUILD_TYPE_DEBUG) - # Prefer Debug lib names - list(INSERT _ILMBASE_LIB_NAMES 0 "Half-${_ILMBASE_LIB_VER}_d") - endif() - - if(ILMBASE_STATIC_LIBRARY) - # Prefer static lib names - set(_ILMBASE_STATIC_LIB_NAMES - "${CMAKE_STATIC_LIBRARY_PREFIX}Half-${_ILMBASE_LIB_VER}_s${CMAKE_STATIC_LIBRARY_SUFFIX}" - "${CMAKE_STATIC_LIBRARY_PREFIX}Half${CMAKE_STATIC_LIBRARY_SUFFIX}" - ) - if(BUILD_TYPE_DEBUG) - # Prefer static Debug lib names - list(INSERT _ILMBASE_STATIC_LIB_NAMES 0 - "${CMAKE_STATIC_LIBRARY_PREFIX}Half-${_ILMBASE_LIB_VER}_s_d${CMAKE_STATIC_LIBRARY_SUFFIX}") - endif() - endif() - - # Find library - find_library(ILMBASE_LIBRARY - NAMES - ${_ILMBASE_STATIC_LIB_NAMES} - ${_ILMBASE_LIB_NAMES} - HINTS - ${_ILMBASE_SEARCH_DIRS} - PATH_SUFFIXES - lib64 lib - ) - - # Get version from config header file - if(ILMBASE_INCLUDE_DIR) - if(EXISTS "${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h") - set(_ILMBASE_CONFIG "${ILMBASE_INCLUDE_DIR}/OpenEXR/IlmBaseConfig.h") - elseif(EXISTS "${ILMBASE_INCLUDE_DIR}/OpenEXR/OpenEXRConfig.h") - set(_ILMBASE_CONFIG "${ILMBASE_INCLUDE_DIR}/OpenEXR/OpenEXRConfig.h") - endif() - endif() - - if(_ILMBASE_CONFIG) - file(STRINGS "${_ILMBASE_CONFIG}" _ILMBASE_VER_SEARCH - REGEX "^[ \t]*#define[ \t]+(OPENEXR|ILMBASE)_VERSION_STRING[ \t]+\"[.0-9]+\".*$") - if(_ILMBASE_VER_SEARCH) - string(REGEX REPLACE ".*#define[ \t]+(OPENEXR|ILMBASE)_VERSION_STRING[ \t]+\"([.0-9]+)\".*" - "\\2" ILMBASE_VERSION "${_ILMBASE_VER_SEARCH}") - endif() - endif() - - # Override REQUIRED if package can be installed - if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) - set(IlmBase_FIND_REQUIRED FALSE) - endif() - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(IlmBase - REQUIRED_VARS - ILMBASE_INCLUDE_DIR - ILMBASE_LIBRARY - VERSION_VAR - ILMBASE_VERSION - ) - set(ILMBASE_FOUND ${IlmBase_FOUND}) -endif() - -############################################################################### -### Install package from source ### - -if(NOT ILMBASE_FOUND) - include(ExternalProject) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") - - # Set find_package standard args - set(ILMBASE_FOUND TRUE) - set(ILMBASE_VERSION ${IlmBase_FIND_VERSION}) - set(ILMBASE_INCLUDE_DIR "${_EXT_DIST_ROOT}/include") - - # Set the expected library name. "_d" is appended to Debug Windows builds - # <= OpenEXR 2.3.0. In newer versions, it is appended to Debug libs on - # all platforms. - if(BUILD_TYPE_DEBUG AND (WIN32 OR ILMBASE_VERSION VERSION_GREATER "2.3.0")) - set(_ILMBASE_LIB_SUFFIX "_d") - endif() - - set(ILMBASE_LIBRARY - "${_EXT_DIST_ROOT}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}Half-${_ILMBASE_LIB_VER}_s${_ILMBASE_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") - - if(_ILMBASE_TARGET_CREATE) - if(UNIX) - set(ILMBASE_CXX_FLAGS "${ILMBASE_CXX_FLAGS} -fPIC") - endif() - - if(MSVC) - set(ILMBASE_CXX_FLAGS "${ILMBASE_CXX_FLAGS} /EHsc") - endif() - - string(STRIP "${ILMBASE_CXX_FLAGS}" ILMBASE_CXX_FLAGS) - - set(ILMBASE_CMAKE_ARGS - ${ILMBASE_CMAKE_ARGS} - -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DOPENEXR_BUILD_ILMBASE:BOOL=ON - -DOPENEXR_BUILD_OPENEXR:BOOL=OFF - -DOPENEXR_BUILD_PYTHON_LIBS:BOOL=OFF - -DOPENEXR_BUILD_SHARED:BOOL=OFF - -DOPENEXR_BUILD_STATIC:BOOL=ON - -DOPENEXR_BUILD_UTILS:BOOL=OFF - -DOPENEXR_BUILD_TESTS:BOOL=OFF - -DCMAKE_CXX_FLAGS=${ILMBASE_CXX_FLAGS} - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - ) - - if(CMAKE_TOOLCHAIN_FILE) - set(ILMBASE_CMAKE_ARGS - ${ILMBASE_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) - endif() - - # Hack to let imported target be built from ExternalProject_Add - file(MAKE_DIRECTORY ${ILMBASE_INCLUDE_DIR}) - - ExternalProject_Add(ilmbase_install - GIT_REPOSITORY "https://github.com/openexr/openexr.git" - GIT_TAG "v${ILMBASE_VERSION}" - GIT_CONFIG advice.detachedHead=false - GIT_SHALLOW TRUE - PREFIX "${_EXT_BUILD_ROOT}/openexr" - BUILD_BYPRODUCTS ${ILMBASE_LIBRARY} - CMAKE_ARGS ${ILMBASE_CMAKE_ARGS} - BUILD_COMMAND - ${CMAKE_COMMAND} --build . - --config ${CMAKE_BUILD_TYPE} - --target Half_static - INSTALL_COMMAND - ${CMAKE_COMMAND} -DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_BUILD_TYPE} - -P "IlmBase/Half/cmake_install.cmake" - EXCLUDE_FROM_ALL TRUE - ) - - add_dependencies(ilmbase::ilmbase ilmbase_install) - message(STATUS "Installing IlmBase: ${ILMBASE_LIBRARY} (version ${ILMBASE_VERSION})") - endif() -endif() - -############################################################################### -### Configure target ### - -if(_ILMBASE_TARGET_CREATE) - set_target_properties(ilmbase::ilmbase PROPERTIES - IMPORTED_LOCATION ${ILMBASE_LIBRARY} - INTERFACE_INCLUDE_DIRECTORIES ${ILMBASE_INCLUDE_DIR} - ) - - mark_as_advanced(ILMBASE_INCLUDE_DIR ILMBASE_LIBRARY ILMBASE_VERSION) -endif() diff --git a/share/cmake/modules/FindOpenImageIO.cmake b/share/cmake/modules/FindOpenImageIO.cmake deleted file mode 100755 index ea82d59f4c..0000000000 --- a/share/cmake/modules/FindOpenImageIO.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright Contributors to the OpenColorIO Project. -# -# Variables defined by this module: -# OpenImageIO_FOUND -# -# Targets exported by this module: -# OpenImageIO -# -# Usage: -# FIND_PACKAGE( OpenImageIO ) -# FIND_PACKAGE( OpenImageIO REQUIRED ) -# - -find_path(OpenImageIO_INCLUDE_DIR OpenImageIO/imageio.h PATH_SUFFIXES include) -find_library(OpenImageIO_LIBRARIES NAMES OpenImageIO OIIO) -if(OpenImageIO_LIBRARIES) - get_filename_component(OpenImageIO_LIBRARY_DIR ${OpenImageIO_LIBRARIES} DIRECTORY) -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(OpenImageIO REQUIRED_VARS OpenImageIO_LIBRARIES OpenImageIO_INCLUDE_DIR OpenImageIO_LIBRARY_DIR) -mark_as_advanced(OpenImageIO_LIBRARIES OpenImageIO_INCLUDE_DIR OpenImageIO_LIBRARY_DIR) - -if(OpenImageIO_FOUND) - # Due to OpenImageIO exposing IlmBase includes in its public headers, we must add the IlmBase Include dir - # to our include path to use OpenImageIO - find_package(IlmBase REQUIRED) - - add_library(OpenImageIO INTERFACE IMPORTED GLOBAL) - set(OpenImageIO_COMBINED_INCLUDES "") - list(APPEND OpenImageIO_COMBINED_INCLUDES ${OpenImageIO_INCLUDE_DIR}) - list(APPEND OpenImageIO_COMBINED_INCLUDES ${ILMBASE_INCLUDE_DIR}) - set_property(TARGET OpenImageIO PROPERTY INTERFACE_LINK_LIBRARIES ${OpenImageIO_LIBRARIES}) - set_property(TARGET OpenImageIO PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${OpenImageIO_COMBINED_INCLUDES}) -endif() diff --git a/share/cmake/modules/FindSphinx.cmake b/share/cmake/modules/FindSphinx.cmake index b4749056f7..4a1ada1f60 100644 --- a/share/cmake/modules/FindSphinx.cmake +++ b/share/cmake/modules/FindSphinx.cmake @@ -4,8 +4,8 @@ # Locate or install Sphinx (Python documentation generator) # # Variables defined by this module: -# SPHINX_FOUND -# SPHINX_EXECUTABLE (CACHE) +# Sphinx_FOUND +# Sphinx_EXECUTABLE (CACHE) # # Targets defined by this module: # Sphinx - custom pip target, if package can be installed @@ -13,7 +13,7 @@ # Usage: # find_package(Sphinx) # -# If Sphinx is not installed in a standard path, add it to the SPHINX_DIRS +# If Sphinx is not installed in a standard path, add it to the Sphinx_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, Sphinx will be # installed via pip at build time. @@ -23,7 +23,7 @@ find_package(PythonInterp 2.7 QUIET) if(NOT TARGET Sphinx) add_custom_target(Sphinx) - set(_SPHINX_TARGET_CREATE TRUE) + set(_Sphinx_TARGET_CREATE TRUE) endif() if(PYTHONINTERP_FOUND AND WIN32) @@ -35,13 +35,12 @@ endif() ### Try to find package ### if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) - # Find sphinx-build - find_program(SPHINX_EXECUTABLE + find_program(Sphinx_EXECUTABLE NAMES sphinx-build HINTS - ${SPHINX_DIRS} + ${Sphinx_ROOT} ${PYTHON_SCRIPTS_DIR} ) @@ -53,30 +52,30 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Sphinx REQUIRED_VARS - SPHINX_EXECUTABLE + Sphinx_EXECUTABLE ) - set(SPHINX_FOUND ${Sphinx_FOUND}) + set(Sphinx_FOUND ${Sphinx_FOUND}) endif() ############################################################################### ### Install package from PyPi ### -if(NOT SPHINX_FOUND) +if(NOT Sphinx_FOUND) set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") # Set find_package standard args - set(SPHINX_FOUND TRUE) + set(Sphinx_FOUND TRUE) if(WIN32) - set(SPHINX_EXECUTABLE "${_EXT_DIST_ROOT}/Scripts/sphinx-build") + set(Sphinx_EXECUTABLE "${_EXT_DIST_ROOT}/Scripts/sphinx-build") # On Windows platform, pip is in the Scripts sub-directory. set(_PYTHON_PIP "${PYTHON_SCRIPTS_DIR}/pip.exe") else() - set(SPHINX_EXECUTABLE "${_EXT_DIST_ROOT}/bin/sphinx-build") + set(Sphinx_EXECUTABLE "${_EXT_DIST_ROOT}/bin/sphinx-build") set(_PYTHON_PIP "pip") endif() # Configure install target - if(_SPHINX_TARGET_CREATE) + if(_Sphinx_TARGET_CREATE) add_custom_command( TARGET Sphinx @@ -88,8 +87,8 @@ if(NOT SPHINX_FOUND) "${CMAKE_BINARY_DIR}" ) - message(STATUS "Installing Sphinx: ${SPHINX_EXECUTABLE} (version ${Sphinx_FIND_VERSION})") + message(STATUS "Installing Sphinx: ${Sphinx_EXECUTABLE} (version \"${Sphinx_FIND_VERSION}\")") endif() endif() -mark_as_advanced(SPHINX_EXECUTABLE) +mark_as_advanced(Sphinx_EXECUTABLE) diff --git a/share/cmake/modules/FindYamlCpp.cmake b/share/cmake/modules/FindYamlCpp.cmake deleted file mode 100644 index b306a78853..0000000000 --- a/share/cmake/modules/FindYamlCpp.cmake +++ /dev/null @@ -1,221 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright Contributors to the OpenColorIO Project. -# -# Locate or install yaml-cpp -# -# Variables defined by this module: -# YAMLCPP_FOUND - If FALSE, do not try to link to yamlcpp -# YAMLCPP_LIBRARY - Where to find yaml-cpp -# YAMLCPP_INCLUDE_DIR - Where to find yaml.h -# YAMLCPP_VERSION - The version of the library -# -# Targets defined by this module: -# yamlcpp::yamlcpp - IMPORTED target, if found -# -# By default, the dynamic libraries of yaml-cpp will be found. To find the -# static ones instead, you must set the YAMLCPP_STATIC_LIBRARY variable to -# TRUE before calling find_package(YamlCpp ...). -# -# If yaml-cpp is not installed in a standard path, you can use the -# YAMLCPP_DIRS variable to tell CMake where to find it. If it is not found -# and OCIO_INSTALL_EXT_PACKAGES is set to MISSING or ALL, yaml-cpp will be -# downloaded, built, and statically-linked into libOpenColorIO at build time. -# - -if(NOT TARGET yamlcpp::yamlcpp) - add_library(yamlcpp::yamlcpp UNKNOWN IMPORTED GLOBAL) - set(_YAMLCPP_TARGET_CREATE TRUE) -endif() - -############################################################################### -### Try to find package ### - -if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) - # Try to use pkg-config to get the version - find_package(PkgConfig QUIET) - pkg_check_modules(PC_YAMLCPP QUIET yaml-cpp) - - set(_YAMLCPP_SEARCH_DIRS - ${YAMLCPP_DIRS} - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - ) - - # Find include directory - find_path(YAMLCPP_INCLUDE_DIR - NAMES - yaml-cpp/yaml.h - HINTS - ${_YAMLCPP_SEARCH_DIRS} - ${PC_YAMLCPP_INCLUDE_DIRS} - PATH_SUFFIXES - include - yaml-cpp/include - ) - - # Lib names to search for - set(_YAMLCPP_LIB_NAMES yaml-cpp) - if(WIN32 AND BUILD_TYPE_DEBUG) - # Prefer Debug lib names (Windows only) - list(INSERT _YAMLCPP_LIB_NAMES 0 yaml-cppd) - endif() - - if(YAMLCPP_STATIC_LIBRARY) - # Prefer static lib names - if(WIN32) - set(_YAMLCPP_LIB_SUFFIX "md") - endif() - set(_YAMLCPP_STATIC_LIB_NAMES - "libyaml-cpp${_YAMLCPP_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") - if(WIN32 AND BUILD_TYPE_DEBUG) - # Prefer static Debug lib names (Windows only) - list(INSERT _YAMLCPP_STATIC_LIB_NAMES 0 - "libyaml-cpp${_YAMLCPP_LIB_SUFFIX}d${CMAKE_STATIC_LIBRARY_SUFFIX}") - endif() - endif() - - # Find library - find_library(YAMLCPP_LIBRARY - NAMES - ${_YAMLCPP_STATIC_LIB_NAMES} - ${_YAMLCPP_LIB_NAMES} - HINTS - ${_YAMLCPP_SEARCH_DIRS} - ${PC_YAMLCPP_LIBRARY_DIRS} - PATH_SUFFIXES - lib64 lib - ) - - # Get version from config if it was found. - if(PC_YAMLCPP_VERSION) - set(YAMLCPP_VERSION "${PC_YAMLCPP_VERSION}") - elseif(EXISTS "${YAMLCPP_INCLUDE_DIR}/yaml-cpp/iterator.h") - set(YAMLCPP_VERSION "0.3.0") - elseif(EXISTS "${YAMLCPP_INCLUDE_DIR}/yaml-cpp/noncopyable.h") - # The version is higher than 0.3.0 but lower than 0.6.3 - # i.e. the version 0.6.3 removes the file 'yaml-cpp/noncopyable.h. - set(YAMLCPP_VERSION "0.5.3") - else() - # The only supported version. - set(YAMLCPP_VERSION "0.6.3") - endif() - - # Override REQUIRED if package can be installed - if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) - set(YamlCpp_FIND_REQUIRED FALSE) - endif() - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(YamlCpp - REQUIRED_VARS - YAMLCPP_INCLUDE_DIR - YAMLCPP_LIBRARY - VERSION_VAR - YAMLCPP_VERSION - ) - set(YAMLCPP_FOUND ${YamlCpp_FOUND}) -endif() - -############################################################################### -### Install package from source ### - -if(NOT YAMLCPP_FOUND) - include(ExternalProject) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") - - # Set find_package standard args - set(YAMLCPP_FOUND TRUE) - set(YAMLCPP_VERSION ${YamlCpp_FIND_VERSION}) - set(YAMLCPP_INCLUDE_DIR "${_EXT_DIST_ROOT}/include") - - # Set the expected library name - if(WIN32) - set(_YAMLCPP_LIB_SUFFIX "md") - if(BUILD_TYPE_DEBUG) - string(APPEND _YAMLCPP_LIB_SUFFIX "d") - endif() - endif() - set(YAMLCPP_LIBRARY - "${_EXT_DIST_ROOT}/lib/libyaml-cpp${_YAMLCPP_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") - - if(_YAMLCPP_TARGET_CREATE) - if(MSVC) - set(YAMLCPP_CXX_FLAGS "${YAMLCPP_CXX_FLAGS} /EHsc") - endif() - - if(UNIX) - set(YAMLCPP_CXX_FLAGS "${YAMLCPP_CXX_FLAGS} -fvisibility=hidden -fPIC") - if(OCIO_INLINES_HIDDEN) - set(YAMLCPP_CXX_FLAGS "${YAMLCPP_CXX_FLAGS} -fvisibility-inlines-hidden") - endif() - endif() - - string(STRIP "${YAMLCPP_CXX_FLAGS}" YAMLCPP_CXX_FLAGS) - - set(YAMLCPP_CMAKE_ARGS - ${YAMLCPP_CMAKE_ARGS} - -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DBUILD_SHARED_LIBS:BOOL=OFF - -DYAML_BUILD_SHARED_LIBS:BOOL=OFF - -DYAML_CPP_BUILD_TESTS:BOOL=OFF - -DYAML_CPP_BUILD_TOOLS:BOOL=OFF - -DYAML_CPP_BUILD_CONTRIB:BOOL=OFF - -DCMAKE_CXX_FLAGS=${YAMLCPP_CXX_FLAGS} - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - ) - if(CMAKE_TOOLCHAIN_FILE) - set(YAMLCPP_CMAKE_ARGS - ${YAMLCPP_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) - 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 YamlCpp. " - "YampCpp symbols are NOT included in the output binary!" - ) - endif() - - set(YAMLCPP_GIT_TAG "yaml-cpp-${YAMLCPP_VERSION}") - - # Hack to let imported target be built from ExternalProject_Add - file(MAKE_DIRECTORY ${YAMLCPP_INCLUDE_DIR}) - - ExternalProject_Add(yamlcpp_install - GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git" - GIT_TAG ${YAMLCPP_GIT_TAG} - GIT_CONFIG advice.detachedHead=false - GIT_SHALLOW TRUE - PREFIX "${_EXT_BUILD_ROOT}/yaml-cpp" - BUILD_BYPRODUCTS ${YAMLCPP_LIBRARY} - CMAKE_ARGS ${YAMLCPP_CMAKE_ARGS} - EXCLUDE_FROM_ALL TRUE - ) - - add_dependencies(yamlcpp::yamlcpp yamlcpp_install) - message(STATUS - "Installing YamlCpp: ${YAMLCPP_LIBRARY} (version ${YAMLCPP_VERSION})" - ) - endif() -endif() - -############################################################################### -### Configure target ### - -if(_YAMLCPP_TARGET_CREATE) - set_target_properties(yamlcpp::yamlcpp PROPERTIES - IMPORTED_LOCATION ${YAMLCPP_LIBRARY} - INTERFACE_INCLUDE_DIRECTORIES ${YAMLCPP_INCLUDE_DIR} - ) - - mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY YAMLCPP_VERSION) -endif() diff --git a/share/cmake/modules/Findexpat.cmake b/share/cmake/modules/Findexpat.cmake new file mode 100644 index 0000000000..9f9a2f3254 --- /dev/null +++ b/share/cmake/modules/Findexpat.cmake @@ -0,0 +1,218 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. +# +# Locate or install expat +# +# Variables defined by this module: +# expat_FOUND - If FALSE, do not try to link to expat +# expat_LIBRARY - expat library to link to +# expat_INCLUDE_DIR - Where to find expat.h +# expat_VERSION - The version of the library +# +# Targets defined by this module: +# expat::expat - IMPORTED target, if found +# +# By default, the dynamic libraries of expat will be found. To find the static +# ones instead, you must set the expat_STATIC_LIBRARY variable to TRUE +# before calling find_package(expat ...). +# +# If expat is not installed in a standard path, you can use the expat_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, expat will be downloaded, +# built, and statically-linked into libOpenColorIO at build time. +# + +############################################################################### +### Try to find package ### + +if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) + set(_expat_REQUIRED_VARS expat_LIBRARY) + + if(NOT DEFINED expat_ROOT) + # Search for expat-config.cmake + find_package(expat ${expat_FIND_VERSION} CONFIG QUIET) + endif() + + if(expat_FOUND) + get_target_property(expat_LIBRARY expat::expat LOCATION) + else() + list(APPEND _expat_REQUIRED_VARS expat_INCLUDE_DIR) + + # Search for expat.pc + find_package(PkgConfig QUIET) + pkg_check_modules(PC_expat QUIET "expat>=${expat_FIND_VERSION}") + + # Find include directory + find_path(expat_INCLUDE_DIR + NAMES + expat.h + HINTS + ${expat_ROOT} + ${PC_expat_INCLUDE_DIRS} + PATH_SUFFIXES + include + expat/include + ) + + # Lib names to search for + set(_expat_LIB_NAMES expat libexpat) + if(WIN32 AND BUILD_TYPE_DEBUG) + # Prefer Debug lib names (Windows only) + list(INSERT _expat_LIB_NAMES 0 expatd) + endif() + + if(expat_STATIC_LIBRARY) + # Prefer static lib names + set(_expat_STATIC_LIB_NAMES + "${CMAKE_STATIC_LIBRARY_PREFIX}expat${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(WIN32 AND BUILD_TYPE_DEBUG) + # Prefer static Debug lib names (Windows only) + list(INSERT _expat_STATIC_LIB_NAMES 0 + "${CMAKE_STATIC_LIBRARY_PREFIX}expatd${CMAKE_STATIC_LIBRARY_SUFFIX}") + endif() + endif() + + # Find library + find_library(expat_LIBRARY + NAMES + ${_expat_STATIC_LIB_NAMES} + ${_expat_LIB_NAMES} + HINTS + ${expat_ROOT} + ${PC_expat_LIBRARY_DIRS} + PATH_SUFFIXES + lib64 lib + ) + + # Get version from header or pkg-config + if(expat_INCLUDE_DIR AND EXISTS "${expat_INCLUDE_DIR}/expat.h") + file(STRINGS "${expat_INCLUDE_DIR}/expat.h" _expat_VER_SEARCH + REGEX "^[ \t]*#define[ \t]+XML_(MAJOR|MINOR|MICRO)_VERSION[ \t]+[0-9]+.*$") + if(_expat_VER_SEARCH) + foreach(_VER_PART MAJOR MINOR MICRO) + string(REGEX REPLACE ".*#define[ \t]+XML_${_VER_PART}_VERSION[ \t]+([0-9]+).*" + "\\1" expat_VERSION_${_VER_PART} "${_expat_VER_SEARCH}") + if(NOT expat_VERSION_${_VER_PART}) + set(expat_VERSION_${_VER_PART} 0) + endif() + endforeach() + set(expat_VERSION + "${expat_VERSION_MAJOR}.${expat_VERSION_MINOR}.${expat_VERSION_MICRO}") + endif() + elseif(PC_expat_FOUND) + set(expat_VERSION "${PC_expat_VERSION}") + endif() + endif() + + # Override REQUIRED if package can be installed + if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) + set(expat_FIND_REQUIRED FALSE) + endif() + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(expat + REQUIRED_VARS + ${_expat_REQUIRED_VARS} + VERSION_VAR + expat_VERSION + ) +endif() + +############################################################################### +### Create target + +if(NOT TARGET expat::expat) + add_library(expat::expat UNKNOWN IMPORTED GLOBAL) + set(_expat_TARGET_CREATE TRUE) +endif() + +############################################################################### +### Install package from source ### + +if(NOT expat_FOUND) + 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(expat_FOUND TRUE) + set(expat_VERSION ${expat_FIND_VERSION}) + set(expat_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") + + # Set the expected library name + if(WIN32) + if(BUILD_TYPE_DEBUG) + set(_expat_LIB_SUFFIX "d") + endif() + # Static Linking, Multi-threaded Dll naming (>=2.2.8): + # https://github.com/libexpat/libexpat/blob/R_2_2_8/expat/win32/README.txt + set(_expat_LIB_SUFFIX "${_expat_LIB_SUFFIX}MD") + endif() + set(expat_LIBRARY + "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}expat${_expat_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") + + if(_expat_TARGET_CREATE) + if(UNIX) + set(EXPAT_C_FLAGS "${EXPAT_C_FLAGS} -fPIC") + set(EXPAT_CXX_FLAGS "${EXPAT_CXX_FLAGS} -fPIC") + endif() + + if(MSVC) + set(EXPAT_C_FLAGS "${EXPAT_C_FLAGS} /EHsc") + set(EXPAT_CXX_FLAGS "${EXPAT_CXX_FLAGS} /EHsc") + endif() + + string(STRIP "${EXPAT_C_FLAGS}" EXPAT_C_FLAGS) + string(STRIP "${EXPAT_CXX_FLAGS}" EXPAT_CXX_FLAGS) + + set(EXPAT_CMAKE_ARGS + ${EXPAT_CMAKE_ARGS} + -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DEXPAT_BUILD_TOOLS=OFF + -DEXPAT_BUILD_EXAMPLES=OFF + -DEXPAT_BUILD_TESTS=OFF + -DEXPAT_SHARED_LIBS=OFF + -DEXPAT_BUILD_DOCS=OFF + -DCMAKE_C_FLAGS=${EXPAT_C_FLAGS} + -DCMAKE_CXX_FLAGS=${EXPAT_CXX_FLAGS} + -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + ) + if(CMAKE_TOOLCHAIN_FILE) + set(EXPAT_CMAKE_ARGS + ${EXPAT_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() + + # Hack to let imported target be built from ExternalProject_Add + file(MAKE_DIRECTORY ${expat_INCLUDE_DIR}) + + ExternalProject_Add(expat_install + GIT_REPOSITORY "https://github.com/libexpat/libexpat.git" + GIT_TAG "R_${expat_FIND_VERSION_MAJOR}_${expat_FIND_VERSION_MINOR}_${expat_FIND_VERSION_PATCH}" + GIT_CONFIG advice.detachedHead=false + GIT_SHALLOW TRUE + PREFIX "${_EXT_BUILD_ROOT}/libexpat" + BUILD_BYPRODUCTS ${expat_LIBRARY} + SOURCE_SUBDIR expat + CMAKE_ARGS ${EXPAT_CMAKE_ARGS} + EXCLUDE_FROM_ALL TRUE + ) + + add_dependencies(expat::expat expat_install) + message(STATUS "Installing expat: ${expat_LIBRARY} (version \"${expat_VERSION}\")") + endif() +endif() + +############################################################################### +### Configure target ### + +if(_expat_TARGET_CREATE) + set_target_properties(expat::expat PROPERTIES + IMPORTED_LOCATION ${expat_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${expat_INCLUDE_DIR} + ) + + mark_as_advanced(expat_INCLUDE_DIR expat_LIBRARY expat_VERSION) +endif() diff --git a/share/cmake/modules/FindLCMS2.cmake b/share/cmake/modules/Findlcms2.cmake similarity index 51% rename from share/cmake/modules/FindLCMS2.cmake rename to share/cmake/modules/Findlcms2.cmake index 60501bfd50..8bc9832412 100644 --- a/share/cmake/modules/FindLCMS2.cmake +++ b/share/cmake/modules/Findlcms2.cmake @@ -4,27 +4,27 @@ # Locate or install lcms2 # # Variables defined by this module: -# LCMS2_FOUND - If FALSE, do not try to link to lcms -# LCMS2_LIBRARY - Where to find lcms -# LCMS2_INCLUDE_DIR - Where to find lcms2.h -# LCMS2_VERSION - The version of the library +# lcms2_FOUND - If FALSE, do not try to link to lcms +# lcms2_LIBRARY - Where to find lcms +# lcms2_INCLUDE_DIR - Where to find lcms2.h +# lcms2_VERSION - The version of the library # # Targets defined by this module: # lcms2::lcms2 - IMPORTED target, if found # -# By default, the dynamic libraries of LCMS2 will be found. To find the static -# ones instead, you must set the LCMS2_STATIC_LIBRARY variable to TRUE -# before calling find_package(LCMS2 ...). +# By default, the dynamic libraries of lcms2 will be found. To find the static +# ones instead, you must set the lcms2_STATIC_LIBRARY variable to TRUE +# before calling find_package(lcms2 ...). # -# If LCMS2 is not installed in a standard path, you can use the LCMS2_DIRS +# If lcms2 is not installed in a standard path, you can use the lcms2_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, LCMS2 will be +# OCIO_INSTALL_EXT_PACKAGES is set to MISSING or ALL, lcms2 will be # downloaded, built, and statically-linked into libOpenColorIO at build time. # if(NOT TARGET lcms2::lcms2) add_library(lcms2::lcms2 UNKNOWN IMPORTED GLOBAL) - set(_LCMS2_TARGET_CREATE TRUE) + set(_lcms2_TARGET_CREATE TRUE) endif() ############################################################################### @@ -33,27 +33,15 @@ endif() if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) # Try to use pkg-config to get the version find_package(PkgConfig QUIET) - pkg_check_modules(PC_LCMS2 QUIET lcms2) - - set(_LCMS2_SEARCH_DIRS - ${LCMS2_DIRS} - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - ) + pkg_check_modules(PC_lcms2 QUIET "lcms2>=${lcms2_FIND_VERSION}") # Find include directory - find_path(LCMS2_INCLUDE_DIR + find_path(lcms2_INCLUDE_DIR NAMES lcms2.h HINTS - ${_LCMS2_SEARCH_DIRS} - ${PC_LCMS2_INCLUDE_DIRS} + ${lcms2_ROOT} + ${PC_lcms2_INCLUDE_DIRS} PATH_SUFFIXES include lcms2/include @@ -61,118 +49,118 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) ) # Attempt to find static library first if this is set - if(LCMS2_STATIC_LIBRARY) - set(_LCMS2_STATIC "${CMAKE_STATIC_LIBRARY_PREFIX}lcms2${CMAKE_STATIC_LIBRARY_SUFFIX}") + if(lcms2_STATIC_LIBRARY) + set(_lcms2_STATIC "${CMAKE_STATIC_LIBRARY_PREFIX}lcms2${CMAKE_STATIC_LIBRARY_SUFFIX}") endif() # Find library - find_library(LCMS2_LIBRARY + find_library(lcms2_LIBRARY NAMES - ${_LCMS2_STATIC} lcms2 liblcms2 + ${_lcms2_STATIC} lcms2 liblcms2 HINTS - ${_LCMS2_SEARCH_DIRS} - ${PC_LCMS2_LIBRARY_DIRS} + ${_lcms2_SEARCH_DIRS} + ${PC_lcms2_LIBRARY_DIRS} PATH_SUFFIXES lib64 lib ) # Get version from config or header file - if(LCMS2_INCLUDE_DIR AND EXISTS "${LCMS2_INCLUDE_DIR}/lcms2.h") - file(STRINGS "${LCMS2_INCLUDE_DIR}/lcms2.h" _LCMS2_VER_SEARCH + if(lcms2_INCLUDE_DIR AND EXISTS "${lcms2_INCLUDE_DIR}/lcms2.h") + file(STRINGS "${lcms2_INCLUDE_DIR}/lcms2.h" _lcms2_VER_SEARCH REGEX "^[ \t]*//[ \t]+Version[ \t]+[.0-9]+.*$") - if(_LCMS2_VER_SEARCH) + if(_lcms2_VER_SEARCH) string(REGEX REPLACE ".*//[ \t]+Version[ \t]+([.0-9]+).*" - "\\1" LCMS2_VERSION "${_LCMS2_VER_SEARCH}") + "\\1" lcms2_VERSION "${_lcms2_VER_SEARCH}") endif() - elseif(PC_LCMS2_FOUND) - set(LCMS2_VERSION "${PC_LCMS2_VERSION}") + elseif(PC_lcms2_FOUND) + set(lcms2_VERSION "${PC_lcms2_VERSION}") endif() # Override REQUIRED if package can be installed if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) - set(LCMS2_FIND_REQUIRED FALSE) + set(lcms2_FIND_REQUIRED FALSE) endif() include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(LCMS2 + find_package_handle_standard_args(lcms2 REQUIRED_VARS - LCMS2_INCLUDE_DIR - LCMS2_LIBRARY + lcms2_INCLUDE_DIR + lcms2_LIBRARY VERSION_VAR - LCMS2_VERSION + lcms2_VERSION ) endif() ############################################################################### ### Install package from source ### -if(NOT LCMS2_FOUND) +if(NOT lcms2_FOUND) include(ExternalProject) set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") # Set find_package standard args - set(LCMS2_FOUND TRUE) - set(LCMS2_VERSION ${LCMS2_FIND_VERSION}) - set(LCMS2_INCLUDE_DIR "${_EXT_DIST_ROOT}/include/lcms2") - set(LCMS2_LIBRARY + set(lcms2_FOUND TRUE) + set(lcms2_VERSION ${lcms2_FIND_VERSION}) + set(lcms2_INCLUDE_DIR "${_EXT_DIST_ROOT}/include/lcms2") + set(lcms2_LIBRARY "${_EXT_DIST_ROOT}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}lcms2${CMAKE_STATIC_LIBRARY_SUFFIX}") - if(_LCMS2_TARGET_CREATE) + if(_lcms2_TARGET_CREATE) if(UNIX) - set(LCMS2_C_FLAGS "${LCMS2_C_FLAGS} -fPIC") + set(lcms2_C_FLAGS "${lcms2_C_FLAGS} -fPIC") endif() if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") - set(LCMS2_C_FLAGS "${LCMS2_C_FLAGS} -Wno-aggressive-loop-optimizations") + set(lcms2_C_FLAGS "${lcms2_C_FLAGS} -Wno-aggressive-loop-optimizations") endif() - string(STRIP "${LCMS2_C_FLAGS}" LCMS2_C_FLAGS) + string(STRIP "${lcms2_C_FLAGS}" lcms2_C_FLAGS) - set(LCMS2_CMAKE_ARGS - ${LCMS2_CMAKE_ARGS} + set(lcms2_CMAKE_ARGS + ${lcms2_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DBUILD_SHARED_LIBS:BOOL=OFF - -DCMAKE_C_FLAGS=${LCMS2_C_FLAGS} + -DBUILD_SHARED_LIBS=OFF + -DCMAKE_C_FLAGS=${lcms2_C_FLAGS} ) if(CMAKE_TOOLCHAIN_FILE) - set(LCMS2_CMAKE_ARGS - ${LCMS2_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + set(lcms2_CMAKE_ARGS + ${lcms2_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) endif() # Hack to let imported target be built from ExternalProject_Add - file(MAKE_DIRECTORY ${LCMS2_INCLUDE_DIR}) + file(MAKE_DIRECTORY ${lcms2_INCLUDE_DIR}) ExternalProject_Add(lcms2_install GIT_REPOSITORY "https://github.com/mm2/Little-CMS.git" - GIT_TAG "lcms${LCMS2_VERSION}" + GIT_TAG "lcms${lcms2_VERSION}" GIT_CONFIG advice.detachedHead=false GIT_SHALLOW TRUE PREFIX "${_EXT_BUILD_ROOT}/Little-CMS" - BUILD_BYPRODUCTS ${LCMS2_LIBRARY} + BUILD_BYPRODUCTS ${lcms2_LIBRARY} PATCH_COMMAND ${CMAKE_COMMAND} -E copy - "${CMAKE_SOURCE_DIR}/share/cmake/projects/BuildLCMS2.cmake" + "${CMAKE_SOURCE_DIR}/share/cmake/projects/Buildlcms2.cmake" "CMakeLists.txt" - CMAKE_ARGS ${LCMS2_CMAKE_ARGS} + CMAKE_ARGS ${lcms2_CMAKE_ARGS} EXCLUDE_FROM_ALL TRUE ) add_dependencies(lcms2::lcms2 lcms2_install) - message(STATUS "Installing LCMS2: ${LCMS2_LIBRARY} (version ${LCMS2_VERSION})") + message(STATUS "Installing lcms2: ${lcms2_LIBRARY} (version \"${lcms2_VERSION}\")") endif() endif() ############################################################################### ### Configure target ### -if(_LCMS2_TARGET_CREATE) +if(_lcms2_TARGET_CREATE) set_target_properties(lcms2::lcms2 PROPERTIES - IMPORTED_LOCATION ${LCMS2_LIBRARY} - INTERFACE_INCLUDE_DIRECTORIES ${LCMS2_INCLUDE_DIR} + IMPORTED_LOCATION ${lcms2_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${lcms2_INCLUDE_DIR} ) - mark_as_advanced(LCMS2_INCLUDE_DIR LCMS2_LIBRARY LCMS2_VERSION) + mark_as_advanced(lcms2_INCLUDE_DIR lcms2_LIBRARY lcms2_VERSION) endif() diff --git a/share/cmake/modules/Findpybind11.cmake b/share/cmake/modules/Findpybind11.cmake index 0467b71454..2f53c2aa2e 100644 --- a/share/cmake/modules/Findpybind11.cmake +++ b/share/cmake/modules/Findpybind11.cmake @@ -9,7 +9,7 @@ # pybind11::module - IMPORTED target, if found # # If pybind11 is not installed in a standard path, you can use the -# pybind11_DIRS variable to tell CMake where to find it. If it is not found +# pybind11_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, pybind11 will be # downloaded at build time. # @@ -18,18 +18,21 @@ ### Try to find package ### if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) - if(DEFINED pybind11_DIRS) - # Try user defined search path first. Ignore all default cmake and - # system paths, and fall back on a system CMake config. + if(NOT DEFINED pybind11_ROOT) + # Search for pybind11Config.cmake + find_package(pybind11 ${pybind11_FIND_VERSION} CONFIG QUIET) + endif() + + if(NOT pybind11_FOUND) + # Find include directory find_path(pybind11_INCLUDE_DIR NAMES pybind11/pybind11.h HINTS - ${pybind11_DIRS} + ${pybind11_ROOT} PATH_SUFFIXES include pybind11/include - NO_DEFAULT_PATH ) # Version information can be extracted from this header @@ -48,67 +51,56 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) "\\1" _pybind11_PATCH "${_pybind11_VER_SEARCH}") set(pybind11_VERSION "${_pybind11_MAJOR}.${_pybind11_MINOR}.${_pybind11_PATCH}") - message(STATUS - "Using user defined search path for pybind11 " - "(found version \"${pybind11_VERSION}\")" - ) endif() endif() endif() - if(NOT DEFINED pybind11_VERSION) - # Search for a CMake config, which should have been installed with - # pybind11, and will provide version information. - find_package(pybind11 ${pybind11_FIND_VERSION} CONFIG) - - if(NOT pybind11_FOUND) - # No CMake config found. Check if pybind11 was installed as a - # Python package (i.e. with "pip install pybind11"). This requires - # a Python interpreter. - find_package(PythonInterp 2.7 QUIET) + if(NOT pybind11_VERSION) + # Check if pybind11 was installed as a Python package (i.e. with + # "pip install pybind11"). This requires a Python interpreter. + find_package(PythonInterp 2.7 QUIET) + + if(PYTHONINTERP_FOUND) + execute_process( + COMMAND + "${PYTHON_EXECUTABLE}" -c + "print(__import__('pybind11').__version__)" + RESULTS_VARIABLE + _pybind11_VER_RESULTS + OUTPUT_VARIABLE + _pybind11_VER_OUTPUT + ERROR_QUIET + ) + if(_pybind11_VER_OUTPUT) + # Strip \n from python output + string(STRIP ${_pybind11_VER_OUTPUT} _pybind11_VER_OUTPUT) + endif() - if(PYTHONINTERP_FOUND) + if(_pybind11_VER_RESULTS EQUAL 0 AND "${_pybind11_VER_OUTPUT}" MATCHES "[.0-9]+") execute_process( COMMAND "${PYTHON_EXECUTABLE}" -c - "print(__import__('pybind11').__version__)" + "import os;\ + import pybind11;\ + print(os.path.join(os.path.dirname(pybind11.__file__), 'include'))" RESULTS_VARIABLE - _pybind11_VER_RESULTS + _pybind11_DIR_RESULTS OUTPUT_VARIABLE - _pybind11_VER_OUTPUT + _pybind11_DIR_OUTPUT ERROR_QUIET ) - if(_pybind11_VER_OUTPUT) + if(_pybind11_DIR_OUTPUT) # Strip \n from python output - string(STRIP ${_pybind11_VER_OUTPUT} _pybind11_VER_OUTPUT) + string(STRIP ${_pybind11_DIR_OUTPUT} _pybind11_DIR_OUTPUT) endif() - if(_pybind11_VER_RESULTS EQUAL 0 AND "${_pybind11_VER_OUTPUT}" MATCHES "[.0-9]+") - execute_process( - COMMAND - "${PYTHON_EXECUTABLE}" -c - "import os;\ - import pybind11;\ - print(os.path.join(os.path.dirname(pybind11.__file__), 'include'))" - RESULTS_VARIABLE - _pybind11_DIR_RESULTS - OUTPUT_VARIABLE - _pybind11_DIR_OUTPUT - ERROR_QUIET + if(_pybind11_DIR_RESULTS EQUAL 0 AND EXISTS "${_pybind11_DIR_OUTPUT}") + set(pybind11_VERSION ${_pybind11_VER_OUTPUT}) + set(pybind11_INCLUDE_DIR ${_pybind11_DIR_OUTPUT}) + message(STATUS + "Using pybind11 python package (version \"${pybind11_VERSION}\", " + "found in python \"${PYTHON_VERSION_STRING}\")" ) - if(_pybind11_DIR_OUTPUT) - # Strip \n from python output - string(STRIP ${_pybind11_DIR_OUTPUT} _pybind11_DIR_OUTPUT) - endif() - - if(_pybind11_DIR_RESULTS EQUAL 0 AND EXISTS "${_pybind11_DIR_OUTPUT}") - set(pybind11_VERSION ${_pybind11_VER_OUTPUT}) - set(pybind11_INCLUDE_DIR ${_pybind11_DIR_OUTPUT}) - message(STATUS - "Using pybind11 python package (version \"${pybind11_VERSION}\", " - "found in python \"${PYTHON_VERSION_STRING}\")" - ) - endif() endif() endif() endif() @@ -141,6 +133,7 @@ endif() if(NOT pybind11_FOUND) include(ExternalProject) + include(GNUInstallDirs) set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") @@ -148,7 +141,7 @@ if(NOT pybind11_FOUND) # Set find_package standard args set(pybind11_FOUND TRUE) set(pybind11_VERSION ${pybind11_FIND_VERSION}) - set(pybind11_INCLUDE_DIR "${_EXT_DIST_ROOT}/include") + set(pybind11_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") if(_pybind11_TARGET_CREATE) # Hack to let imported target be built from ExternalProject_Add @@ -157,8 +150,8 @@ if(NOT pybind11_FOUND) set(pybind11_CMAKE_ARGS ${pybind11_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DPYBIND11_INSTALL:BOOL=ON - -DPYBIND11_TEST:BOOL=OFF + -DPYBIND11_INSTALL=ON + -DPYBIND11_TEST=OFF ) ExternalProject_Add(pybind11_install @@ -172,7 +165,7 @@ if(NOT pybind11_FOUND) ) add_dependencies(pybind11::module pybind11_install) - message(STATUS "Installing pybind11: ${pybind11_INCLUDE_DIR} (version ${pybind11_VERSION})") + message(STATUS "Installing pybind11: ${pybind11_INCLUDE_DIR} (version \"${pybind11_VERSION}\")") endif() endif() diff --git a/share/cmake/modules/FindPystring.cmake b/share/cmake/modules/Findpystring.cmake similarity index 57% rename from share/cmake/modules/FindPystring.cmake rename to share/cmake/modules/Findpystring.cmake index 01bef2c074..a519f47d5a 100644 --- a/share/cmake/modules/FindPystring.cmake +++ b/share/cmake/modules/Findpystring.cmake @@ -4,166 +4,154 @@ # Locate or install pystring # # Variables defined by this module: -# PYSTRING_FOUND - If FALSE, do not try to link to pystring -# PYSTRING_LIBRARY - Where to find pystring -# PYSTRING_INCLUDE_DIR - Where to find pystring.h +# pystring_FOUND - If FALSE, do not try to link to pystring +# pystring_LIBRARY - Where to find pystring +# pystring_INCLUDE_DIR - Where to find pystring.h # # Targets defined by this module: # pystring::pystring - IMPORTED target, if found # # By default, the dynamic libraries of pystring will be found. To find the -# static ones instead, you must set the PYSTRING_STATIC_LIBRARY variable to -# TRUE before calling find_package(Pystring ...). +# static ones instead, you must set the pystring_STATIC_LIBRARY variable to +# TRUE before calling find_package(pystring ...). # # If pystring is not installed in a standard path, you can use the -# PYSTRING_DIRS variable to tell CMake where to find it. If it is not found +# pystring_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, pystring will be # downloaded, built, and statically-linked into libOpenColorIO at build time. # if(NOT TARGET pystring::pystring) add_library(pystring::pystring UNKNOWN IMPORTED GLOBAL) - set(_PYSTRING_TARGET_CREATE TRUE) + set(_pystring_TARGET_CREATE TRUE) endif() ############################################################################### ### Try to find package ### if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) - set(_PYSTRING_SEARCH_DIRS - ${PYSTRING_DIRS} - ~/Library/Frameworks - /Library/Frameworks - /usr/local - /usr - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt - ) - # Find include directory - find_path(PYSTRING_INCLUDE_DIR + find_path(pystring_INCLUDE_DIR NAMES pystring/pystring.h HINTS - ${_PYSTRING_SEARCH_DIRS} + ${pystring_ROOT} PATH_SUFFIXES include pystring/include ) # Attempt to find static library first if this is set - if(PYSTRING_STATIC_LIBRARY) - set(_PYSTRING_STATIC + if(pystring_STATIC_LIBRARY) + set(_pystring_STATIC "${CMAKE_STATIC_LIBRARY_PREFIX}pystring${CMAKE_STATIC_LIBRARY_SUFFIX}") endif() # Find library - find_library(PYSTRING_LIBRARY + find_library(pystring_LIBRARY NAMES - ${_PYSTRING_STATIC} pystring + ${_pystring_STATIC} pystring HINTS - ${_PYSTRING_SEARCH_DIRS} + ${_pystring_SEARCH_DIRS} PATH_SUFFIXES lib64 lib ) # Override REQUIRED if package can be installed if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) - set(Pystring_FIND_REQUIRED FALSE) + set(pystring_FIND_REQUIRED FALSE) endif() include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(Pystring + find_package_handle_standard_args(pystring REQUIRED_VARS - PYSTRING_INCLUDE_DIR - PYSTRING_LIBRARY + pystring_INCLUDE_DIR + pystring_LIBRARY ) - set(PYSTRING_FOUND ${Pystring_FOUND}) + set(pystring_FOUND ${pystring_FOUND}) endif() ############################################################################### ### Install package from source ### -if(NOT PYSTRING_FOUND) +if(NOT pystring_FOUND) include(ExternalProject) set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") # Set find_package standard args - set(PYSTRING_FOUND TRUE) - set(PYSTRING_VERSION ${Pystring_FIND_VERSION}) - set(PYSTRING_INCLUDE_DIR "${_EXT_DIST_ROOT}/include") - set(PYSTRING_LIBRARY + set(pystring_FOUND TRUE) + set(pystring_VERSION ${pystring_FIND_VERSION}) + set(pystring_INCLUDE_DIR "${_EXT_DIST_ROOT}/include") + set(pystring_LIBRARY "${_EXT_DIST_ROOT}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}pystring${CMAKE_STATIC_LIBRARY_SUFFIX}") - if(_PYSTRING_TARGET_CREATE) + if(_pystring_TARGET_CREATE) if(UNIX) - set(PYSTRING_CXX_FLAGS "${PYSTRING_CXX_FLAGS} -fvisibility=hidden -fPIC") + set(pystring_CXX_FLAGS "${pystring_CXX_FLAGS} -fvisibility=hidden -fPIC") if(OCIO_INLINES_HIDDEN) - set(PYSTRING_CXX_FLAGS "${PYSTRING_CXX_FLAGS} -fvisibility-inlines-hidden") + set(pystring_CXX_FLAGS "${pystring_CXX_FLAGS} -fvisibility-inlines-hidden") endif() endif() if(MSVC) - set(PYSTRING_CXX_FLAGS "${PYSTRING_CXX_FLAGS} /EHsc") + set(pystring_CXX_FLAGS "${pystring_CXX_FLAGS} /EHsc") endif() - string(STRIP "${PYSTRING_CXX_FLAGS}" PYSTRING_CXX_FLAGS) + string(STRIP "${pystring_CXX_FLAGS}" pystring_CXX_FLAGS) - set(PYSTRING_CMAKE_ARGS - ${PYSTRING_CMAKE_ARGS} + set(pystring_CMAKE_ARGS + ${pystring_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_CXX_FLAGS=${PYSTRING_CXX_FLAGS} + -DCMAKE_CXX_FLAGS=${pystring_CXX_FLAGS} -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} ) if(CMAKE_TOOLCHAIN_FILE) - set(PYSTRING_CMAKE_ARGS - ${PYSTRING_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + set(pystring_CMAKE_ARGS + ${pystring_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) 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!" + "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}) + file(MAKE_DIRECTORY ${pystring_INCLUDE_DIR}) ExternalProject_Add(pystring_install GIT_REPOSITORY "https://github.com/imageworks/pystring.git" - GIT_TAG "v${Pystring_FIND_VERSION}" + GIT_TAG "v${pystring_FIND_VERSION}" GIT_CONFIG advice.detachedHead=false GIT_SHALLOW TRUE PREFIX "${_EXT_BUILD_ROOT}/pystring" - BUILD_BYPRODUCTS ${PYSTRING_LIBRARY} + BUILD_BYPRODUCTS ${pystring_LIBRARY} PATCH_COMMAND ${CMAKE_COMMAND} -E copy - "${CMAKE_SOURCE_DIR}/share/cmake/projects/BuildPystring.cmake" + "${CMAKE_SOURCE_DIR}/share/cmake/projects/Buildpystring.cmake" "CMakeLists.txt" - CMAKE_ARGS ${PYSTRING_CMAKE_ARGS} + CMAKE_ARGS ${pystring_CMAKE_ARGS} EXCLUDE_FROM_ALL TRUE ) add_dependencies(pystring::pystring pystring_install) - message(STATUS "Installing Pystring: ${PYSTRING_LIBRARY} (version ${PYSTRING_VERSION})") + message(STATUS "Installing pystring: ${pystring_LIBRARY} (version \"${pystring_VERSION}\")") endif() endif() ############################################################################### ### Configure target ### -if(_PYSTRING_TARGET_CREATE) +if(_pystring_TARGET_CREATE) set_target_properties(pystring::pystring PROPERTIES - IMPORTED_LOCATION ${PYSTRING_LIBRARY} - INTERFACE_INCLUDE_DIRECTORIES ${PYSTRING_INCLUDE_DIR} + IMPORTED_LOCATION ${pystring_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${pystring_INCLUDE_DIR} ) - mark_as_advanced(PYSTRING_INCLUDE_DIR PYSTRING_LIBRARY PYSTRING_VERSION) + mark_as_advanced(pystring_INCLUDE_DIR pystring_LIBRARY pystring_VERSION) endif() diff --git a/share/cmake/modules/Findyaml-cpp.cmake b/share/cmake/modules/Findyaml-cpp.cmake new file mode 100644 index 0000000000..67aa488f11 --- /dev/null +++ b/share/cmake/modules/Findyaml-cpp.cmake @@ -0,0 +1,219 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. +# +# Locate or install yaml-cpp +# +# Variables defined by this module: +# yaml-cpp_FOUND - If FALSE, do not try to link to yamlcpp +# yaml-cpp_LIBRARY - yaml-cpp library to link to +# yaml-cpp_INCLUDE_DIR - Where to find yaml.h +# yaml-cpp_VERSION - The version of the library +# +# Targets defined by this module: +# yaml-cpp - IMPORTED target, if found +# +# By default, the dynamic libraries of yaml-cpp will be found. To find the +# static ones instead, you must set the yaml-cpp_STATIC_LIBRARY variable to +# TRUE before calling find_package(yaml-cpp ...). +# +# If yaml-cpp is not installed in a standard path, you can use the +# yaml-cpp_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, yaml-cpp will be +# downloaded, built, and statically-linked into libOpenColorIO at build time. +# + +############################################################################### +### Try to find package ### + +if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) + if(NOT DEFINED yaml-cpp_ROOT) + # Search for yaml-cpp-config.cmake + find_package(yaml-cpp ${yaml-cpp_FIND_VERSION} CONFIG QUIET) + endif() + + if(yaml-cpp_FOUND) + set(yaml-cpp_LIBRARY "${YAML_CPP_LIBRARIES}") + set(yaml-cpp_INCLUDE_DIR "${YAML_CPP_INCLUDE_DIR}") + else() + # Search for yaml-cpp.pc + find_package(PkgConfig QUIET) + pkg_check_modules(PC_yaml-cpp QUIET "yaml-cpp>=${yaml-cpp_FIND_VERSION}") + + # Find include directory + find_path(yaml-cpp_INCLUDE_DIR + NAMES + yaml-cpp/yaml.h + HINTS + ${yaml-cpp_ROOT} + ${PC_yaml-cpp_INCLUDE_DIRS} + PATH_SUFFIXES + include + yaml-cpp/include + ) + + # Lib names to search for + set(_yaml-cpp_LIB_NAMES yaml-cpp) + if(WIN32 AND BUILD_TYPE_DEBUG) + # Prefer Debug lib names (Windows only) + list(INSERT _yaml-cpp_LIB_NAMES 0 yaml-cppd) + endif() + + if(yaml-cpp_STATIC_LIBRARY) + # Prefer static lib names + if(WIN32) + 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) + # Prefer static Debug lib names (Windows only) + list(INSERT _yaml-cpp_STATIC_LIB_NAMES 0 + "libyaml-cpp${_yaml-cpp_LIB_SUFFIX}d${CMAKE_STATIC_LIBRARY_SUFFIX}") + endif() + endif() + + # Find library + find_library(yaml-cpp_LIBRARY + NAMES + ${_yaml-cpp_STATIC_LIB_NAMES} + ${_yaml-cpp_LIB_NAMES} + HINTS + ${_yaml-cpp_ROOT} + ${PC_yaml-cpp_LIBRARY_DIRS} + PATH_SUFFIXES + lib64 lib + ) + + # Get version from pkg-config if it was found. + if(PC_yaml-cpp_FOUND) + set(yaml-cpp_VERSION "${PC_yaml-cpp_VERSION}") + endif() + endif() + + # Override REQUIRED if package can be installed + if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) + set(yaml-cpp_FIND_REQUIRED FALSE) + endif() + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(yaml-cpp + REQUIRED_VARS + yaml-cpp_INCLUDE_DIR + yaml-cpp_LIBRARY + VERSION_VAR + yaml-cpp_VERSION + ) +endif() + +############################################################################### +### Create target (if previous 'find_package' call hasn't) ### + +if(NOT TARGET yaml-cpp) + add_library(yaml-cpp UNKNOWN IMPORTED GLOBAL) + set(_yaml-cpp_TARGET_CREATE TRUE) +endif() + +############################################################################### +### Install package from source ### + +if(NOT yaml-cpp_FOUND) + include(ExternalProject) + # TODO: yaml-cpp master is using GNUInstallDirs to define include and lib + # dir names. Once that change is released and OCIO updates the + # minimum yaml-cpp version, toggle the three disabled lines below. + #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(yaml-cpp_FOUND TRUE) + set(yaml-cpp_VERSION ${yaml-cpp_FIND_VERSION}) + set(yaml-cpp_INCLUDE_DIR "${_EXT_DIST_ROOT}/include") + #set(yaml-cpp_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") + + # Set the expected library name + if(WIN32) + set(_yaml-cpp_LIB_SUFFIX "md") + if(BUILD_TYPE_DEBUG) + string(APPEND _yaml-cpp_LIB_SUFFIX "d") + endif() + endif() + set(yaml-cpp_LIBRARY + "${_EXT_DIST_ROOT}/lib/libyaml-cpp${_yaml-cpp_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") + # set(yaml-cpp_LIBRARY + # "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/libyaml-cpp${_yaml-cpp_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") + + if(_yaml-cpp_TARGET_CREATE) + if(MSVC) + set(yaml-cpp_CXX_FLAGS "${yaml-cpp_CXX_FLAGS} /EHsc") + endif() + + if(UNIX) + set(yaml-cpp_CXX_FLAGS "${yaml-cpp_CXX_FLAGS} -fvisibility=hidden -fPIC") + if(OCIO_INLINES_HIDDEN) + set(yaml-cpp_CXX_FLAGS "${yaml-cpp_CXX_FLAGS} -fvisibility-inlines-hidden") + endif() + endif() + + string(STRIP "${yaml-cpp_CXX_FLAGS}" yaml-cpp_CXX_FLAGS) + + set(yaml-cpp_CMAKE_ARGS + ${yaml-cpp_CMAKE_ARGS} + -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DBUILD_SHARED_LIBS=OFF + -DYAML_BUILD_SHARED_LIBS=OFF + -DYAML_CPP_BUILD_TESTS=OFF + -DYAML_CPP_BUILD_TOOLS=OFF + -DYAML_CPP_BUILD_CONTRIB=OFF + -DCMAKE_CXX_FLAGS=${yaml-cpp_CXX_FLAGS} + -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + ) + if(CMAKE_TOOLCHAIN_FILE) + set(yaml-cpp_CMAKE_ARGS + ${yaml-cpp_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + 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 + file(MAKE_DIRECTORY ${yaml-cpp_INCLUDE_DIR}) + + ExternalProject_Add(yaml-cpp_install + GIT_REPOSITORY "https://github.com/jbeder/yaml-cpp.git" + GIT_TAG ${yaml-cpp_GIT_TAG} + GIT_CONFIG advice.detachedHead=false + GIT_SHALLOW TRUE + PREFIX "${_EXT_BUILD_ROOT}/yaml-cpp" + BUILD_BYPRODUCTS ${yaml-cpp_LIBRARY} + CMAKE_ARGS ${yaml-cpp_CMAKE_ARGS} + EXCLUDE_FROM_ALL TRUE + ) + + add_dependencies(yaml-cpp yaml-cpp_install) + message(STATUS + "Installing yaml-cpp: ${yaml-cpp_LIBRARY} (version \"${yaml-cpp_VERSION}\")" + ) + endif() +endif() + +############################################################################### +### Configure target ### + +if(_yaml-cpp_TARGET_CREATE) + set_target_properties(yaml-cpp PROPERTIES + IMPORTED_LOCATION ${yaml-cpp_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${yaml-cpp_INCLUDE_DIR} + ) + + mark_as_advanced(yaml-cpp_INCLUDE_DIR yaml-cpp_LIBRARY yaml-cpp_VERSION) +endif() diff --git a/share/cmake/projects/BuildLCMS2.cmake b/share/cmake/projects/Buildlcms2.cmake similarity index 100% rename from share/cmake/projects/BuildLCMS2.cmake rename to share/cmake/projects/Buildlcms2.cmake diff --git a/share/cmake/projects/BuildPystring.cmake b/share/cmake/projects/Buildpystring.cmake similarity index 81% rename from share/cmake/projects/BuildPystring.cmake rename to share/cmake/projects/Buildpystring.cmake index 9d90b076ad..0a6dee7939 100644 --- a/share/cmake/projects/BuildPystring.cmake +++ b/share/cmake/projects/Buildpystring.cmake @@ -16,11 +16,11 @@ set(SOURCES add_library(${PROJECT_NAME} STATIC ${HEADERS} ${SOURCES}) if(UNIX) - set(PYSTRING_CXX_FLAGS "${PYSTRING_CXX_FLAGS} -fPIC") + set(pystring_CXX_FLAGS "${pystring_CXX_FLAGS} -fPIC") endif() set_target_properties(${PROJECT_NAME} PROPERTIES - COMPILE_FLAGS "${PLATFORM_COMPILE_FLAGS} ${PYSTRING_CXX_FLAGS}" + COMPILE_FLAGS "${PLATFORM_COMPILE_FLAGS} ${pystring_CXX_FLAGS}" PUBLIC_HEADER "${HEADERS}" ) diff --git a/share/cmake/scripts/PatchOpenEXR.cmake b/share/cmake/scripts/PatchOpenEXR.cmake new file mode 100644 index 0000000000..e885d71794 --- /dev/null +++ b/share/cmake/scripts/PatchOpenEXR.cmake @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +# Disable OpenEXR in the root CMakeLists.txt file, so that only IlmBase is +# configured. +file(READ CMakeLists.txt _OpenEXR_CMAKE_DATA) +string(REGEX REPLACE "^(.*)(add_subdirectory\\(OpenEXR\\))(.*)$" "\\1#\\2\\3" + _OpenEXR_CMAKE_DATA "${_OpenEXR_CMAKE_DATA}") +file(WRITE CMakeLists.txt "${_OpenEXR_CMAKE_DATA}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index cf69e8876f..45dd12049e 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,11 +2,14 @@ # Copyright Contributors to the OpenColorIO Project. # The presence of OpenImageIO allows additional ocio apps to be built. -# These apps may also require the building of openglbuilder from utils +# These apps may also require the building of oglapphelpers from libutils # but because the builder also needs GLEW, we only conditionally build # this lib -find_package(OpenImageIO QUIET) +# OpenImageIO +# https://github.com/OpenImageIO/oiio +find_package(OpenImageIO 2.1.9 CONFIG) +package_root_message(OpenImageIO) # The order defines the architecture of the project i.e. layers and dependencies. diff --git a/src/OpenColorIO/CMakeLists.txt b/src/OpenColorIO/CMakeLists.txt index b7e594df56..cabad4248f 100755 --- a/src/OpenColorIO/CMakeLists.txt +++ b/src/OpenColorIO/CMakeLists.txt @@ -175,11 +175,11 @@ target_link_libraries(OpenColorIO public_api PRIVATE expat::expat - ilmbase::ilmbase + IlmBase::Half pystring::pystring sampleicc::sampleicc utils::strings - yamlcpp::yamlcpp + yaml-cpp ) if(NOT BUILD_SHARED_LIBS) diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt index 39446decce..52bac9fbce 100755 --- a/src/apps/CMakeLists.txt +++ b/src/apps/CMakeLists.txt @@ -8,12 +8,12 @@ if(OCIO_BUILD_APPS) add_subdirectory(ociomakeclf) add_subdirectory(ociowrite) - if(TARGET OpenImageIO) + if(TARGET OpenImageIO::OpenImageIO) add_subdirectory(ociolutimage) add_subdirectory(ocioconvert) add_subdirectory(ociodisplay) add_subdirectory(ocioperf) else() - message(WARNING "OpenImageIO Not found. Skipping build for ociolutimage, ocioconvert, ociodisplay and ocioperf") + message(WARNING "Could NOT find OpenImageIO. Skipping build for ociolutimage, ocioconvert, ociodisplay and ocioperf") endif() endif() diff --git a/src/apps/ocioconvert/CMakeLists.txt b/src/apps/ocioconvert/CMakeLists.txt index 85327d6689..68a5db17b6 100755 --- a/src/apps/ocioconvert/CMakeLists.txt +++ b/src/apps/ocioconvert/CMakeLists.txt @@ -27,11 +27,11 @@ set_target_properties(ocioconvert PROPERTIES target_link_libraries(ocioconvert PRIVATE apputils - ilmbase::ilmbase + IlmBase::Half ${OCIO_GL_LIB} oiiohelpers OpenColorIO - OpenImageIO + OpenImageIO::OpenImageIO ) install(TARGETS ocioconvert diff --git a/src/apps/ociodisplay/CMakeLists.txt b/src/apps/ociodisplay/CMakeLists.txt index cedf55bcef..8048460641 100755 --- a/src/apps/ociodisplay/CMakeLists.txt +++ b/src/apps/ociodisplay/CMakeLists.txt @@ -37,7 +37,7 @@ target_link_libraries(ociodisplay oglapphelpers OpenColorIO ${OPENGL_LIBRARIES} - OpenImageIO + OpenImageIO::OpenImageIO ) install(TARGETS ociodisplay RUNTIME DESTINATION bin diff --git a/src/apps/ociolutimage/CMakeLists.txt b/src/apps/ociolutimage/CMakeLists.txt index b44911ca28..ef24e6bba7 100755 --- a/src/apps/ociolutimage/CMakeLists.txt +++ b/src/apps/ociolutimage/CMakeLists.txt @@ -21,7 +21,7 @@ target_link_libraries(ociolutimage PRIVATE apputils OpenColorIO - OpenImageIO + OpenImageIO::OpenImageIO utils::strings ) diff --git a/src/apps/ocioperf/CMakeLists.txt b/src/apps/ocioperf/CMakeLists.txt index baa0039e84..69e9ba4c59 100644 --- a/src/apps/ocioperf/CMakeLists.txt +++ b/src/apps/ocioperf/CMakeLists.txt @@ -20,10 +20,10 @@ set_target_properties(ocioperf PROPERTIES target_link_libraries(ocioperf PRIVATE apputils - ilmbase::ilmbase + IlmBase::Half oiiohelpers OpenColorIO - OpenImageIO + OpenImageIO::OpenImageIO utils::strings ) diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt index aaa8f0eb09..8f6986b1fa 100644 --- a/src/bindings/python/CMakeLists.txt +++ b/src/bindings/python/CMakeLists.txt @@ -7,11 +7,6 @@ find_package(PythonInterp 2.7 REQUIRED) find_package(PythonLibs 2.7 REQUIRED) -# pybind11 -# https://github.com/pybind/pybind11 -set(pybind11_MIN_VERSION 2.4.3) -find_package(pybind11 ${pybind11_MIN_VERSION} REQUIRED) - ############################################################################### # PyDoc generation # file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include") diff --git a/src/libutils/oiiohelpers/CMakeLists.txt b/src/libutils/oiiohelpers/CMakeLists.txt index 84e16101a5..0fcadf1ccf 100644 --- a/src/libutils/oiiohelpers/CMakeLists.txt +++ b/src/libutils/oiiohelpers/CMakeLists.txt @@ -1,11 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. -find_package(OpenGL REQUIRED) -if(NOT APPLE) - find_package(GLEW REQUIRED) -endif() - set(SOURCES oiiohelpers.cpp ) @@ -31,11 +26,11 @@ target_include_directories(oiiohelpers target_link_libraries(oiiohelpers PUBLIC - OpenImageIO + OpenImageIO::OpenImageIO PRIVATE OpenColorIO - ilmbase::ilmbase + IlmBase::Half utils::strings ) diff --git a/tests/cpu/CMakeLists.txt b/tests/cpu/CMakeLists.txt index 35b02ed0f8..4736879ef2 100755 --- a/tests/cpu/CMakeLists.txt +++ b/tests/cpu/CMakeLists.txt @@ -1,8 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. -include(ExternalProject) - # Define used for tests in tests/cpu/Context_tests.cpp add_definitions("-DOCIO_SOURCE_DIR=${CMAKE_SOURCE_DIR}") @@ -20,12 +18,12 @@ function(add_ocio_test NAME SOURCES PRIVATE_INCLUDES) public_api PRIVATE expat::expat - ilmbase::ilmbase + IlmBase::Half pystring::pystring sampleicc::sampleicc unittest_data utils::strings - yamlcpp::yamlcpp + yaml-cpp testutils ) if(PRIVATE_INCLUDES)