From b09c380b648f3b718b2eaae9ea6feef221602be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Tue, 24 Jan 2023 15:57:54 -0500 Subject: [PATCH 01/18] Implementation of ocio_find_package and ocio_install_package macro. Implemention of minimum, maximum and recommended version. Refactor the FindOpenImageIO to be inline with the rest of the custom find module (OCIO_USE_OIIO_CMAKE_CONFIG is no longer needed). Added a new option called OCIO_VERBOSE. It allow the user to tell OCIO to display more information when searching and building the dependencies. Splitted the find and install part into two files - Find.cmake and Install.cmake. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- CMakeLists.txt | 7 +- share/cmake/macros/ocio_find_package.cmake | 190 +++++++++++ share/cmake/macros/ocio_install_package.cmake | 22 ++ share/cmake/modules/FindExtPackages.cmake | 143 +++++--- share/cmake/modules/FindImath.cmake | 114 +------ share/cmake/modules/FindOpenEXR.cmake | 202 ----------- share/cmake/modules/FindOpenImageIO.cmake | 315 +++++++++--------- .../modules/FindOpenShadingLanguage.cmake | 2 +- share/cmake/modules/Findexpat.cmake | 120 +------ share/cmake/modules/Findlcms2.cmake | 106 +----- share/cmake/modules/Findminizip-ng.cmake | 114 +------ share/cmake/modules/Findopenfx.cmake | 47 +-- share/cmake/modules/Findpybind11.cmake | 85 +---- share/cmake/modules/Findpystring.cmake | 100 +----- share/cmake/modules/Findyaml-cpp.cmake | 121 +------ .../cmake/modules/install/InstallImath.cmake | 140 ++++++++ .../modules/install/InstallOpenEXR.cmake | 239 +++++++++++++ .../modules/{ => install}/InstallZLIB.cmake | 6 +- .../cmake/modules/install/Installexpat.cmake | 149 +++++++++ .../cmake/modules/install/Installlcms2.cmake | 127 +++++++ .../modules/install/Installminizip-ng.cmake | 136 ++++++++ .../cmake/modules/install/Installopenfx.cmake | 72 ++++ .../modules/install/Installpybind11.cmake | 108 ++++++ .../modules/install/Installpystring.cmake | 119 +++++++ .../modules/install/Installyaml-cpp.cmake | 143 ++++++++ share/cmake/utils/CheckSupportGL.cmake | 27 +- share/cmake/utils/Colors.cmake | 16 + share/cmake/utils/CompilerFlags.cmake | 2 + src/cmake/Config.cmake.in | 24 +- 29 files changed, 1793 insertions(+), 1203 deletions(-) create mode 100644 share/cmake/macros/ocio_find_package.cmake create mode 100644 share/cmake/macros/ocio_install_package.cmake create mode 100644 share/cmake/modules/install/InstallImath.cmake create mode 100644 share/cmake/modules/install/InstallOpenEXR.cmake rename share/cmake/modules/{ => install}/InstallZLIB.cmake (97%) create mode 100644 share/cmake/modules/install/Installexpat.cmake create mode 100644 share/cmake/modules/install/Installlcms2.cmake create mode 100644 share/cmake/modules/install/Installminizip-ng.cmake create mode 100644 share/cmake/modules/install/Installopenfx.cmake create mode 100644 share/cmake/modules/install/Installpybind11.cmake create mode 100644 share/cmake/modules/install/Installpystring.cmake create mode 100644 share/cmake/modules/install/Installyaml-cpp.cmake create mode 100644 share/cmake/utils/Colors.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 3911a154ce..a0859c6f5a 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/share/cmake/utils ${CMAKE_SOURCE_DIR}/share/cmake/macros ${CMAKE_SOURCE_DIR}/share/cmake/modules + ${CMAKE_SOURCE_DIR}/share/cmake/modules/install ) set(CMAKE_WARN_DEPRECATED ON) @@ -143,6 +144,9 @@ if (WIN32) option(OCIO_USE_WINDOWS_UNICODE "Compile with Windows Unicode support" ON) endif() +############################################################################### +# Other preferences +option(OCIO_VERBOSE "Display more information when searching or installing dependencies" OFF) ############################################################################### # Optimization / internal linking preferences @@ -154,7 +158,8 @@ option(OCIO_USE_OIIO_FOR_APPS "Request OIIO to build apps (ociolutimage, ociocon ############################################################################### # GPU configuration - +message(STATUS "") +message(STATUS "Checking for GPU configuration...") include(CheckSupportGL) diff --git a/share/cmake/macros/ocio_find_package.cmake b/share/cmake/macros/ocio_find_package.cmake new file mode 100644 index 0000000000..74ccdd9208 --- /dev/null +++ b/share/cmake/macros/ocio_find_package.cmake @@ -0,0 +1,190 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +include(ocio_install_package) + +macro (ocio_print_versions_error dep_name) + if(NOT ocio_dep_MIN_VERSION AND NOT ocio_dep_MAX_VERSION AND NOT ocio_dep_RECOMMENDED_MIN_VERSION) + message(STATUS "${ColorError}Could not find ${dep_name} (no version specified)${ColorReset}") + elseif(NOT ocio_dep_MIN_VERSION AND NOT ocio_dep_RECOMMENDED_MIN_VERSION) + message(STATUS "${ColorError}Could not find ${dep_name} (maximum version: \"${ocio_dep_MAX_VERSION)\"${ColorReset}") + elseif(NOT ocio_dep_MIN_VERSION AND NOT ocio_dep_MAX_VERSION) + message(STATUS "${ColorError}Could not find ${dep_name} (recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\")\"${ColorReset}") + elseif(NOT ocio_dep_RECOMMENDED_MIN_VERSION AND NOT ocio_dep_MAX_VERSION) + message(STATUS "${ColorError}Could not find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION})\"${ColorReset}") + elseif(NOT ocio_dep_MIN_VERSION) + message(STATUS "${ColorError}Could not find ${dep_name} (recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\", maximum version: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") + elseif(NOT ocio_dep_RECOMMENDED_MIN_VERSION) + message(STATUS "${ColorError}Could not find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", maximum version: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") + elseif(NOT ocio_dep_MAX_VERSION) + message(STATUS "${ColorError}Could not find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\")${ColorReset}") + else() + message(STATUS "${ColorError}Could not find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\", max: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") + endif() +endmacro() + +# Using a macro because OCIO wants the scope to be the same as the caller scope. +# Find modules will set variables via the PARENT_SCOPE option and OCIO needs those +# variables in the caller scope. +macro (ocio_find_package dep_name) + cmake_parse_arguments( + # prefix + ocio_dep + # options + "REQUIRED;PREFER_CONFIG;ALLOW_INSTALL;VERBOSE" + # one value keywords + "MIN_VERSION;MAX_VERSION;RECOMMENDED_MIN_VERSION;RECOMMENDED_MIN_VERSION_REASON" + # multi value keywords + "VERSION_VARS;COMPONENTS" + # args + ${ARGN}) + + set(ocio_dep_QUIET_string "") + # Do not set to QUIET when OCIO_VERBOSE is ON. + if(NOT ocio_dep_VERBOSE AND NOT OCIO_VERBOSE) + set(${dep_name}_FIND_QUIETLY true) + set(ocio_dep_QUIET_string "QUIET") + endif() + + set(ocio_dep_CONFIG_string "") + if(ocio_dep_PREFER_CONFIG) + set(ocio_dep_CONFIG_string "CONFIG") + endif() + + set(ocio_dep_COMPONENTS_string "") + if(ocio_dep_COMPONENTS) + set(ocio_dep_COMPONENTS_string "COMPONENTS") + endif() + + if (${dep_name}_FOUND) + # Nothing to do. Already found. + else() + # Try to find the recommended version. + find_package(${dep_name} + ${ocio_dep_RECOMMENDED_MIN_VERSION} + ${ocio_dep_CONFIG_string} + ${ocio_dep_COMPONENTS_string} + ${ocio_dep_COMPONENTS} + ${ocio_dep_QUIET_string} + ${ocio_dep_UNPARSED_ARGUMENTS}) + + if (NOT ${dep_name}_FOUND AND ocio_dep_PREFER_CONFIG) + # Try find_package in module mode instead of config mode. + find_package(${dep_name} + ${ocio_dep_RECOMMENDED_MIN_VERSION} + ${ocio_dep_COMPONENTS_string} + ${ocio_dep_COMPONENTS} + ${ocio_dep_QUIET_string} + ${ocio_dep_UNPARSED_ARGUMENTS}) + endif() + + if(NOT ${dep_name}_FOUND AND ocio_dep_MAX_VERSION + AND NOT ocio_dep_MAX_VERSION VERSION_EQUAL ocio_dep_RECOMMENDED_MIN_VERSION) + # if the recommended version is not found, try to find dependency with the maximum version. + find_package(${dep_name} + ${ocio_dep_MAX_VERSION} EXACT + ${ocio_dep_CONFIG_string} + ${ocio_dep_COMPONENTS_string} + ${ocio_dep_COMPONENTS} + ${ocio_dep_QUIET_string} + ${ocio_dep_UNPARSED_ARGUMENTS}) + + if (NOT ${dep_name}_FOUND AND ocio_dep_PREFER_CONFIG) + # Try find_package in module mode instead of config mode. + find_package(${dep_name} + ${ocio_dep_MAX_VERSION} EXACT + ${ocio_dep_COMPONENTS_string} + ${ocio_dep_COMPONENTS} + ${ocio_dep_QUIET_string} + ${ocio_dep_UNPARSED_ARGUMENTS}) + endif() + endif() + + if(NOT ${dep_name}_FOUND AND ocio_dep_MIN_VERSION + AND NOT ocio_dep_MIN_VERSION VERSION_EQUAL ocio_dep_MAX_VERSION + AND NOT ocio_dep_MIN_VERSION VERSION_EQUAL ocio_dep_RECOMMENDED_MIN_VERSION) + + if (DEFINED ocio_dep_MAX_VERSION + AND ocio_dep_MIN_VERSION VERSION_LESS ocio_dep_MAX_VERSION) + + endif() + + # if the maximum version is not found, try to find dependency with the minimum version. + find_package(${dep_name} + ${ocio_dep_MIN_VERSION} + ${ocio_dep_CONFIG_string} + ${ocio_dep_COMPONENTS_string} + ${ocio_dep_COMPONENTS} + ${ocio_dep_QUIET_string} + ${ocio_dep_UNPARSED_ARGUMENTS}) + if (NOT ${dep_name}_FOUND AND ocio_dep_PREFER_CONFIG) + # Try find_package in module mode instead of config mode. + find_package(${dep_name} + ${ocio_dep_MIN_VERSION} + ${ocio_dep_COMPONENTS_string} + ${ocio_dep_COMPONENTS} + ${ocio_dep_QUIET_string} + ${ocio_dep_UNPARSED_ARGUMENTS}) + endif() + endif() + endif() + + # Check which VERSION_VARS was set by find_package. + set(_VERSION_VAR "${dep_name}_VERSION") + foreach (_vervar ${ocio_dep_VERSION_VARS}) + if(${_vervar}) + set(_VERSION_VAR ${_vervar}) + break() + endif() + endforeach() + + if(_VERSION_VAR) + set(ocio_dep_VERSION ${${_VERSION_VAR}}) + endif() + + # Expecting that the minimum and recommended version are always provided. + # Make sure that the version is within the valid range. + if(${dep_name}_FOUND) + if (ocio_dep_VERSION) + # Make sure that the version found is not greater than the maximum version. + if(DEFINED ocio_dep_MAX_VERSION) + if(ocio_dep_VERSION VERSION_GREATER ocio_dep_MAX_VERSION) + # Display it as an error, but do not abort right now. + message(SEND_ERROR "${ColorError}Found ${dep_name} ${ocio_dep_VERSION}, but is it over the recommended maximum version \"${ocio_dep_MAX_VERSION}\" ${ColorReset}") + set(_${dep_name}_found_displayed true) + endif() + endif() + + if(DEFINED ocio_dep_RECOMMENDED_MIN_VERSION) + if (ocio_dep_VERSION VERSION_LESS ocio_dep_RECOMMENDED_MIN_VERSION) + message(STATUS "${ColorSuccess}Found ${dep_name} (version \"${ocio_dep_VERSION}\") (recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\")${ColorReset}") + set(_${dep_name}_found_displayed true) + endif() + endif() + + if(NOT _${dep_name}_found_displayed) + message(STATUS "${ColorSuccess}Found ${dep_name} (version \"${ocio_dep_VERSION}\")${ColorReset}") + endif() + else() + message(STATUS "${ColorSuccess}Found ${dep_name} (no version information)${ColorReset}") + endif() + else() + ocio_print_versions_error(${dep_name}) + + if(${dep_name}_ROOT) + message(STATUS "${ColorError} ${dep_name}_ROOT was: ${${dep_name}_ROOT} ${ColorReset}") + elseif($ENV{${dep_name}_ROOT}) + message(STATUS "${ColorError} ENV ${dep_name}_ROOT was: ${${dep_name}_ROOT} ${ColorReset}") + endif() + + if(ocio_dep_ALLOW_INSTALL) + ocio_install_package(${dep_name} VERSION ${ocio_dep_RECOMMENDED_MIN_VERSION}) + endif() + + if(ocio_dep_REQUIRED) + if(NOT ${dep_name}_FOUND AND NOT ${ocio_dep_VERSION}) + message(FATAL_ERROR "${ColorError}${dep_name} is required, aborting.${ColorReset}") + endif() + endif() + endif() +endmacro() \ No newline at end of file diff --git a/share/cmake/macros/ocio_install_package.cmake b/share/cmake/macros/ocio_install_package.cmake new file mode 100644 index 0000000000..1bd5892522 --- /dev/null +++ b/share/cmake/macros/ocio_install_package.cmake @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +# Install the specific dependency using OCIO's custom installXYZ module +# where XYZ is the name of the dependency. +macro (ocio_install_package dep_name) + cmake_parse_arguments( + # prefix + ocio_dep + # options + "" + # one value keywords + "VERSION" + # multi value keywords + "" + # args + ${ARGN}) + if(NOT ${dep_name}_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + set(OCIO_${dep_name}_RECOMMENDED_VERSION ${ocio_dep_VERSION}) + include(Install${dep_name}) + endif() +endmacro() \ No newline at end of file diff --git a/share/cmake/modules/FindExtPackages.cmake b/share/cmake/modules/FindExtPackages.cmake index 5455a08ce6..415e553065 100644 --- a/share/cmake/modules/FindExtPackages.cmake +++ b/share/cmake/modules/FindExtPackages.cmake @@ -6,6 +6,9 @@ # by the OCIO_INSTALL_EXT_PACKAGES option. # +include(Colors) +include(ocio_find_package) + ############################################################################### ### Global package options ### @@ -32,25 +35,50 @@ if (APPLE) set(CMAKE_FIND_APPBUNDLE LAST) endif() + +message(STATUS "") +message(STATUS "Missing a dependency? Try the following possibilities:") +message(STATUS "If the package provides a configuration file, use -D_DIR=.") +message(STATUS "If it doesn't provide it, try -D_ROOT=.") +message(STATUS "Alternatively, try -D_LIBRARY= and -D_INCLUDE_DIR=.") +message(STATUS "") +message(STATUS "Please refer to the find module under share/cmake/modules for extra information.") + ############################################################################### -### Packages and versions ### +## +## Required dependencies +## +############################################################################### +message(STATUS "") +message(STATUS "Checking for mandatory dependencies...") # expat # https://github.com/libexpat/libexpat -find_package(expat 2.4.1 REQUIRED) +ocio_find_package( expat REQUIRED ALLOW_INSTALL + MIN_VERSION 2.4.1 + RECOMMENDED_MIN_VERSION 2.5.0 + RECOMMENDED_MIN_VERSION_REASON "CVE fixes and fix issue with symbol leakage when built as a static library") # yaml-cpp # https://github.com/jbeder/yaml-cpp -find_package(yaml-cpp 0.7.0 REQUIRED) +ocio_find_package( yaml-cpp REQUIRED ALLOW_INSTALL + MIN_VERSION 0.6.3 + RECOMMENDED_MIN_VERSION 0.7.0 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") # pystring # https://github.com/imageworks/pystring -find_package(pystring 1.1.3 REQUIRED) +ocio_find_package( pystring REQUIRED ALLOW_INSTALL + MIN_VERSION 1.1.3 + RECOMMENDED_MIN_VERSION 1.1.3 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") # Imath (>=3.1) # https://github.com/AcademySoftwareFoundation/Imath -set(_Imath_ExternalProject_VERSION "3.1.5") -find_package(Imath 3.0 REQUIRED) +ocio_find_package( Imath REQUIRED ALLOW_INSTALL + MIN_VERSION 3.1.1 + RECOMMENDED_MIN_VERSION 3.1.5 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") ############################################################################### ### ZLIB (https://github.com/madler/zlib) @@ -69,8 +97,6 @@ find_package(Imath 3.0 REQUIRED) # ZLIB 1.2.13 is used since it fixes a critical vulnerability. # See https://nvd.nist.gov/vuln/detail/CVE-2022-37434 # See https://github.com/madler/zlib/releases/tag/v1.2.13 -set(_ZLIB_FIND_VERSION "1.2.13") -set(_ZLIB_ExternalProject_VERSION ${_ZLIB_FIND_VERSION}) if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) # ZLIB_USE_STATIC_LIBS is supported only from CMake 3.24+. @@ -80,6 +106,7 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) endif() else() # For CMake < 3.24 since ZLIB_USE_STATIC_LIBS is not available. if(NOT ZLIB_LIBRARY) + set(_cmake_find_library_x_changed true) if(DEFINED CMAKE_FIND_LIBRARY_PREFIXES) set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") else() @@ -115,33 +142,49 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) set(_ZLIB_REQUIRED "") endif() - find_package(ZLIB ${_ZLIB_FIND_VERSION} ${_ZLIB_REQUIRED}) + ocio_find_package( ZLIB REQUIRED ALLOW_INSTALL + MIN_VERSION 1.2.10 + RECOMMENDED_MIN_VERSION 1.2.13 + RECOMMENDED_MIN_VERSION_REASON "CVE fixes" + VERSION_VARS ZLIB_VERSION_STRING ZLIB_VERSION ) # Restore the original find library ordering - if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) - set(CMAKE_FIND_LIBRARY_SUFFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}") - else() - set(CMAKE_FIND_LIBRARY_SUFFIXES) - endif() + if(_cmake_find_library_x_changed) + if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}") + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES) + endif() - if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES) - set(CMAKE_FIND_LIBRARY_PREFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES}") - else() - set(CMAKE_FIND_LIBRARY_PREFIXES) + if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES) + set(CMAKE_FIND_LIBRARY_PREFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES}") + else() + set(CMAKE_FIND_LIBRARY_PREFIXES) + endif() endif() endif() -if(NOT ZLIB_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) - include(InstallZLIB) +if(NOT ZLIB_FOUND) + ocio_install_package(ZLIB VERSION 1.2.13) endif() ############################################################################### # minizip-ng # https://github.com/zlib-ng/minizip-ng -find_package(minizip-ng 3.0.7 REQUIRED) +ocio_find_package( minizip-ng REQUIRED ALLOW_INSTALL + MIN_VERSION 3.0.6 + RECOMMENDED_MIN_VERSION 3.0.7 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") -if(OCIO_BUILD_APPS) +############################################################################### +## +## Optional dependencies +## +############################################################################### +message(STATUS "") +message(STATUS "Checking for optional dependencies...") +if(OCIO_BUILD_APPS) # NOTE: Depending of the compiler version lcms2 2.2 does not compile with # C++17 so, if you change the lcms2 version update the code to compile # lcms2 and dependencies with C++17 or higher i.e. remove the cap of C++ @@ -149,13 +192,19 @@ if(OCIO_BUILD_APPS) # lcms2 # https://github.com/mm2/Little-CMS - find_package(lcms2 2.2 REQUIRED) + ocio_find_package( lcms2 REQUIRED ALLOW_INSTALL + MIN_VERSION 2.2 + RECOMMENDED_MIN_VERSION 2.2 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") endif() if(OCIO_BUILD_OPENFX) # openfx # https://github.com/ofxa/openfx - find_package(openfx 1.4 REQUIRED) + ocio_find_package( openfx REQUIRED ALLOW_INSTALL + MIN_VERSION 1.4.0 + RECOMMENDED_MIN_VERSION 1.4.0 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") endif() if (OCIO_PYTHON_VERSION AND NOT OCIO_BUILD_PYTHON) @@ -177,15 +226,22 @@ if(OCIO_BUILD_PYTHON OR OCIO_BUILD_DOCS) list(APPEND _Python_COMPONENTS Development) endif() + # Python - find_package(Python ${OCIO_PYTHON_VERSION} REQUIRED - COMPONENTS ${_Python_COMPONENTS}) + ocio_find_package( Python REQUIRED + COMPONENTS ${_Python_COMPONENTS} + MIN_VERSION ${OCIO_PYTHON_VERSION} + RECOMMENDED_MIN_VERSION ${OCIO_PYTHON_VERSION} + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") if(OCIO_BUILD_PYTHON) # pybind11 # https://github.com/pybind/pybind11 # pybind11 2.9 fixes issues with MS Visual Studio 2022 (Debug). - find_package(pybind11 2.9.2 REQUIRED) + ocio_find_package( pybind11 REQUIRED ALLOW_INSTALL + MIN_VERSION 2.9.2 + RECOMMENDED_MIN_VERSION 2.9.2 + RECOMMENDED_MIN_VERSION_REASON "Pybind 2.10.0+ does not work with Python 2.7 anymore") endif() endif() @@ -195,14 +251,14 @@ if((OCIO_BUILD_APPS AND OCIO_USE_OIIO_FOR_APPS) OR OCIO_BUILD_TESTS) # OpenImageIO # https://github.com/OpenImageIO/oiio set(OIIO_VERSION "2.2.14") - - if(OCIO_USE_OIIO_CMAKE_CONFIG) - # TODO: Try when OIIO 2.4 is released (https://github.com/OpenImageIO/oiio/pull/3322). - # set(OPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH 1) - find_package(OpenImageIO ${OIIO_VERSION} CONFIG) - else() - find_package(OpenImageIO ${OIIO_VERSION}) - endif() + set(OIIO_RECOMMENDED_VERSION "2.4") + + # TODO: Try when OIIO 2.4 is released (https://github.com/OpenImageIO/oiio/pull/3322). + # Supported from OIIO 2.4+. Setting this for lower versions doesn't affect anything. + set(OPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH 1) + ocio_find_package( OpenImageIO + MIN_VERSION ${OIIO_VERSION} + RECOMMENDED_MIN_VERSION ${OIIO_RECOMMENDED_VERSION}) endif() if(OCIO_BUILD_APPS) @@ -213,8 +269,10 @@ if(OCIO_BUILD_APPS) else() # OpenEXR # https://github.com/AcademySoftwareFoundation/openexr - set(_OpenEXR_ExternalProject_VERSION "3.1.5") - find_package(OpenEXR 3.0) + ocio_find_package( OpenEXR REQUIRED ALLOW_INSTALL + MIN_VERSION 3.0.4 + RECOMMENDED_MIN_VERSION 3.1.5 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") if(OpenEXR_FOUND AND TARGET OpenEXR::OpenEXR) add_library(OpenColorIO::ImageIOBackend ALIAS OpenEXR::OpenEXR) @@ -236,15 +294,18 @@ if(OCIO_BUILD_TESTS) if(TARGET Imath::Imath) # OpenShadingLanguage # https://github.com/AcademySoftwareFoundation/OpenShadingLanguage - find_package(OpenShadingLanguage 1.11) + ocio_find_package( OpenShadingLanguage + MIN_VERSION 1.11 + RECOMMENDED_MIN_VERSION 1.11 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") if(NOT OSL_FOUND) - message(WARNING "Could NOT find OpenShadingLanguage. Skipping build of the OSL unit tests.") + message(WARNING "Skipping build of the OpenShadingLanguage unit tests (OpenShadingLanguage missing)") endif() else() - message(WARNING "Could NOT find Imath. Skipping build of the OSL unit tests.") + message(WARNING "Skipping build of the OpenShadingLanguage unit tests (Imath missing)") endif() else() - message(WARNING "Could NOT find OpenImageIO. Skipping build of the OSL unit tests.") + message(WARNING "Skipping build of the OpenShadingLanguage unit tests (OpenImageIO missing)") endif() endif() diff --git a/share/cmake/modules/FindImath.cmake b/share/cmake/modules/FindImath.cmake index 30f5b4e465..cf99bfe0d9 100644 --- a/share/cmake/modules/FindImath.cmake +++ b/share/cmake/modules/FindImath.cmake @@ -131,122 +131,12 @@ endif() ############################################################################### ### Create target -if (NOT TARGET Imath::Imath) +if (Imath_FOUND AND NOT TARGET Imath::Imath) add_library(Imath::Imath UNKNOWN IMPORTED GLOBAL) add_library(Imath::ImathConfig INTERFACE IMPORTED GLOBAL) set(_Imath_TARGET_CREATE TRUE) endif() -############################################################################### -### Install package from source ### - -if(NOT Imath_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) - include(ExternalProject) - include(GNUInstallDirs) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") - - # Set find_package standard args - set(Imath_FOUND TRUE) - if(_Imath_ExternalProject_VERSION) - set(Imath_VERSION ${_Imath_ExternalProject_VERSION}) - else() - set(Imath_VERSION ${Imath_FIND_VERSION}) - endif() - set(Imath_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") - - # Set the expected library name - if(BUILD_TYPE_DEBUG) - set(_Imath_LIB_SUFFIX "_d") - endif() - - include(VersionUtils) - split_version_string(${Imath_VERSION} _Imath_ExternalProject) - - set(_Imath_LIB_VER "${_Imath_ExternalProject_VERSION_MAJOR}_${_Imath_ExternalProject_VERSION_MINOR}") - - set(Imath_LIBRARY - "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}Imath-${_Imath_LIB_VER}${_Imath_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") - - if(_Imath_TARGET_CREATE) - if(MSVC) - set(Imath_CXX_FLAGS "${Imath_CXX_FLAGS} /EHsc") - endif() - - string(STRIP "${Imath_CXX_FLAGS}" Imath_CXX_FLAGS) - - set(Imath_CMAKE_ARGS - ${Imath_CMAKE_ARGS} - -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} - -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_CXX_FLAGS=${Imath_CXX_FLAGS} - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} - -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} - -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} - -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} - -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} - -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} - -DBUILD_SHARED_LIBS=OFF - -DBUILD_TESTING=OFF - -DPYTHON=OFF - -DDOCS=OFF - -DIMATH_HALF_USE_LOOKUP_TABLE=OFF - ) - - if(CMAKE_TOOLCHAIN_FILE) - set(Imath_CMAKE_ARGS - ${Imath_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) - endif() - - if(APPLE) - string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") - - set(Imath_CMAKE_ARGS - ${Imath_CMAKE_ARGS} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} - -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} - ) - endif() - - if (ANDROID) - set(Imath_CMAKE_ARGS - ${Imath_CMAKE_ARGS} - -DANDROID_PLATFORM=${ANDROID_PLATFORM} - -DANDROID_ABI=${ANDROID_ABI} - -DANDROID_STL=${ANDROID_STL}) - endif() - - # Hack to let imported target be built from ExternalProject_Add - file(MAKE_DIRECTORY ${Imath_INCLUDE_DIR}) - - ExternalProject_Add(imath_install - GIT_REPOSITORY "https://github.com/AcademySoftwareFoundation/Imath.git" - GIT_TAG "v${Imath_VERSION}" - GIT_CONFIG advice.detachedHead=false - GIT_SHALLOW TRUE - PREFIX "${_EXT_BUILD_ROOT}/Imath" - BUILD_BYPRODUCTS ${Imath_LIBRARY} - CMAKE_ARGS ${Imath_CMAKE_ARGS} - EXCLUDE_FROM_ALL TRUE - BUILD_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} --build . - --config ${CMAKE_BUILD_TYPE} - --target install - --parallel - ) - - add_dependencies(Imath::Imath imath_install) - - message(STATUS "Installing Imath: ${Imath_LIBRARY} (version \"${Imath_VERSION}\")") - endif() -endif() - ############################################################################### ### Configure target ### @@ -262,4 +152,4 @@ if(_Imath_TARGET_CREATE) ) mark_as_advanced(Imath_INCLUDE_DIR Imath_LIBRARY Imath_VERSION) -endif() +endif() \ No newline at end of file diff --git a/share/cmake/modules/FindOpenEXR.cmake b/share/cmake/modules/FindOpenEXR.cmake index a8b8448fd6..1aabf0f2b9 100644 --- a/share/cmake/modules/FindOpenEXR.cmake +++ b/share/cmake/modules/FindOpenEXR.cmake @@ -64,205 +64,3 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) OpenEXR_VERSION ) endif() - -############################################################################### -### Create target - -if (NOT TARGET OpenEXR::OpenEXR) - set(_OpenEXR_TARGET_CREATE TRUE) -endif() - -############################################################################### -### Install package from source ### - -macro(set_target_location target_name) - if(NOT DEFINED "${target_name}_LIBRARY") - set("${target_name}_LIBRARY" "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${target_name}-${_OpenEXR_LIB_VER}${_OpenEXR_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") - endif() -endmacro() - -if(NOT OpenEXR_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) - include(ExternalProject) - include(GNUInstallDirs) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") - - # Required dependency - if(NOT ZLIB_FOUND) - find_package(ZLIB) - if(NOT ZLIB_FOUND) - message(STATUS "ZLib is required to build OpenEXR.") - return() - endif() - endif() - - find_package(Threads) - if(NOT Threads_FOUND) - message(STATUS "Threads is required to build OpenEXR.") - return() - endif() - - # Set find_package standard args - set(OpenEXR_FOUND TRUE) - if(_OpenEXR_ExternalProject_VERSION) - set(OpenEXR_VERSION ${_OpenEXR_ExternalProject_VERSION}) - else() - set(OpenEXR_VERSION ${OpenEXR_FIND_VERSION}) - endif() - set(OpenEXR_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") - - # Set the expected library name - if(BUILD_TYPE_DEBUG) - set(_OpenEXR_LIB_SUFFIX "_d") - endif() - - include(VersionUtils) - split_version_string(${OpenEXR_VERSION} _OpenEXR_ExternalProject) - - set(_OpenEXR_LIB_VER "${_OpenEXR_ExternalProject_VERSION_MAJOR}_${_OpenEXR_ExternalProject_VERSION_MINOR}") - - set_target_location(Iex) - set_target_location(IlmThread) - set_target_location(OpenEXR) - set_target_location(OpenEXRCore) - set_target_location(OpenEXRUtil) - - if(_OpenEXR_TARGET_CREATE) - if(MSVC) - set(OpenEXR_CXX_FLAGS "${OpenEXR_CXX_FLAGS} /EHsc") - endif() - - string(STRIP "${OpenEXR_CXX_FLAGS}" OpenEXR_CXX_FLAGS) - - set(OpenEXR_CMAKE_ARGS - ${OpenEXR_CMAKE_ARGS} - -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} - -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_CXX_FLAGS=${OpenEXR_CXX_FLAGS} - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} - -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} - -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} - -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} - -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} - -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} - -DBUILD_SHARED_LIBS=OFF - -DBUILD_TESTING=OFF - -DOPENEXR_INSTALL_EXAMPLES=OFF - -DOPENEXR_INSTALL_TOOLS=OFF - # Try to use in-source built Imath first, if available. - -DCMAKE_PREFIX_PATH=${_EXT_DIST_ROOT} - ) - - if(CMAKE_TOOLCHAIN_FILE) - set(OpenEXR_CMAKE_ARGS - ${OpenEXR_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) - endif() - - if(APPLE) - string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") - - set(OpenEXR_CMAKE_ARGS - ${OpenEXR_CMAKE_ARGS} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} - -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} - ) - endif() - - if (ANDROID) - set(OpenEXR_CMAKE_ARGS - ${OpenEXR_CMAKE_ARGS} - -DANDROID_PLATFORM=${ANDROID_PLATFORM} - -DANDROID_ABI=${ANDROID_ABI} - -DANDROID_STL=${ANDROID_STL}) - endif() - - # Hack to let imported target be built from ExternalProject_Add - file(MAKE_DIRECTORY ${OpenEXR_INCLUDE_DIR}) - - ExternalProject_Add(openexr_install - GIT_REPOSITORY "https://github.com/AcademySoftwareFoundation/openexr.git" - GIT_TAG "v${OpenEXR_VERSION}" - GIT_CONFIG advice.detachedHead=false - GIT_SHALLOW TRUE - PREFIX "${_EXT_BUILD_ROOT}/openexr" - BUILD_BYPRODUCTS - ${Iex_LIBRARY} - ${IlmThread_LIBRARY} - ${OpenEXR_LIBRARY} - ${OpenEXRCore_LIBRARY} - ${OpenEXRUtil_LIBRARY} - CMAKE_ARGS ${OpenEXR_CMAKE_ARGS} - EXCLUDE_FROM_ALL TRUE - BUILD_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} --build . - --config ${CMAKE_BUILD_TYPE} - --target install - --parallel - ) - - # Additional targets. ALIAS to UNKNOWN imported target is only possible - # from CMake 3.15, so we explicitly define targets as STATIC here. - add_library(OpenEXR::Iex STATIC IMPORTED GLOBAL) - add_library(OpenEXR::IexConfig INTERFACE IMPORTED GLOBAL) - add_library(OpenEXR::IlmThread STATIC IMPORTED GLOBAL) - add_library(OpenEXR::IlmThreadConfig INTERFACE IMPORTED GLOBAL) - add_library(OpenEXR::OpenEXR STATIC IMPORTED GLOBAL) - add_library(OpenEXR::OpenEXRConfig INTERFACE IMPORTED GLOBAL) - add_library(OpenEXR::OpenEXRCore STATIC IMPORTED GLOBAL) - add_library(OpenEXR::OpenEXRUtil STATIC IMPORTED GLOBAL) - - add_dependencies(OpenEXR::OpenEXR openexr_install) - - message(STATUS "Installing OpenEXR: ${OpenEXR_LIBRARY} (version \"${OpenEXR_VERSION}\")") - endif() -endif() - -############################################################################### -### Configure target ### - -if(_OpenEXR_TARGET_CREATE) - file(MAKE_DIRECTORY ${OpenEXR_INCLUDE_DIR}/OpenEXR) - - set_target_properties(OpenEXR::Iex PROPERTIES - IMPORTED_LOCATION ${Iex_LIBRARY} - INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "OpenEXR::IlmThreadConfig;OpenEXR::IlmThreadConfig" - ) - set_target_properties(OpenEXR::IexConfig PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR};${OpenEXR_INCLUDE_DIR}/OpenEXR" - ) - set_target_properties(OpenEXR::IlmThread PROPERTIES - IMPORTED_LOCATION ${IlmThread_LIBRARY} - INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "OpenEXR::IlmThreadConfig;OpenEXR::IlmThreadConfig;OpenEXR::Iex;Threads::Threads" - ) - set_target_properties(OpenEXR::IlmThreadConfig PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR};${OpenEXR_INCLUDE_DIR}/OpenEXR" - ) - set_target_properties(OpenEXR::OpenEXR PROPERTIES - IMPORTED_LOCATION ${OpenEXR_LIBRARY} - INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "OpenEXR::IlmThreadConfig;Imath::Imath;OpenEXR::IlmThreadConfig;OpenEXR::Iex;OpenEXR::IlmThread;ZLIB::ZLIB" - ) - set_target_properties(OpenEXR::OpenEXRConfig PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR};${OpenEXR_INCLUDE_DIR}/OpenEXR" - ) - set_target_properties(OpenEXR::OpenEXRCore PROPERTIES - IMPORTED_LOCATION ${OpenEXRCore_LIBRARY} - INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "OpenEXR::IlmThreadConfig;ZLIB::ZLIB;\$" - ) - set_target_properties(OpenEXR::OpenEXRUtil PROPERTIES - IMPORTED_LOCATION ${OpenEXRUtil_LIBRARY} - INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "OpenEXR::IlmThreadConfig;OpenEXR::OpenEXR" - ) - - mark_as_advanced(OpenEXR_INCLUDE_DIR OpenEXR_LIBRARY OpenEXR_VERSION) -endif() diff --git a/share/cmake/modules/FindOpenImageIO.cmake b/share/cmake/modules/FindOpenImageIO.cmake index c8f68abd63..828da451fa 100644 --- a/share/cmake/modules/FindOpenImageIO.cmake +++ b/share/cmake/modules/FindOpenImageIO.cmake @@ -1,174 +1,187 @@ -########################################################################### -# OpenImageIO https://www.openimageio.org -# Copyright 2008-present Contributors to the OpenImageIO project. # SPDX-License-Identifier: BSD-3-Clause -# https://github.com/OpenImageIO/oiio/blob/master/LICENSE.md +# Copyright Contributors to the OpenColorIO Project. # -# For an up-to-date version of this file, see: -# https://github.com/OpenImageIO/oiio/blob/master/src/cmake/Modules/FindOpenImageIO.cmake +# Locate OpenImageIO # -########################################################################### +# Variables defined by this module: +# OpenImageIO_FOUND - If FALSE, do not try to link to OpenImageIO +# OpenImageIO_LIBRARY - OpenImageIO library to link to +# OpenImageIO_LIB_DIR - Libray directory +# OpenImageIO_INCLUDE_DIR - Where to find OpenImageIO.h +# OpenImageIO_VERSION - The version of the library # -# CMake module to find OpenImageIO +# Targets defined by this module: +# OpenImageIO::OpenImageIO - The libOpenImageIO library +# OpenImageIO::OpenImageIO_Util - Utility classes (v2.3+) # -# This module will set -# OpenImageIO_FOUND True, if found -# OPENIMAGEIO_INCLUDES directory where headers are found -# OPENIMAGEIO_LIBRARIES libraries for OIIO -# OPENIMAGEIO_LIBRARY_DIRS library dirs for OIIO -# OPENIMAGEIO_VERSION Version ("major.minor.patch.tweak") -# OPENIMAGEIO_VERSION_MAJOR Version major number -# OPENIMAGEIO_VERSION_MINOR Version minor number -# OPENIMAGEIO_VERSION_PATCH Version minor patch -# OPENIMAGEIO_VERSION_TWEAK Version minor tweak -# -# Imported targets: -# OpenImageIO::OpenImageIO The libOpenImageIO library. -# OpenImageIO::oiiotool The oiiotool executable. -# -# Special inputs: -# OpenImageIO_ROOT - if using CMake >= 3.12, will automatically search -# this area for OIIO components. -# OPENIMAGEIO_ROOT_DIR - custom "prefix" location of OIIO installation -# (expecting bin, lib, include subdirectories) -# This is deprecated, but will work for a while. -# OpenImageIO_FIND_QUIETLY - if set, print minimal console output -# OIIO_LIBNAME_SUFFIX - if set, optional nonstandard library suffix -# -########################################################################### -# -# NOTE: This file is deprecated. -# -# In OIIO 2.1+, we generate OpenImageIOConfig.cmake files that are now the -# preferred way for downstream projecs to find an installed OIIO. There -# should be no need to copy this FindOpenImageIO.cmake file into downstream -# projects, *unless* they need to work with a range of OIIO vesions that -# may include <2.1, which would lack the generated config files. -# -########################################################################### - - -# If 'OPENIMAGE_HOME' not set, use the env variable of that name if available -if (NOT OPENIMAGEIO_ROOT_DIR AND NOT $ENV{OPENIMAGEIO_ROOT_DIR} STREQUAL "") - set (OPENIMAGEIO_ROOT_DIR $ENV{OPENIMAGEIO_ROOT_DIR}) -endif () - -find_library (OPENIMAGEIO_LIBRARY - NAMES - OpenImageIO${OIIO_LIBNAME_SUFFIX} - HINTS - ${OPENIMAGEIO_ROOT_DIR} - PATH_SUFFIXES - lib64 - lib - OpenImageIO/lib -) -find_library (OPENIMAGEIO_UTIL_LIBRARY - NAMES - OpenImageIO_Util${OIIO_LIBNAME_SUFFIX} - HINTS - ${OPENIMAGEIO_ROOT_DIR} - PATH_SUFFIXES - lib64 - lib - OpenImageIO/lib -) -find_path (OPENIMAGEIO_INCLUDE_DIR - NAMES - OpenImageIO/imageio.h - HINTS - ${OPENIMAGEIO_ROOT_DIR} - PATH_SUFFIXES - OpenImageIO/include -) -find_program (OIIOTOOL_BIN - NAMES - oiiotool - HINTS - ${OPENIMAGEIO_ROOT_DIR} - PATH_SUFFIXES - OpenImageIO/bin -) -# Try to figure out version number -set (OIIO_VERSION_HEADER "${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO/oiioversion.h") -if (EXISTS "${OIIO_VERSION_HEADER}") - file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_MAJOR .*$") - string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_MAJOR ${TMP}) - file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_MINOR .*$") - string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_MINOR ${TMP}) - file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_PATCH .*$") - string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_PATCH ${TMP}) - file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_TWEAK .*$") - if (TMP) - string (REGEX MATCHALL "[0-9]+" OPENIMAGEIO_VERSION_TWEAK ${TMP}) - else () - set (OPENIMAGEIO_VERSION_TWEAK 0) - endif () - set (OPENIMAGEIO_VERSION "${OPENIMAGEIO_VERSION_MAJOR}.${OPENIMAGEIO_VERSION_MINOR}.${OPENIMAGEIO_VERSION_PATCH}.${OPENIMAGEIO_VERSION_TWEAK}") -endif () - -set (OIIO_IMATH_HEADER "${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO/Imath.h") -if (EXISTS "${OIIO_IMATH_HEADER}") - file (STRINGS "${OIIO_IMATH_HEADER}" TMP REGEX "^#define OIIO_USING_IMATH .*$") - string (REGEX MATCHALL "[0-9]" OIIO_IMATH_VERSION ${TMP}) - if (OIIO_IMATH_VERSION LESS 3) - message(STATUS "Skipping OpenImageIO built against OpenEXR 2, please use version 3 or greater.") - return () - endif () -endif () - -include (FindPackageHandleStandardArgs) -find_package_handle_standard_args ( - OpenImageIO - FOUND_VAR - OpenImageIO_FOUND - REQUIRED_VARS - OPENIMAGEIO_INCLUDE_DIR - OPENIMAGEIO_LIBRARY - OPENIMAGEIO_VERSION +if(NOT DEFINED OpenImageIO_ROOT) + # Search for OpenImageIOConfig.cmake + find_package(OpenImageIO ${OpenImageIO_FIND_VERSION} CONFIG QUIET) +endif() + +if (OpenImageIO_FOUND) + # IMPORTED_GLOBAL property must be set to TRUE since alisasing a non-global imported target + # is not possible until CMake 3.18+. + set_target_properties(OpenImageIO::OpenImageIO PROPERTIES IMPORTED_GLOBAL TRUE) + + # Set the ROOT directory by going up a directory from OpenImageIO_LIB_DIR. + get_filename_component(_PARENT_DIR ${OpenImageIO_LIB_DIR} DIRECTORY) + # find_library will prioritize OpenImageIO_ROOT before any other path. + set(OpenImageIO_ROOT ${_PARENT_DIR}) + + # Set OpenImageIO_LIBRARY since OpenImageIOConfig does not do it. + find_library (OpenImageIO_LIBRARY + NAMES + OpenImageIO + HINTS + ${OpenImageIO_LIB_DIR} + PATH_SUFFIXES + lib64 + lib + OpenImageIO/lib + ) + + # Find util library + find_library (OpenImageIO_UTIL_LIBRARY + NAMES + OpenImageIO_Util + HINTS + ${OpenImageIO_LIB_DIR} + PATH_SUFFIXES + lib64 + lib + OpenImageIO/lib + ) + +else() + # Search for pkg config file. + find_package(PkgConfig QUIET) + pkg_check_modules(PC_OpenImageIO QUIET "OpenImageIO>=${OpenImageIO_FIND_VERSION}") + + # Find include directory + # Since CMake 3.12, find_path search through _ROOT before everything else. + find_path(OpenImageIO_INCLUDE_DIR + NAMES + oiioversion.h + HINTS + ${PC_OpenImageIO_INCLUDE_DIRS} + PATH_SUFFIXES + include/OpenImageIO + OpenImageIO + include + OpenImageIO/include + ) + + # Set OpenImageIO_INCLUDES since OpenImageIOConfig does it. + set(OpenImageIO_INCLUDES ${OpenImageIO_INCLUDE_DIR}) + + # Find library + # Since CMake 3.12, find_library search through _ROOT before everything else. + find_library (OpenImageIO_LIBRARY + NAMES + OpenImageIO + HINTS + ${PC_OpenImageIO_LIBRARY_DIRS} + PATH_SUFFIXES + lib64 + lib + OpenImageIO/lib + ) + + # Find util library + find_library (OpenImageIO_UTIL_LIBRARY + NAMES + OpenImageIO_Util + HINTS + ${PC_OpenImageIO_LIBRARY_DIRS} + PATH_SUFFIXES + lib64 + lib + OpenImageIO/lib + ) + + # Set OpenImageIO_LIB_DIR since OpenImageIOConfig does it. + get_filename_component(OpenImageIO_LIB_DIR ${OpenImageIO_LIBRARY} DIRECTORY) + + if (OpenImageIO_INCLUDE_DIR) + # Try to figure out version number + list(GET OpenImageIO_INCLUDE_DIR 0 _OpenImageIO_INCLUDE_DIR) + if(EXISTS "${_OpenImageIO_INCLUDE_DIR}/oiioversion.h") + set(OIIO_VERSION_HEADER "${_OpenImageIO_INCLUDE_DIR}/oiioversion.h") + elseif(EXISTS "${_OpenImageIO_INCLUDE_DIR}/OpenImageIO/oiioversion.h") + set(OIIO_VERSION_HEADER "${_OpenImageIO_INCLUDE_DIR}/OpenImageIO/oiioversion.h") + endif() + + if (EXISTS "${OIIO_VERSION_HEADER}") + file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_MAJOR .*$") + string (REGEX MATCHALL "[0-9]+" OpenImageIO_VERSION_MAJOR ${TMP}) + file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_MINOR .*$") + string (REGEX MATCHALL "[0-9]+" OpenImageIO_VERSION_MINOR ${TMP}) + file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_PATCH .*$") + string (REGEX MATCHALL "[0-9]+" OpenImageIO_VERSION_PATCH ${TMP}) + file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_TWEAK .*$") + if (TMP) + string (REGEX MATCHALL "[0-9]+" OpenImageIO_VERSION_TWEAK ${TMP}) + else () + set (OpenImageIO_VERSION_TWEAK 0) + endif () + set (OpenImageIO_VERSION "${OpenImageIO_VERSION_MAJOR}.${OpenImageIO_VERSION_MINOR}.${OpenImageIO_VERSION_PATCH}.${OpenImageIO_VERSION_TWEAK}") + endif () + + set (OIIO_IMATH_HEADER "${OpenImageIO_INCLUDE_DIR}/OpenImageIO/Imath.h") + if (EXISTS "${OIIO_IMATH_HEADER}") + file (STRINGS "${OIIO_IMATH_HEADER}" TMP REGEX "^#define OIIO_USING_IMATH .*$") + string (REGEX MATCHALL "[0-9]" OIIO_IMATH_VERSION ${TMP}) + if (OIIO_IMATH_VERSION LESS 3) + message(STATUS "Skipping OpenImageIO built against OpenEXR 2, please use version 3 or greater.") + return () + endif () + endif () + elseif(PC_OpenImageIO_FOUND) + set(OpenImageIO_VERSION "${PC_OpenImageIO_VERSION}") + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OpenImageIO + REQUIRED_VARS + OpenImageIO_LIB_DIR + OpenImageIO_INCLUDE_DIR + OpenImageIO_LIBRARY VERSION_VAR - OPENIMAGEIO_VERSION + OpenImageIO_VERSION ) -set (OPENIMAGEIO_FOUND ${OpenImageIO_FOUND}) # Old name +############################################################################### +### Create target -if (OpenImageIO_FOUND) - set (OPENIMAGEIO_INCLUDES ${OPENIMAGEIO_INCLUDE_DIR}) - set (OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARY}) - get_filename_component (OPENIMAGEIO_LIBRARY_DIRS "${OPENIMAGEIO_LIBRARY}" DIRECTORY) - if (NOT OpenImageIO_FIND_QUIETLY) - message ( STATUS "OpenImageIO includes = ${OPENIMAGEIO_INCLUDE_DIR}" ) - message ( STATUS "OpenImageIO libraries = ${OPENIMAGEIO_LIBRARIES}" ) - message ( STATUS "OpenImageIO library_dirs = ${OPENIMAGEIO_LIBRARY_DIRS}" ) - endif () +if (OpenImageIO_FOUND AND NOT TARGET OpenImageIO::OpenImageIO) + add_library(OpenImageIO::OpenImageIO UNKNOWN IMPORTED GLOBAL) + + # Configure target - if (NOT TARGET OpenImageIO::OpenImageIO) - add_library(OpenImageIO::OpenImageIO UNKNOWN IMPORTED) - set_target_properties(OpenImageIO::OpenImageIO PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${OPENIMAGEIO_INCLUDES}") + set_target_properties(OpenImageIO::OpenImageIO PROPERTIES + IMPORTED_LOCATION "${OpenImageIO_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${OpenImageIO_INCLUDE_DIR}") - set_property(TARGET OpenImageIO::OpenImageIO APPEND PROPERTY - IMPORTED_LOCATION "${OPENIMAGEIO_LIBRARIES}") - endif () + set_property(TARGET OpenImageIO::OpenImageIO APPEND PROPERTY + IMPORTED_LOCATION "${OpenImageIO_LIBRARY}") # Starting with OIIO v2.3, some utility classes are now only declared in OpenImageIO_Util # (and not in both libraries like in older versions). - if (${OPENIMAGEIO_VERSION} VERSION_GREATER_EQUAL "2.3" AND NOT TARGET OpenImageIO::OpenImageIO_Util) + if (${OpenImageIO_VERSION} VERSION_GREATER_EQUAL "2.3" AND NOT TARGET OpenImageIO::OpenImageIO_Util) add_library(OpenImageIO::OpenImageIO_Util UNKNOWN IMPORTED) set_target_properties(OpenImageIO::OpenImageIO_Util PROPERTIES - IMPORTED_LOCATION "${OPENIMAGEIO_UTIL_LIBRARY}") + IMPORTED_LOCATION "${OpenImageIO_UTIL_LIBRARY}") target_link_libraries(OpenImageIO::OpenImageIO INTERFACE OpenImageIO::OpenImageIO_Util) endif () # Starting with OIIO v2.3, OIIO needs to compile at least in C++14. - if (${OPENIMAGEIO_VERSION} VERSION_GREATER_EQUAL "2.3" AND ${CMAKE_CXX_STANDARD} LESS_EQUAL 11) + if (${OpenImageIO_VERSION} VERSION_GREATER_EQUAL "2.3" AND ${CMAKE_CXX_STANDARD} LESS_EQUAL 11) set(OpenImageIO_FOUND OFF) - message(WARNING "Need C++14 or higher to compile with OpenImageIO ${OPENIMAGEIO_VERSION}.") + message(WARNING "Need C++14 or higher to compile with OpenImageIO ${OpenImageIO_VERSION}.") endif () -endif () - -mark_as_advanced ( - OPENIMAGEIO_INCLUDE_DIR - OPENIMAGEIO_LIBRARY -) + + mark_as_advanced(OpenImageIO_INCLUDE_DIR OpenImageIO_LIBRARY OpenImageIO_VERSION) +endif() \ No newline at end of file diff --git a/share/cmake/modules/FindOpenShadingLanguage.cmake b/share/cmake/modules/FindOpenShadingLanguage.cmake index f73ffdf9b9..5a07572f4a 100644 --- a/share/cmake/modules/FindOpenShadingLanguage.cmake +++ b/share/cmake/modules/FindOpenShadingLanguage.cmake @@ -18,7 +18,7 @@ endif() if(NOT DEFINED OSL_ROOT) - find_package(OSL ${OpenShadingLanguage_FIND_VERSION} CONFIG) + find_package(OSL ${OpenShadingLanguage_FIND_VERSION} CONFIG QUIET) set(OpenShadingLanguage_VERSION ${OSL_VERSION}) diff --git a/share/cmake/modules/Findexpat.cmake b/share/cmake/modules/Findexpat.cmake index 8e23cbba0b..ff26a3d071 100644 --- a/share/cmake/modules/Findexpat.cmake +++ b/share/cmake/modules/Findexpat.cmake @@ -96,7 +96,6 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) expat/include ) - # Expat uses prefix "lib" on all platform by default. # Library name doesn't change in debug. @@ -200,126 +199,11 @@ endif() ############################################################################### ### Create target -if(NOT TARGET expat::expat) +if(expat_FOUND AND 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 AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) - include(ExternalProject) - include(GNUInstallDirs) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") - - # Set find_package standard args - set(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() - - # Expat use a hardcoded lib prefix instead of CMAKE_STATIC_LIBRARY_PREFIX - # https://github.com/libexpat/libexpat/blob/R_2_4_1/expat/CMakeLists.txt#L374 - set(_expat_LIB_PREFIX "lib") - - set(expat_LIBRARY - "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${_expat_LIB_PREFIX}expat${_expat_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") - - if(_expat_TARGET_CREATE) - 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_POLICY_DEFAULT_CMP0063=NEW - -DCMAKE_C_VISIBILITY_PRESET=${CMAKE_C_VISIBILITY_PRESET} - -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} - -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_C_FLAGS=${EXPAT_C_FLAGS} - -DCMAKE_CXX_FLAGS=${EXPAT_CXX_FLAGS} - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} - -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} - -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} - -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} - -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} - -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} - -DEXPAT_BUILD_DOCS=OFF - -DEXPAT_BUILD_EXAMPLES=OFF - -DEXPAT_BUILD_TESTS=OFF - -DEXPAT_BUILD_TOOLS=OFF - -DEXPAT_SHARED_LIBS=OFF - ) - - if(CMAKE_TOOLCHAIN_FILE) - set(EXPAT_CMAKE_ARGS - ${EXPAT_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) - endif() - - if(APPLE) - string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") - - set(EXPAT_CMAKE_ARGS - ${EXPAT_CMAKE_ARGS} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} - -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} - ) - endif() - - if (ANDROID) - set(EXPAT_CMAKE_ARGS - ${EXPAT_CMAKE_ARGS} - -DANDROID_PLATFORM=${ANDROID_PLATFORM} - -DANDROID_ABI=${ANDROID_ABI} - -DANDROID_STL=${ANDROID_STL}) - 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 - BUILD_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} --build . - --config ${CMAKE_BUILD_TYPE} - --target install - --parallel - ) - - add_dependencies(expat::expat expat_install) - message(STATUS "Installing expat: ${expat_LIBRARY} (version \"${expat_VERSION}\")") - endif() -endif() - ############################################################################### ### Configure target ### @@ -330,4 +214,4 @@ if(_expat_TARGET_CREATE) ) mark_as_advanced(expat_INCLUDE_DIR expat_LIBRARY expat_VERSION) -endif() +endif() \ No newline at end of file diff --git a/share/cmake/modules/Findlcms2.cmake b/share/cmake/modules/Findlcms2.cmake index f35fcf14f4..e2387c468a 100644 --- a/share/cmake/modules/Findlcms2.cmake +++ b/share/cmake/modules/Findlcms2.cmake @@ -22,11 +22,6 @@ # 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) -endif() - ############################################################################### ### Try to find package ### @@ -95,104 +90,11 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) endif() ############################################################################### -### Install package from source ### - -if(NOT lcms2_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) - include(ExternalProject) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - 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}/${CMAKE_INSTALL_INCLUDEDIR}/lcms2") - set(lcms2_LIBRARY - "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}lcms2${CMAKE_STATIC_LIBRARY_SUFFIX}") - - if(_lcms2_TARGET_CREATE) - if(UNIX) - set(lcms2_C_FLAGS "${lcms2_C_FLAGS} -fvisibility=hidden -fPIC") - endif() - - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") - set(lcms2_C_FLAGS "${lcms2_C_FLAGS} -Wno-aggressive-loop-optimizations") - endif() - - string(STRIP "${lcms2_C_FLAGS}" lcms2_C_FLAGS) - - # NOTE: Depending of the compiler version lcm2 2.2 does not compile with C++17 so revert - # to C++11 because the library is only used by a cmd line tool. - - set(lcms2_CXX_STANDARD ${CMAKE_CXX_STANDARD}) - if(${CMAKE_CXX_STANDARD} GREATER_EQUAL 17) - set(lcms2_CXX_STANDARD 11) - endif() - - set(lcms2_CMAKE_ARGS - ${lcms2_CMAKE_ARGS} - -DCMAKE_C_FLAGS=${lcms2_C_FLAGS} - -DCMAKE_CXX_STANDARD=${lcms2_CXX_STANDARD} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} - -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} - -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} - -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} - -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} - -DBUILD_SHARED_LIBS=OFF - ) - - if(CMAKE_TOOLCHAIN_FILE) - set(lcms2_CMAKE_ARGS - ${lcms2_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) - endif() - - if(APPLE) - string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") - - set(lcms2_CMAKE_ARGS - ${lcms2_CMAKE_ARGS} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} - -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} - ) - endif() - - if (ANDROID) - set(lcms2_CMAKE_ARGS - ${lcms2_CMAKE_ARGS} - -DANDROID_PLATFORM=${ANDROID_PLATFORM} - -DANDROID_ABI=${ANDROID_ABI} - -DANDROID_STL=${ANDROID_STL}) - endif() - - # Hack to let imported target be built from ExternalProject_Add - 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_CONFIG advice.detachedHead=false - GIT_SHALLOW TRUE - PREFIX "${_EXT_BUILD_ROOT}/Little-CMS" - BUILD_BYPRODUCTS ${lcms2_LIBRARY} - CMAKE_ARGS ${lcms2_CMAKE_ARGS} - EXCLUDE_FROM_ALL TRUE - PATCH_COMMAND - ${CMAKE_COMMAND} -E copy - "${CMAKE_SOURCE_DIR}/share/cmake/projects/Buildlcms2.cmake" - "CMakeLists.txt" - BUILD_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} --build . - --config ${CMAKE_BUILD_TYPE} - --target install - --parallel - ) +### Configure target ### - add_dependencies(lcms2::lcms2 lcms2_install) - message(STATUS "Installing lcms2: ${lcms2_LIBRARY} (version \"${lcms2_VERSION}\")") - endif() +if(lcms2_FOUND AND NOT TARGET lcms2::lcms2) + add_library(lcms2::lcms2 UNKNOWN IMPORTED GLOBAL) + set(_lcms2_TARGET_CREATE TRUE) endif() ############################################################################### diff --git a/share/cmake/modules/Findminizip-ng.cmake b/share/cmake/modules/Findminizip-ng.cmake index b961d1c9ac..12a14ce9c4 100644 --- a/share/cmake/modules/Findminizip-ng.cmake +++ b/share/cmake/modules/Findminizip-ng.cmake @@ -40,7 +40,7 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) # Search for minizip-ng-config.cmake find_package(minizip-ng ${minizip-ng_FIND_VERSION} CONFIG QUIET) endif() - + if (minizip-ng_FOUND) get_target_property(minizip-ng_INCLUDE_DIR MINIZIP::minizip-ng INTERFACE_INCLUDE_DIRECTORIES) get_target_property(minizip-ng_LIBRARY MINIZIP::minizip-ng LOCATION) @@ -176,120 +176,12 @@ endif() ############################################################################### ### Create target -if(NOT TARGET MINIZIP::minizip-ng) + +if(minizip-ng_FOUND AND NOT TARGET MINIZIP::minizip-ng) add_library(MINIZIP::minizip-ng UNKNOWN IMPORTED GLOBAL) set(_minizip-ng_TARGET_CREATE TRUE) endif() -############################################################################### -### Install package from source ### - -if(NOT minizip-ng_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) - include(ExternalProject) - include(GNUInstallDirs) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") - - # Set find_package standard args - set(minizip-ng_FOUND TRUE) - set(minizip-ng_VERSION ${minizip-ng_FIND_VERSION}) - - set(minizip-ng_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}/minizip-ng") - - # Minizip-ng use a hardcoded lib prefix instead of CMAKE_STATIC_LIBRARY_PREFIX - set(_minizip-ng_LIB_PREFIX "lib") - - set(minizip-ng_LIBRARY - "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${_minizip-ng_LIB_PREFIX}minizip-ng${_minizip-ng_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") - - if(_minizip-ng_TARGET_CREATE) - set(minizip-ng_CMAKE_ARGS - ${minizip-ng_CMAKE_ARGS} - -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} - -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} - -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} - -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} - -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} - # Since the other modules create a subfolder for the includes by default and since - # minizip-ng does not, a suffix is added to CMAKE_INSTALL_INCLUDEDIR in order to - # install the headers under a subdirectory named "minizip-ng". - # Note that this does not affect external builds for minizip-ng. - -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}/minizip-ng - -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} - -DBUILD_SHARED_LIBS=OFF - -DMZ_OPENSSL=OFF - -DMZ_LIBBSD=OFF - -DMZ_BUILD_TESTS=OFF - -DMZ_COMPAT=OFF - -DMZ_BZIP2=OFF - -DMZ_LZMA=OFF - -DMZ_LIBCOMP=OFF - -DMZ_ZSTD=OFF - -DMZ_PKCRYPT=OFF - -DMZ_WZAES=OFF - -DMZ_SIGNING=OFF - -DMZ_ZLIB=ON - -DMZ_ICONV=OFF - -DMZ_FETCH_LIBS=OFF - -DMZ_FORCE_FETCH_LIBS=OFF - -DZLIB_LIBRARY=${ZLIB_LIBRARIES} - -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS} - ) - - if(CMAKE_TOOLCHAIN_FILE) - set(minizip-ng_CMAKE_ARGS - ${minizip-ng_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) - endif() - - if(APPLE) - string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") - - set(minizip-ng_CMAKE_ARGS - ${minizip-ng_CMAKE_ARGS} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} - -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} - ) - endif() - - if (ANDROID) - set(minizip-ng_CMAKE_ARGS - ${minizip-ng_CMAKE_ARGS} - -DANDROID_PLATFORM=${ANDROID_PLATFORM} - -DANDROID_ABI=${ANDROID_ABI} - -DANDROID_STL=${ANDROID_STL}) - endif() - endif() - - # Hack to let imported target be built from ExternalProject_Add - file(MAKE_DIRECTORY ${minizip-ng_INCLUDE_DIR}) - - ExternalProject_Add(minizip-ng_install - GIT_REPOSITORY "https://github.com/zlib-ng/minizip-ng.git" - GIT_TAG "${minizip-ng_VERSION}" - GIT_CONFIG advice.detachedHead=false - GIT_SHALLOW TRUE - PREFIX "${_EXT_BUILD_ROOT}/libminizip-ng" - BUILD_BYPRODUCTS ${minizip-ng_LIBRARY} - CMAKE_ARGS ${minizip-ng_CMAKE_ARGS} - EXCLUDE_FROM_ALL TRUE - BUILD_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} --build . - --config ${CMAKE_BUILD_TYPE} - --target install - --parallel - ) - - add_dependencies(MINIZIP::minizip-ng minizip-ng_install) - message(STATUS "Installing minizip-ng: ${minizip-ng_LIBRARY} (version \"${minizip-ng_VERSION}\")") -endif() - ############################################################################### ### Configure target ### diff --git a/share/cmake/modules/Findopenfx.cmake b/share/cmake/modules/Findopenfx.cmake index 8b0eefb344..c639e72631 100644 --- a/share/cmake/modules/Findopenfx.cmake +++ b/share/cmake/modules/Findopenfx.cmake @@ -17,11 +17,6 @@ # downloaded at build time. # -if(NOT TARGET openfx::module) - add_library(openfx::module INTERFACE IMPORTED GLOBAL) - set(_openfx_TARGET_CREATE TRUE) -endif() - ############################################################################### ### Try to find package ### @@ -56,45 +51,11 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) endif() ############################################################################### -### Install package from source ### - -if(NOT openfx_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) - include(ExternalProject) - include(GNUInstallDirs) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") - set(_openfx_INSTALL_DIR "${_EXT_BUILD_ROOT}/openfx/src/openfx_install") +### Create target - # Set find_package standard args - set(openfx_FOUND TRUE) - set(openfx_VERSION ${openfx_FIND_VERSION}) - set(openfx_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}/openfx") - - if(_openfx_TARGET_CREATE) - # Hack to let imported target be built from ExternalProject_Add - file(MAKE_DIRECTORY ${openfx_INCLUDE_DIR}) - - ExternalProject_Add(openfx_install - GIT_REPOSITORY "https://github.com/ofxa/openfx.git" - GIT_TAG "OFX_Release_${openfx_FIND_VERSION_MAJOR}_${openfx_FIND_VERSION_MINOR}_TAG" - GIT_CONFIG advice.detachedHead=false - GIT_SHALLOW TRUE - PREFIX "${_EXT_BUILD_ROOT}/openfx" - BUILD_BYPRODUCTS ${openfx_INCLUDE_DIR} - CONFIGURE_COMMAND "" - BUILD_COMMAND - ${CMAKE_COMMAND} -E copy_directory - "${_EXT_BUILD_ROOT}/openfx/src/openfx_install/include" - "${openfx_INCLUDE_DIR}" - INSTALL_COMMAND "" - CMAKE_ARGS ${openfx_CMAKE_ARGS} - EXCLUDE_FROM_ALL TRUE - ) - - add_dependencies(openfx::module openfx_install) - message(STATUS "Installing openfx: ${openfx_INCLUDE_DIR} (version \"${openfx_VERSION}\")") - endif() +if(openfx_FOUND AND NOT TARGET openfx::module) + add_library(openfx::module INTERFACE IMPORTED GLOBAL) + set(_openfx_TARGET_CREATE TRUE) endif() ############################################################################### diff --git a/share/cmake/modules/Findpybind11.cmake b/share/cmake/modules/Findpybind11.cmake index e6c2f35a86..0ed436bf49 100644 --- a/share/cmake/modules/Findpybind11.cmake +++ b/share/cmake/modules/Findpybind11.cmake @@ -126,94 +126,11 @@ endif() ############################################################################### ### Create target ### -if(NOT TARGET pybind11::module) +if(pybind11_FOUND AND NOT TARGET pybind11::module) add_library(pybind11::module INTERFACE IMPORTED GLOBAL) set(_pybind11_TARGET_CREATE TRUE) endif() -############################################################################### -### Install package from source ### - -if(NOT pybind11_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) - include(ExternalProject) - include(GNUInstallDirs) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") - - # Set find_package standard args - set(pybind11_FOUND TRUE) - set(pybind11_VERSION ${pybind11_FIND_VERSION}) - set(pybind11_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") - - if(_pybind11_TARGET_CREATE) - # Hack to let imported target be built from ExternalProject_Add - file(MAKE_DIRECTORY ${pybind11_INCLUDE_DIR}) - - set(pybind11_CMAKE_ARGS - ${pybind11_CMAKE_ARGS} - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} - -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} - -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} - -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} - -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} - -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} - # Using FindPython mode (PYBIND11_FINDPYTHON=ON) doesn't seem to - # work when building on docker manylinux images where Development - # component is not available but is hardcoded in pybind11 script. - -DPYTHON_EXECUTABLE=${Python_EXECUTABLE} - -DPYBIND11_INSTALL=ON - -DPYBIND11_TEST=OFF - ) - - if(CMAKE_TOOLCHAIN_FILE) - set(pybind11_CMAKE_ARGS - ${pybind11_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) - endif() - - if(APPLE) - string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") - - set(pybind11_CMAKE_ARGS - ${pybind11_CMAKE_ARGS} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} - -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} - ) - endif() - - if (ANDROID) - set(pybind11_CMAKE_ARGS - ${pybind11_CMAKE_ARGS} - -DANDROID_PLATFORM=${ANDROID_PLATFORM} - -DANDROID_ABI=${ANDROID_ABI} - -DANDROID_STL=${ANDROID_STL}) - endif() - - ExternalProject_Add(pybind11_install - GIT_REPOSITORY "https://github.com/pybind/pybind11.git" - GIT_TAG "v${pybind11_FIND_VERSION}" - GIT_CONFIG advice.detachedHead=false - GIT_SHALLOW TRUE - PREFIX "${_EXT_BUILD_ROOT}/pybind11" - BUILD_BYPRODUCTS ${pybind11_INCLUDE_DIR} - CMAKE_ARGS ${pybind11_CMAKE_ARGS} - EXCLUDE_FROM_ALL TRUE - BUILD_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} --build . - --config ${CMAKE_BUILD_TYPE} - --target install - --parallel - ) - - add_dependencies(pybind11::module pybind11_install) - message(STATUS "Installing pybind11: ${pybind11_INCLUDE_DIR} (version \"${pybind11_VERSION}\")") - endif() -endif() - ############################################################################### ### Configure target ### diff --git a/share/cmake/modules/Findpystring.cmake b/share/cmake/modules/Findpystring.cmake index bbd5e1fd27..a83ed4a753 100644 --- a/share/cmake/modules/Findpystring.cmake +++ b/share/cmake/modules/Findpystring.cmake @@ -17,11 +17,6 @@ # 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) -endif() - ############################################################################### ### Try to find package ### @@ -64,96 +59,11 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) endif() ############################################################################### -### Install package from source ### - -if(NOT pystring_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) - include(ExternalProject) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - 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}/${CMAKE_INSTALL_INCLUDEDIR}") - - set(pystring_LIBRARY - "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}pystring${CMAKE_STATIC_LIBRARY_SUFFIX}") - - if(_pystring_TARGET_CREATE) - if(MSVC) - set(pystring_CXX_FLAGS "${pystring_CXX_FLAGS} /EHsc") - endif() - - string(STRIP "${pystring_CXX_FLAGS}" pystring_CXX_FLAGS) - - set(pystring_CMAKE_ARGS - ${pystring_CMAKE_ARGS} - -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} - -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_CXX_FLAGS=${pystring_CXX_FLAGS} - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} - -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} - -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} - -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} - -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} - ) - - if(CMAKE_TOOLCHAIN_FILE) - set(pystring_CMAKE_ARGS - ${pystring_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) - endif() - - if(APPLE) - string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") - - set(pystring_CMAKE_ARGS - ${pystring_CMAKE_ARGS} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} - -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} - ) - endif() - - - if (ANDROID) - set(pystring_CMAKE_ARGS - ${pystring_CMAKE_ARGS} - -DANDROID_PLATFORM=${ANDROID_PLATFORM} - -DANDROID_ABI=${ANDROID_ABI} - -DANDROID_STL=${ANDROID_STL}) - endif() - - # Hack to let imported target be built from ExternalProject_Add - 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_CONFIG advice.detachedHead=false - GIT_SHALLOW TRUE - PREFIX "${_EXT_BUILD_ROOT}/pystring" - BUILD_BYPRODUCTS ${pystring_LIBRARY} - CMAKE_ARGS ${pystring_CMAKE_ARGS} - EXCLUDE_FROM_ALL TRUE - PATCH_COMMAND - ${CMAKE_COMMAND} -E copy - "${CMAKE_SOURCE_DIR}/share/cmake/projects/Buildpystring.cmake" - "CMakeLists.txt" - BUILD_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} --build . - --config ${CMAKE_BUILD_TYPE} - --target install - --parallel - ) +### Configure target ### - add_dependencies(pystring::pystring pystring_install) - message(STATUS "Installing pystring: ${pystring_LIBRARY} (version \"${pystring_VERSION}\")") - endif() +if(pystring_FOUND AND NOT TARGET pystring::pystring) + add_library(pystring::pystring UNKNOWN IMPORTED GLOBAL) + set(_pystring_TARGET_CREATE TRUE) endif() ############################################################################### @@ -166,4 +76,4 @@ if(_pystring_TARGET_CREATE) ) mark_as_advanced(pystring_INCLUDE_DIR pystring_LIBRARY pystring_VERSION) -endif() +endif() \ No newline at end of file diff --git a/share/cmake/modules/Findyaml-cpp.cmake b/share/cmake/modules/Findyaml-cpp.cmake index 59558ce6a9..9e651b98c0 100644 --- a/share/cmake/modules/Findyaml-cpp.cmake +++ b/share/cmake/modules/Findyaml-cpp.cmake @@ -128,128 +128,13 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) endif() ############################################################################### -### Create target (if previous 'find_package' call hasn't) ### +### Create target -if(NOT TARGET yaml-cpp) +if(yaml-cpp_FOUND AND 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 AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) - include(ExternalProject) - include(GNUInstallDirs) - - set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") - set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") - - # Set find_package standard args - set(yaml-cpp_FOUND TRUE) - set(yaml-cpp_VERSION ${yaml-cpp_FIND_VERSION}) - set(yaml-cpp_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") - - # Starting from 0.7.0, this is included on all platforms, we could also - # override CMAKE_DEBUG_POSTFIX to bypass it. - if(BUILD_TYPE_DEBUG) - string(APPEND _yaml-cpp_LIB_SUFFIX "d") - endif() - - # Set the expected library name - set(yaml-cpp_LIBRARY - "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}yaml-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) - if(USE_CLANG) - # Remove some global 'shadow' warnings. - set(yaml-cpp_CXX_FLAGS "${yaml-cpp_CXX_FLAGS} -Wno-shadow") - endif() - endif() - - string(STRIP "${yaml-cpp_CXX_FLAGS}" yaml-cpp_CXX_FLAGS) - - set(yaml-cpp_CMAKE_ARGS - ${yaml-cpp_CMAKE_ARGS} - -DCMAKE_POLICY_DEFAULT_CMP0063=NEW - -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} - -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} - -DCMAKE_POSITION_INDEPENDENT_CODE=ON - -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} - -DCMAKE_CXX_FLAGS=${yaml-cpp_CXX_FLAGS} - -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} - -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} - -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} - -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} - -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} - -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} - -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} - -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} - -DBUILD_SHARED_LIBS=OFF - -DYAML_BUILD_SHARED_LIBS=OFF - -DYAML_CPP_BUILD_TESTS=OFF - -DYAML_CPP_BUILD_TOOLS=OFF - -DYAML_CPP_BUILD_CONTRIB=OFF - ) - - if(CMAKE_TOOLCHAIN_FILE) - set(yaml-cpp_CMAKE_ARGS - ${yaml-cpp_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) - endif() - - if(APPLE) - string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") - - set(yaml-cpp_CMAKE_ARGS - ${yaml-cpp_CMAKE_ARGS} - -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} - -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} - ) - endif() - - - if (ANDROID) - set(yaml-cpp_CMAKE_ARGS - ${yaml-cpp_CMAKE_ARGS} - -DANDROID_PLATFORM=${ANDROID_PLATFORM} - -DANDROID_ABI=${ANDROID_ABI} - -DANDROID_STL=${ANDROID_STL}) - 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 - BUILD_COMMAND "" - INSTALL_COMMAND - ${CMAKE_COMMAND} --build . - --config ${CMAKE_BUILD_TYPE} - --target install - --parallel - ) - - add_dependencies(yaml-cpp yaml-cpp_install) - message(STATUS - "Installing yaml-cpp: ${yaml-cpp_LIBRARY} (version \"${yaml-cpp_VERSION}\")" - ) - endif() -endif() - ############################################################################### ### Configure target ### @@ -260,4 +145,4 @@ if(_yaml-cpp_TARGET_CREATE) ) mark_as_advanced(yaml-cpp_INCLUDE_DIR yaml-cpp_LIBRARY yaml-cpp_VERSION) -endif() +endif() \ No newline at end of file diff --git a/share/cmake/modules/install/InstallImath.cmake b/share/cmake/modules/install/InstallImath.cmake new file mode 100644 index 0000000000..8e40bd8fb5 --- /dev/null +++ b/share/cmake/modules/install/InstallImath.cmake @@ -0,0 +1,140 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +# TODOCED Header + +############################################################################### +### Create target + +if (NOT TARGET Imath::Imath) + add_library(Imath::Imath UNKNOWN IMPORTED GLOBAL) + add_library(Imath::ImathConfig INTERFACE IMPORTED GLOBAL) + set(_Imath_TARGET_CREATE TRUE) +endif() + +############################################################################### +### Install package from source ### + +if(NOT Imath_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + include(ExternalProject) + include(GNUInstallDirs) + + set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") + set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") + + # Set find_package standard args + set(Imath_FOUND TRUE) + if(OCIO_Imath_RECOMMENDED_VERSION) + set(Imath_VERSION ${OCIO_Imath_RECOMMENDED_VERSION}) + else() + set(Imath_VERSION ${Imath_FIND_VERSION}) + endif() + set(Imath_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") + + # Set the expected library name + if(BUILD_TYPE_DEBUG) + set(_Imath_LIB_SUFFIX "_d") + endif() + + include(VersionUtils) + split_version_string(${Imath_VERSION} _Imath_ExternalProject) + + set(_Imath_LIB_VER "${_Imath_ExternalProject_VERSION_MAJOR}_${_Imath_ExternalProject_VERSION_MINOR}") + + set(Imath_LIBRARY + "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}Imath-${_Imath_LIB_VER}${_Imath_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") + + if(_Imath_TARGET_CREATE) + if(MSVC) + set(Imath_CXX_FLAGS "${Imath_CXX_FLAGS} /EHsc") + endif() + + string(STRIP "${Imath_CXX_FLAGS}" Imath_CXX_FLAGS) + + set(Imath_CMAKE_ARGS + ${Imath_CMAKE_ARGS} + -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} + -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_CXX_FLAGS=${Imath_CXX_FLAGS} + -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} + -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} + -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} + -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} + -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} + -DBUILD_SHARED_LIBS=OFF + -DBUILD_TESTING=OFF + -DPYTHON=OFF + -DDOCS=OFF + -DIMATH_HALF_USE_LOOKUP_TABLE=OFF + ) + + if(CMAKE_TOOLCHAIN_FILE) + set(Imath_CMAKE_ARGS + ${Imath_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() + + if(APPLE) + string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") + + set(Imath_CMAKE_ARGS + ${Imath_CMAKE_ARGS} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} + -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} + ) + endif() + + if (ANDROID) + set(Imath_CMAKE_ARGS + ${Imath_CMAKE_ARGS} + -DANDROID_PLATFORM=${ANDROID_PLATFORM} + -DANDROID_ABI=${ANDROID_ABI} + -DANDROID_STL=${ANDROID_STL}) + endif() + + # Hack to let imported target be built from ExternalProject_Add + file(MAKE_DIRECTORY ${Imath_INCLUDE_DIR}) + + ExternalProject_Add(imath_install + GIT_REPOSITORY "https://github.com/AcademySoftwareFoundation/Imath.git" + GIT_TAG "v${Imath_VERSION}" + GIT_CONFIG advice.detachedHead=false + GIT_SHALLOW TRUE + PREFIX "${_EXT_BUILD_ROOT}/Imath" + BUILD_BYPRODUCTS ${Imath_LIBRARY} + CMAKE_ARGS ${Imath_CMAKE_ARGS} + EXCLUDE_FROM_ALL TRUE + BUILD_COMMAND "" + INSTALL_COMMAND + ${CMAKE_COMMAND} --build . + --config ${CMAKE_BUILD_TYPE} + --target install + --parallel + ) + + add_dependencies(Imath::Imath imath_install) + + message(STATUS "Installing Imath: ${Imath_LIBRARY} (version \"${Imath_VERSION}\")") + endif() +endif() + +############################################################################### +### Configure target ### + +if(_Imath_TARGET_CREATE) + file(MAKE_DIRECTORY ${Imath_INCLUDE_DIR}/Imath) + + set_target_properties(Imath::Imath PROPERTIES + IMPORTED_LOCATION ${Imath_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES "${Imath_INCLUDE_DIR};${Imath_INCLUDE_DIR}/Imath" + ) + set_target_properties(Imath::ImathConfig PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Imath_INCLUDE_DIR};${Imath_INCLUDE_DIR}/Imath" + ) + + mark_as_advanced(Imath_INCLUDE_DIR Imath_LIBRARY Imath_VERSION) +endif() diff --git a/share/cmake/modules/install/InstallOpenEXR.cmake b/share/cmake/modules/install/InstallOpenEXR.cmake new file mode 100644 index 0000000000..414c548fb9 --- /dev/null +++ b/share/cmake/modules/install/InstallOpenEXR.cmake @@ -0,0 +1,239 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. +# +# Locate or install OpenEXR. +# +# Variables defined by this module: +# OpenEXR_FOUND - If FALSE, do not try to link to OpenEXR +# OpenEXR_LIBRARY - OpenEXR library to link to +# OpenEXR_INCLUDE_DIR - Where to find OpenEXR headers +# OpenEXR_VERSION - The version of the library +# +# Imported targets defined by this module, if found: +# OpenEXR::Iex +# OpenEXR::IexConfig +# OpenEXR::IlmThread +# OpenEXR::IlmThreadConfig +# OpenEXR::OpenEXR +# OpenEXR::OpenEXRConfig +# OpenEXR::OpenEXRCore +# OpenEXR::OpenEXRUtil +# +# By default, the dynamic libraries of OpenEXR will be found. To find the +# static ones instead, you must set the OpenEXR_STATIC_LIBRARY variable to +# TRUE before calling find_package(OpenEXR ...). +# +# If OpenEXR is not installed in a standard path, you can use the +# OpenEXR_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, OpenEXR will be +# downloaded, statically-built, and used to generate +# libOpenColorIOimageioapphelpers. +# + +############################################################################### +### Try to find package ### + +############################################################################### +### Create target + +if (NOT TARGET OpenEXR::OpenEXR) + set(_OpenEXR_TARGET_CREATE TRUE) +endif() + +############################################################################### +### Install package from source ### + +macro(set_target_location target_name) + if(NOT DEFINED "${target_name}_LIBRARY") + set("${target_name}_LIBRARY" "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${target_name}-${_OpenEXR_LIB_VER}${_OpenEXR_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") + endif() +endmacro() + +if(NOT OpenEXR_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + include(ExternalProject) + include(GNUInstallDirs) + + set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") + set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") + + # Required dependency + if(NOT ZLIB_FOUND) + # ZLIB is required for OCIO too. + # Try to find ZLIB without specifying a version since at this point in the dependencies + # check, ZLIB should already be found. If not, the configure step will fail either way. + ocio_find_package(ZLIB VERSION_VARS ZLIB_VERSION_STRING ZLIB_VERSION) + if(NOT ZLIB_FOUND) + message(STATUS "ZLIB is required to build OpenEXR.") + return() + endif() + endif() + + ocio_find_package(Threads) + if(NOT Threads_FOUND) + message(STATUS "Threads is required to build OpenEXR.") + return() + endif() + + # Set find_package standard args + set(OpenEXR_FOUND TRUE) + if(OCIO_OpenEXR_RECOMMENDED_VERSION) + set(OpenEXR_VERSION ${OCIO_OpenEXR_RECOMMENDED_VERSION}) + else() + set(OpenEXR_VERSION ${OpenEXR_FIND_VERSION}) + endif() + set(OpenEXR_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") + + # Set the expected library name + if(BUILD_TYPE_DEBUG) + set(_OpenEXR_LIB_SUFFIX "_d") + endif() + + include(VersionUtils) + split_version_string(${OpenEXR_VERSION} _OpenEXR) + + set(_OpenEXR_LIB_VER "${_OpenEXR_VERSION_MAJOR}_${_OpenEXR_VERSION_MINOR}") + + set_target_location(Iex) + set_target_location(IlmThread) + set_target_location(OpenEXR) + set_target_location(OpenEXRCore) + set_target_location(OpenEXRUtil) + + if(_OpenEXR_TARGET_CREATE) + if(MSVC) + set(OpenEXR_CXX_FLAGS "${OpenEXR_CXX_FLAGS} /EHsc") + endif() + + string(STRIP "${OpenEXR_CXX_FLAGS}" OpenEXR_CXX_FLAGS) + + set(OpenEXR_CMAKE_ARGS + ${OpenEXR_CMAKE_ARGS} + -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} + -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_CXX_FLAGS=${OpenEXR_CXX_FLAGS} + -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} + -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} + -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} + -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} + -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} + -DBUILD_SHARED_LIBS=OFF + -DBUILD_TESTING=OFF + -DOPENEXR_INSTALL_EXAMPLES=OFF + -DOPENEXR_INSTALL_TOOLS=OFF + # Try to use in-source built Imath first, if available. + -DCMAKE_PREFIX_PATH=${_EXT_DIST_ROOT} + ) + + if(CMAKE_TOOLCHAIN_FILE) + set(OpenEXR_CMAKE_ARGS + ${OpenEXR_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() + + if(APPLE) + string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") + + set(OpenEXR_CMAKE_ARGS + ${OpenEXR_CMAKE_ARGS} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} + -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} + ) + endif() + + if (ANDROID) + set(OpenEXR_CMAKE_ARGS + ${OpenEXR_CMAKE_ARGS} + -DANDROID_PLATFORM=${ANDROID_PLATFORM} + -DANDROID_ABI=${ANDROID_ABI} + -DANDROID_STL=${ANDROID_STL}) + endif() + + # Hack to let imported target be built from ExternalProject_Add + file(MAKE_DIRECTORY ${OpenEXR_INCLUDE_DIR}) + + ExternalProject_Add(openexr_install + GIT_REPOSITORY "https://github.com/AcademySoftwareFoundation/openexr.git" + GIT_TAG "v${OpenEXR_VERSION}" + GIT_CONFIG advice.detachedHead=false + GIT_SHALLOW TRUE + PREFIX "${_EXT_BUILD_ROOT}/openexr" + BUILD_BYPRODUCTS + ${Iex_LIBRARY} + ${IlmThread_LIBRARY} + ${OpenEXR_LIBRARY} + ${OpenEXRCore_LIBRARY} + ${OpenEXRUtil_LIBRARY} + CMAKE_ARGS ${OpenEXR_CMAKE_ARGS} + EXCLUDE_FROM_ALL TRUE + BUILD_COMMAND "" + INSTALL_COMMAND + ${CMAKE_COMMAND} --build . + --config ${CMAKE_BUILD_TYPE} + --target install + --parallel + ) + + # Additional targets. ALIAS to UNKNOWN imported target is only possible + # from CMake 3.15, so we explicitly define targets as STATIC here. + add_library(OpenEXR::Iex STATIC IMPORTED GLOBAL) + add_library(OpenEXR::IexConfig INTERFACE IMPORTED GLOBAL) + add_library(OpenEXR::IlmThread STATIC IMPORTED GLOBAL) + add_library(OpenEXR::IlmThreadConfig INTERFACE IMPORTED GLOBAL) + add_library(OpenEXR::OpenEXR STATIC IMPORTED GLOBAL) + add_library(OpenEXR::OpenEXRConfig INTERFACE IMPORTED GLOBAL) + add_library(OpenEXR::OpenEXRCore STATIC IMPORTED GLOBAL) + add_library(OpenEXR::OpenEXRUtil STATIC IMPORTED GLOBAL) + + add_dependencies(OpenEXR::OpenEXR openexr_install) + + message(STATUS "Installing OpenEXR: ${OpenEXR_LIBRARY} (version \"${OpenEXR_VERSION}\")") + endif() +endif() + +############################################################################### +### Configure target ### + +if(_OpenEXR_TARGET_CREATE) + file(MAKE_DIRECTORY ${OpenEXR_INCLUDE_DIR}/OpenEXR) + + set_target_properties(OpenEXR::Iex PROPERTIES + IMPORTED_LOCATION ${Iex_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "OpenEXR::IlmThreadConfig;OpenEXR::IlmThreadConfig" + ) + set_target_properties(OpenEXR::IexConfig PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR};${OpenEXR_INCLUDE_DIR}/OpenEXR" + ) + set_target_properties(OpenEXR::IlmThread PROPERTIES + IMPORTED_LOCATION ${IlmThread_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "OpenEXR::IlmThreadConfig;OpenEXR::IlmThreadConfig;OpenEXR::Iex;Threads::Threads" + ) + set_target_properties(OpenEXR::IlmThreadConfig PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR};${OpenEXR_INCLUDE_DIR}/OpenEXR" + ) + set_target_properties(OpenEXR::OpenEXR PROPERTIES + IMPORTED_LOCATION ${OpenEXR_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "OpenEXR::IlmThreadConfig;Imath::Imath;OpenEXR::IlmThreadConfig;OpenEXR::Iex;OpenEXR::IlmThread;ZLIB::ZLIB" + ) + set_target_properties(OpenEXR::OpenEXRConfig PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR};${OpenEXR_INCLUDE_DIR}/OpenEXR" + ) + set_target_properties(OpenEXR::OpenEXRCore PROPERTIES + IMPORTED_LOCATION ${OpenEXRCore_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "OpenEXR::IlmThreadConfig;ZLIB::ZLIB;\$" + ) + set_target_properties(OpenEXR::OpenEXRUtil PROPERTIES + IMPORTED_LOCATION ${OpenEXRUtil_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES "${OpenEXR_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "OpenEXR::IlmThreadConfig;OpenEXR::OpenEXR" + ) + + mark_as_advanced(OpenEXR_INCLUDE_DIR OpenEXR_LIBRARY OpenEXR_VERSION) +endif() diff --git a/share/cmake/modules/InstallZLIB.cmake b/share/cmake/modules/install/InstallZLIB.cmake similarity index 97% rename from share/cmake/modules/InstallZLIB.cmake rename to share/cmake/modules/install/InstallZLIB.cmake index 954563ec4e..3859149c29 100644 --- a/share/cmake/modules/InstallZLIB.cmake +++ b/share/cmake/modules/install/InstallZLIB.cmake @@ -47,8 +47,8 @@ if(NOT ZLIB_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGE # Set find_package standard args set(ZLIB_FOUND TRUE) - if(_ZLIB_ExternalProject_VERSION) - set(ZLIB_VERSION ${_ZLIB_ExternalProject_VERSION}) + if(OCIO_ZLIB_RECOMMENDED_VERSION) + set(ZLIB_VERSION ${OCIO_ZLIB_RECOMMENDED_VERSION}) else() set(ZLIB_VERSION ${ZLIB_FIND_VERSION}) endif() @@ -138,7 +138,7 @@ if(NOT ZLIB_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGE set(ZLIB_LIBRARY ${ZLIB_LIBRARIES}) set(ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIRS}) - message(STATUS "Installing ZLIB: ${ZLIB_LIBRARIES} (version \"${ZLIB_VERSION}\")") + message(STATUS "Installing ZLIB: ${ZLIB_LIBRARIES} (version \"${ZLIB_VERSION}\") ") endif() diff --git a/share/cmake/modules/install/Installexpat.cmake b/share/cmake/modules/install/Installexpat.cmake new file mode 100644 index 0000000000..e25f7a9bdb --- /dev/null +++ b/share/cmake/modules/install/Installexpat.cmake @@ -0,0 +1,149 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +# TODOCED Header + +############################################################################### +### 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 AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + include(ExternalProject) + include(GNUInstallDirs) + + set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") + set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") + + # Set find_package standard args + set(expat_FOUND TRUE) + set(expat_VERSION ${expat_FIND_VERSION}) + if(OCIO_expat_RECOMMENDED_VERSION) + set(expat_VERSION ${OCIO_expat_RECOMMENDED_VERSION}) + else() + set(expat_VERSION ${expat_FIND_VERSION}) + endif() + 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() + + # Expat use a hardcoded lib prefix instead of CMAKE_STATIC_LIBRARY_PREFIX + # https://github.com/libexpat/libexpat/blob/R_2_4_1/expat/CMakeLists.txt#L374 + set(_expat_LIB_PREFIX "lib") + + set(expat_LIBRARY + "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${_expat_LIB_PREFIX}expat${_expat_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") + + if(_expat_TARGET_CREATE) + 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_POLICY_DEFAULT_CMP0063=NEW + -DCMAKE_C_VISIBILITY_PRESET=${CMAKE_C_VISIBILITY_PRESET} + -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} + -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_C_FLAGS=${EXPAT_C_FLAGS} + -DCMAKE_CXX_FLAGS=${EXPAT_CXX_FLAGS} + -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} + -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} + -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} + -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} + -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} + -DEXPAT_BUILD_DOCS=OFF + -DEXPAT_BUILD_EXAMPLES=OFF + -DEXPAT_BUILD_TESTS=OFF + -DEXPAT_BUILD_TOOLS=OFF + -DEXPAT_SHARED_LIBS=OFF + ) + + if(CMAKE_TOOLCHAIN_FILE) + set(EXPAT_CMAKE_ARGS + ${EXPAT_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() + + if(APPLE) + string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") + + set(EXPAT_CMAKE_ARGS + ${EXPAT_CMAKE_ARGS} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} + -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} + ) + endif() + + if (ANDROID) + set(EXPAT_CMAKE_ARGS + ${EXPAT_CMAKE_ARGS} + -DANDROID_PLATFORM=${ANDROID_PLATFORM} + -DANDROID_ABI=${ANDROID_ABI} + -DANDROID_STL=${ANDROID_STL}) + endif() + + # Hack to let imported target be built from ExternalProject_Add + file(MAKE_DIRECTORY ${expat_INCLUDE_DIR}) + + string(REPLACE "." ";" VERSION_LIST ${expat_VERSION}) + list(GET VERSION_LIST 0 expat_VERSION_MAJOR) + list(GET VERSION_LIST 1 expat_VERSION_MINOR) + list(GET VERSION_LIST 2 expat_VERSION_PATCH) + + ExternalProject_Add(expat_install + GIT_REPOSITORY "https://github.com/libexpat/libexpat.git" + GIT_TAG "R_${expat_VERSION_MAJOR}_${expat_VERSION_MINOR}_${expat_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 + BUILD_COMMAND "" + INSTALL_COMMAND + ${CMAKE_COMMAND} --build . + --config ${CMAKE_BUILD_TYPE} + --target install + --parallel + ) + + 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/install/Installlcms2.cmake b/share/cmake/modules/install/Installlcms2.cmake new file mode 100644 index 0000000000..e89bbed904 --- /dev/null +++ b/share/cmake/modules/install/Installlcms2.cmake @@ -0,0 +1,127 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +############################################################################### +### Configure target ### + +if(NOT TARGET lcms2::lcms2) + add_library(lcms2::lcms2 UNKNOWN IMPORTED GLOBAL) + set(_lcms2_TARGET_CREATE TRUE) +endif() + +############################################################################### +### Install package from source ### + +if(NOT lcms2_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + include(ExternalProject) + + set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") + set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") + + # Set find_package standard args + set(lcms2_FOUND TRUE) + if(OCIO_lcms2_RECOMMENDED_VERSION) + set(lcms2_VERSION ${OCIO_lcms2_RECOMMENDED_VERSION}) + else() + set(lcms2_VERSION ${lcms2_FIND_VERSION}) + endif() + set(lcms2_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}/lcms2") + set(lcms2_LIBRARY + "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}lcms2${CMAKE_STATIC_LIBRARY_SUFFIX}") + + if(_lcms2_TARGET_CREATE) + if(UNIX) + set(lcms2_C_FLAGS "${lcms2_C_FLAGS} -fvisibility=hidden -fPIC") + endif() + + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + set(lcms2_C_FLAGS "${lcms2_C_FLAGS} -Wno-aggressive-loop-optimizations") + endif() + + string(STRIP "${lcms2_C_FLAGS}" lcms2_C_FLAGS) + + # NOTE: Depending of the compiler version lcm2 2.2 does not compile with C++17 so revert + # to C++11 because the library is only used by a cmd line tool. + + set(lcms2_CXX_STANDARD ${CMAKE_CXX_STANDARD}) + if(${CMAKE_CXX_STANDARD} GREATER_EQUAL 17) + set(lcms2_CXX_STANDARD 11) + endif() + + set(lcms2_CMAKE_ARGS + ${lcms2_CMAKE_ARGS} + -DCMAKE_C_FLAGS=${lcms2_C_FLAGS} + -DCMAKE_CXX_STANDARD=${lcms2_CXX_STANDARD} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} + -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} + -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} + -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} + -DBUILD_SHARED_LIBS=OFF + ) + + if(CMAKE_TOOLCHAIN_FILE) + set(lcms2_CMAKE_ARGS + ${lcms2_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() + + if(APPLE) + string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") + + set(lcms2_CMAKE_ARGS + ${lcms2_CMAKE_ARGS} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} + -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} + ) + endif() + + if (ANDROID) + set(lcms2_CMAKE_ARGS + ${lcms2_CMAKE_ARGS} + -DANDROID_PLATFORM=${ANDROID_PLATFORM} + -DANDROID_ABI=${ANDROID_ABI} + -DANDROID_STL=${ANDROID_STL}) + endif() + + # Hack to let imported target be built from ExternalProject_Add + 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_CONFIG advice.detachedHead=false + GIT_SHALLOW TRUE + PREFIX "${_EXT_BUILD_ROOT}/Little-CMS" + BUILD_BYPRODUCTS ${lcms2_LIBRARY} + CMAKE_ARGS ${lcms2_CMAKE_ARGS} + EXCLUDE_FROM_ALL TRUE + PATCH_COMMAND + ${CMAKE_COMMAND} -E copy + "${CMAKE_SOURCE_DIR}/share/cmake/projects/Buildlcms2.cmake" + "CMakeLists.txt" + BUILD_COMMAND "" + INSTALL_COMMAND + ${CMAKE_COMMAND} --build . + --config ${CMAKE_BUILD_TYPE} + --target install + --parallel + ) + + add_dependencies(lcms2::lcms2 lcms2_install) + message(STATUS "Installing lcms2: ${lcms2_LIBRARY} (version \"${lcms2_VERSION}\")") + endif() +endif() + +############################################################################### +### Configure target ### + +if(_lcms2_TARGET_CREATE) + set_target_properties(lcms2::lcms2 PROPERTIES + IMPORTED_LOCATION ${lcms2_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${lcms2_INCLUDE_DIR} + ) + + mark_as_advanced(lcms2_INCLUDE_DIR lcms2_LIBRARY lcms2_VERSION) +endif() \ No newline at end of file diff --git a/share/cmake/modules/install/Installminizip-ng.cmake b/share/cmake/modules/install/Installminizip-ng.cmake new file mode 100644 index 0000000000..2ac7d0353e --- /dev/null +++ b/share/cmake/modules/install/Installminizip-ng.cmake @@ -0,0 +1,136 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +############################################################################### +### Create target +if(NOT TARGET MINIZIP::minizip-ng) + add_library(MINIZIP::minizip-ng UNKNOWN IMPORTED GLOBAL) + set(_minizip-ng_TARGET_CREATE TRUE) +endif() + +############################################################################### +### Install package from source ### + +if(NOT minizip-ng_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + include(ExternalProject) + include(GNUInstallDirs) + + set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") + set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") + + # Set find_package standard args + set(minizip-ng_FOUND TRUE) + if(OCIO_minizip-ng_RECOMMENDED_VERSION) + set(minizip-ng_VERSION ${OCIO_minizip-ng_RECOMMENDED_VERSION}) + else() + set(minizip-ng_VERSION ${minizip-ng_FIND_VERSION}) + endif() + + set(minizip-ng_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}/minizip-ng") + + # Minizip-ng use a hardcoded lib prefix instead of CMAKE_STATIC_LIBRARY_PREFIX + set(_minizip-ng_LIB_PREFIX "lib") + + set(minizip-ng_LIBRARY + "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${_minizip-ng_LIB_PREFIX}minizip-ng${_minizip-ng_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}") + + if(_minizip-ng_TARGET_CREATE) + set(minizip-ng_CMAKE_ARGS + ${minizip-ng_CMAKE_ARGS} + -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} + -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} + -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} + -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} + -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + # Since the other modules create a subfolder for the includes by default and since + # minizip-ng does not, a suffix is added to CMAKE_INSTALL_INCLUDEDIR in order to + # install the headers under a subdirectory named "minizip-ng". + # Note that this does not affect external builds for minizip-ng. + -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}/minizip-ng + -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} + -DBUILD_SHARED_LIBS=OFF + -DMZ_OPENSSL=OFF + -DMZ_LIBBSD=OFF + -DMZ_BUILD_TESTS=OFF + -DMZ_COMPAT=OFF + -DMZ_BZIP2=OFF + -DMZ_LZMA=OFF + -DMZ_LIBCOMP=OFF + -DMZ_ZSTD=OFF + -DMZ_PKCRYPT=OFF + -DMZ_WZAES=OFF + -DMZ_SIGNING=OFF + -DMZ_ZLIB=ON + -DMZ_ICONV=OFF + -DMZ_FETCH_LIBS=OFF + -DMZ_FORCE_FETCH_LIBS=OFF + -DZLIB_LIBRARY=${ZLIB_LIBRARIES} + -DZLIB_INCLUDE_DIR=${ZLIB_INCLUDE_DIRS} + ) + + if(CMAKE_TOOLCHAIN_FILE) + set(minizip-ng_CMAKE_ARGS + ${minizip-ng_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() + + if(APPLE) + string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") + + set(minizip-ng_CMAKE_ARGS + ${minizip-ng_CMAKE_ARGS} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} + -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} + ) + endif() + + if (ANDROID) + set(minizip-ng_CMAKE_ARGS + ${minizip-ng_CMAKE_ARGS} + -DANDROID_PLATFORM=${ANDROID_PLATFORM} + -DANDROID_ABI=${ANDROID_ABI} + -DANDROID_STL=${ANDROID_STL}) + endif() + endif() + + # Hack to let imported target be built from ExternalProject_Add + file(MAKE_DIRECTORY ${minizip-ng_INCLUDE_DIR}) + + ExternalProject_Add(minizip-ng_install + GIT_REPOSITORY "https://github.com/zlib-ng/minizip-ng.git" + GIT_TAG "${minizip-ng_VERSION}" + GIT_CONFIG advice.detachedHead=false + GIT_SHALLOW TRUE + PREFIX "${_EXT_BUILD_ROOT}/libminizip-ng" + BUILD_BYPRODUCTS ${minizip-ng_LIBRARY} + CMAKE_ARGS ${minizip-ng_CMAKE_ARGS} + EXCLUDE_FROM_ALL TRUE + BUILD_COMMAND "" + INSTALL_COMMAND + ${CMAKE_COMMAND} --build . + --config ${CMAKE_BUILD_TYPE} + --target install + --parallel + ) + + add_dependencies(MINIZIP::minizip-ng minizip-ng_install) + message(STATUS "Installing minizip-ng: ${minizip-ng_LIBRARY} (version \"${minizip-ng_VERSION}\")") +endif() + +############################################################################### +### Configure target ### + +if(_minizip-ng_TARGET_CREATE) + set_target_properties(MINIZIP::minizip-ng PROPERTIES + IMPORTED_LOCATION "${minizip-ng_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${minizip-ng_INCLUDE_DIR}" + ) + + mark_as_advanced(minizip-ng_INCLUDE_DIR minizip-ng_LIBRARY minizip-ng_VERSION) + + target_link_libraries(MINIZIP::minizip-ng INTERFACE ZLIB::ZLIB) +endif() \ No newline at end of file diff --git a/share/cmake/modules/install/Installopenfx.cmake b/share/cmake/modules/install/Installopenfx.cmake new file mode 100644 index 0000000000..5966a81978 --- /dev/null +++ b/share/cmake/modules/install/Installopenfx.cmake @@ -0,0 +1,72 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +############################################################################### +### Create target + +if(NOT TARGET openfx::module) + add_library(openfx::module INTERFACE IMPORTED GLOBAL) + set(_openfx_TARGET_CREATE TRUE) +endif() + +############################################################################### +### Install package from source ### + +if(NOT openfx_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + include(ExternalProject) + include(GNUInstallDirs) + + set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") + set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") + set(_openfx_INSTALL_DIR "${_EXT_BUILD_ROOT}/openfx/src/openfx_install") + + # Set find_package standard args + set(openfx_FOUND TRUE) + if(OCIO_openfx_RECOMMENDED_VERSION) + set(openfx_VERSION ${OCIO_openfx_RECOMMENDED_VERSION}) + else() + set(openfx_VERSION ${openfx_FIND_VERSION}) + endif() + set(openfx_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}/openfx") + + if(_openfx_TARGET_CREATE) + # Hack to let imported target be built from ExternalProject_Add + file(MAKE_DIRECTORY ${openfx_INCLUDE_DIR}) + + string(REPLACE "." ";" VERSION_LIST ${openfx_VERSION}) + list(GET VERSION_LIST 0 openfx_VERSION_MAJOR) + list(GET VERSION_LIST 1 openfx_VERSION_MINOR) + list(GET VERSION_LIST 2 openfx_VERSION_PATCH) + + ExternalProject_Add(openfx_install + GIT_REPOSITORY "https://github.com/ofxa/openfx.git" + GIT_TAG "OFX_Release_${openfx_VERSION_MAJOR}_${openfx_VERSION_MINOR}_TAG" + GIT_CONFIG advice.detachedHead=false + GIT_SHALLOW TRUE + PREFIX "${_EXT_BUILD_ROOT}/openfx" + BUILD_BYPRODUCTS ${openfx_INCLUDE_DIR} + CONFIGURE_COMMAND "" + BUILD_COMMAND + ${CMAKE_COMMAND} -E copy_directory + "${_EXT_BUILD_ROOT}/openfx/src/openfx_install/include" + "${openfx_INCLUDE_DIR}" + INSTALL_COMMAND "" + CMAKE_ARGS ${openfx_CMAKE_ARGS} + EXCLUDE_FROM_ALL TRUE + ) + + add_dependencies(openfx::module openfx_install) + message(STATUS "Installing openfx: ${openfx_INCLUDE_DIR} (version \"${openfx_VERSION}\")") + endif() +endif() + +############################################################################### +### Configure target ### + +if(_openfx_TARGET_CREATE) + set_target_properties(openfx::module PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${openfx_INCLUDE_DIR} + ) + + mark_as_advanced(openfx_INCLUDE_DIR) +endif() diff --git a/share/cmake/modules/install/Installpybind11.cmake b/share/cmake/modules/install/Installpybind11.cmake new file mode 100644 index 0000000000..141549fad9 --- /dev/null +++ b/share/cmake/modules/install/Installpybind11.cmake @@ -0,0 +1,108 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Proj + +############################################################################### +### Create target ### + +if(NOT TARGET pybind11::module) + add_library(pybind11::module INTERFACE IMPORTED GLOBAL) + set(_pybind11_TARGET_CREATE TRUE) +endif() + +############################################################################### +### Install package from source ### + +if(NOT pybind11_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + include(ExternalProject) + include(GNUInstallDirs) + + set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") + set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") + + # Set find_package standard args + set(pybind11_FOUND TRUE) + if(OCIO_pybind11_RECOMMENDED_VERSION) + set(pybind11_VERSION ${OCIO_pybind11_RECOMMENDED_VERSION}) + else() + set(pybind11_VERSION ${pybind11_FIND_VERSION}) + endif() + set(pybind11_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") + + if(_pybind11_TARGET_CREATE) + # Hack to let imported target be built from ExternalProject_Add + file(MAKE_DIRECTORY ${pybind11_INCLUDE_DIR}) + + set(pybind11_CMAKE_ARGS + ${pybind11_CMAKE_ARGS} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} + -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} + -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} + -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} + -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} + # Using FindPython mode (PYBIND11_FINDPYTHON=ON) doesn't seem to + # work when building on docker manylinux images where Development + # component is not available but is hardcoded in pybind11 script. + -DPYTHON_EXECUTABLE=${Python_EXECUTABLE} + -DPYBIND11_INSTALL=ON + -DPYBIND11_TEST=OFF + ) + + if(CMAKE_TOOLCHAIN_FILE) + set(pybind11_CMAKE_ARGS + ${pybind11_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() + + if(APPLE) + string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") + + set(pybind11_CMAKE_ARGS + ${pybind11_CMAKE_ARGS} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} + -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} + ) + endif() + + if (ANDROID) + set(pybind11_CMAKE_ARGS + ${pybind11_CMAKE_ARGS} + -DANDROID_PLATFORM=${ANDROID_PLATFORM} + -DANDROID_ABI=${ANDROID_ABI} + -DANDROID_STL=${ANDROID_STL}) + endif() + + ExternalProject_Add(pybind11_install + GIT_REPOSITORY "https://github.com/pybind/pybind11.git" + GIT_TAG "v${pybind11_VERSION}" + GIT_CONFIG advice.detachedHead=false + GIT_SHALLOW TRUE + PREFIX "${_EXT_BUILD_ROOT}/pybind11" + BUILD_BYPRODUCTS ${pybind11_INCLUDE_DIR} + CMAKE_ARGS ${pybind11_CMAKE_ARGS} + EXCLUDE_FROM_ALL TRUE + BUILD_COMMAND "" + INSTALL_COMMAND + ${CMAKE_COMMAND} --build . + --config ${CMAKE_BUILD_TYPE} + --target install + --parallel + ) + + add_dependencies(pybind11::module pybind11_install) + message(STATUS "Installing pybind11: ${pybind11_INCLUDE_DIR} (version \"${pybind11_VERSION}\")") + endif() +endif() + +############################################################################### +### Configure target ### + +if(_pybind11_TARGET_CREATE) + set_target_properties(pybind11::module PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${pybind11_INCLUDE_DIR} + ) + + mark_as_advanced(pybind11_INCLUDE_DIR pybind11_VERSION) +endif() \ No newline at end of file diff --git a/share/cmake/modules/install/Installpystring.cmake b/share/cmake/modules/install/Installpystring.cmake new file mode 100644 index 0000000000..d966f05e70 --- /dev/null +++ b/share/cmake/modules/install/Installpystring.cmake @@ -0,0 +1,119 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +############################################################################### +### Configure target ### + +if(NOT TARGET pystring::pystring) + add_library(pystring::pystring UNKNOWN IMPORTED GLOBAL) + set(_pystring_TARGET_CREATE TRUE) +endif() + +############################################################################### +### Install package from source ### + +if(NOT pystring_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + include(ExternalProject) + + set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") + set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") + + # Set find_package standard args + set(pystring_FOUND TRUE) + if(OCIO_pystring_RECOMMENDED_VERSION) + set(pystring_VERSION ${OCIO_pystring_RECOMMENDED_VERSION}) + else() + set(pystring_VERSION ${pystring_FIND_VERSION}) + endif() + set(pystring_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") + + set(pystring_LIBRARY + "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}pystring${CMAKE_STATIC_LIBRARY_SUFFIX}") + + if(_pystring_TARGET_CREATE) + if(MSVC) + set(pystring_CXX_FLAGS "${pystring_CXX_FLAGS} /EHsc") + endif() + + string(STRIP "${pystring_CXX_FLAGS}" pystring_CXX_FLAGS) + + set(pystring_CMAKE_ARGS + ${pystring_CMAKE_ARGS} + -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} + -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_CXX_FLAGS=${pystring_CXX_FLAGS} + -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} + -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} + -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} + -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} + ) + + if(CMAKE_TOOLCHAIN_FILE) + set(pystring_CMAKE_ARGS + ${pystring_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() + + if(APPLE) + string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") + + set(pystring_CMAKE_ARGS + ${pystring_CMAKE_ARGS} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} + -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} + ) + endif() + + + if (ANDROID) + set(pystring_CMAKE_ARGS + ${pystring_CMAKE_ARGS} + -DANDROID_PLATFORM=${ANDROID_PLATFORM} + -DANDROID_ABI=${ANDROID_ABI} + -DANDROID_STL=${ANDROID_STL}) + endif() + + # Hack to let imported target be built from ExternalProject_Add + file(MAKE_DIRECTORY ${pystring_INCLUDE_DIR}) + + ExternalProject_Add(pystring_install + GIT_REPOSITORY "https://github.com/imageworks/pystring.git" + GIT_TAG "v${pystring_VERSION}" + GIT_CONFIG advice.detachedHead=false + GIT_SHALLOW TRUE + PREFIX "${_EXT_BUILD_ROOT}/pystring" + BUILD_BYPRODUCTS ${pystring_LIBRARY} + CMAKE_ARGS ${pystring_CMAKE_ARGS} + EXCLUDE_FROM_ALL TRUE + PATCH_COMMAND + ${CMAKE_COMMAND} -E copy + "${CMAKE_SOURCE_DIR}/share/cmake/projects/Buildpystring.cmake" + "CMakeLists.txt" + BUILD_COMMAND "" + INSTALL_COMMAND + ${CMAKE_COMMAND} --build . + --config ${CMAKE_BUILD_TYPE} + --target install + --parallel + ) + + add_dependencies(pystring::pystring pystring_install) + message(STATUS "Installing pystring: ${pystring_LIBRARY} (version \"${pystring_VERSION}\")") + endif() +endif() + +############################################################################### +### Configure target ### + +if(_pystring_TARGET_CREATE) + set_target_properties(pystring::pystring PROPERTIES + IMPORTED_LOCATION ${pystring_LIBRARY} + INTERFACE_INCLUDE_DIRECTORIES ${pystring_INCLUDE_DIR} + ) + + mark_as_advanced(pystring_INCLUDE_DIR pystring_LIBRARY pystring_VERSION) +endif() diff --git a/share/cmake/modules/install/Installyaml-cpp.cmake b/share/cmake/modules/install/Installyaml-cpp.cmake new file mode 100644 index 0000000000..74f4db97f0 --- /dev/null +++ b/share/cmake/modules/install/Installyaml-cpp.cmake @@ -0,0 +1,143 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +# TODOCED Header + +############################################################################### +### 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 AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) + include(ExternalProject) + include(GNUInstallDirs) + + set(_EXT_DIST_ROOT "${CMAKE_BINARY_DIR}/ext/dist") + set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") + + # Set find_package standard args + set(yaml-cpp_FOUND TRUE) + if(OCIO_yaml-cpp_RECOMMENDED_VERSION) + set(yaml-cpp_VERSION ${OCIO_yaml-cpp_RECOMMENDED_VERSION}) + else() + set(yaml-cpp_VERSION ${yaml-cpp_FIND_VERSION}) + endif() + set(yaml-cpp_INCLUDE_DIR "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_INCLUDEDIR}") + + # Starting from 0.7.0, this is included on all platforms, we could also + # override CMAKE_DEBUG_POSTFIX to bypass it. + if(BUILD_TYPE_DEBUG) + string(APPEND _yaml-cpp_LIB_SUFFIX "d") + endif() + + # Set the expected library name + set(yaml-cpp_LIBRARY + "${_EXT_DIST_ROOT}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}yaml-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) + if(USE_CLANG) + # Remove some global 'shadow' warnings. + set(yaml-cpp_CXX_FLAGS "${yaml-cpp_CXX_FLAGS} -Wno-shadow") + endif() + endif() + + string(STRIP "${yaml-cpp_CXX_FLAGS}" yaml-cpp_CXX_FLAGS) + + set(yaml-cpp_CMAKE_ARGS + ${yaml-cpp_CMAKE_ARGS} + -DCMAKE_POLICY_DEFAULT_CMP0063=NEW + -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} + -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} + -DCMAKE_POSITION_INDEPENDENT_CODE=ON + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_CXX_FLAGS=${yaml-cpp_CXX_FLAGS} + -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD} + -DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE} + -DCMAKE_INSTALL_PREFIX=${_EXT_DIST_ROOT} + -DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR} + -DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR} + -DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR} + -DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR} + -DCMAKE_OBJECT_PATH_MAX=${CMAKE_OBJECT_PATH_MAX} + -DBUILD_SHARED_LIBS=OFF + -DYAML_BUILD_SHARED_LIBS=OFF + -DYAML_CPP_BUILD_TESTS=OFF + -DYAML_CPP_BUILD_TOOLS=OFF + -DYAML_CPP_BUILD_CONTRIB=OFF + ) + + if(CMAKE_TOOLCHAIN_FILE) + set(yaml-cpp_CMAKE_ARGS + ${yaml-cpp_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}) + endif() + + if(APPLE) + string(REPLACE ";" "$" ESCAPED_CMAKE_OSX_ARCHITECTURES "${CMAKE_OSX_ARCHITECTURES}") + + set(yaml-cpp_CMAKE_ARGS + ${yaml-cpp_CMAKE_ARGS} + -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET} + -DCMAKE_OSX_ARCHITECTURES=${ESCAPED_CMAKE_OSX_ARCHITECTURES} + ) + endif() + + + if (ANDROID) + set(yaml-cpp_CMAKE_ARGS + ${yaml-cpp_CMAKE_ARGS} + -DANDROID_PLATFORM=${ANDROID_PLATFORM} + -DANDROID_ABI=${ANDROID_ABI} + -DANDROID_STL=${ANDROID_STL}) + 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 + BUILD_COMMAND "" + INSTALL_COMMAND + ${CMAKE_COMMAND} --build . + --config ${CMAKE_BUILD_TYPE} + --target install + --parallel + ) + + 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/utils/CheckSupportGL.cmake b/share/cmake/utils/CheckSupportGL.cmake index 0f2678da11..d603587c88 100644 --- a/share/cmake/utils/CheckSupportGL.cmake +++ b/share/cmake/utils/CheckSupportGL.cmake @@ -7,28 +7,30 @@ include(PackageUtils) include(SelectLibraryConfigurations) +include(Colors) +include(ocio_find_package) if((OCIO_BUILD_TESTS AND 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 COMPONENTS OpenGL) + ocio_find_package(OpenGL COMPONENTS OpenGL) if(NOT OpenGL_OpenGL_FOUND AND NOT OPENGL_GLU_FOUND) package_root_message(OpenGL) set(OCIO_GL_ENABLED OFF) endif() if(NOT APPLE) - # On some Linux platform, the glew-config.cmake is found first so make it explicit - # to fall back on the regular search if not found. - find_package(GLEW CONFIG QUIET) + # On some Linux platform, the glew-config.cmake is found first. + # PREFER_CONFIG assure that config mode will be used first and fallback to module mode. + ocio_find_package( GLEW PREFER_CONFIG + MIN_VERSION 2.1.0 + RECOMMENDED_MIN_VERSION 2.1.0 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") if(NOT GLEW_FOUND) - find_package(GLEW) - if(NOT GLEW_FOUND) - package_root_message(GLEW) - set(OCIO_GL_ENABLED OFF) - endif() + package_root_message(GLEW) + set(OCIO_GL_ENABLED OFF) else() # Expected variables GLEW_LIBRARIES and GLEW_INCLUDE_DIRS are missing so create # the mandatory one. @@ -67,7 +69,10 @@ if((OCIO_BUILD_TESTS AND OCIO_BUILD_GPU_TESTS) OR OCIO_BUILD_APPS) endif() endif() - find_package(GLUT) + ocio_find_package( GLUT + MIN_VERSION 3.2.1 + RECOMMENDED_MIN_VERSION 3.2.1 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") if(NOT GLUT_FOUND) package_root_message(GLUT) set(OCIO_GL_ENABLED OFF) @@ -90,7 +95,7 @@ if((OCIO_BUILD_TESTS AND OCIO_BUILD_GPU_TESTS) OR OCIO_BUILD_APPS) message(STATUS "Can't find EGL without GLVND support; can't render headlessly") set(OCIO_USE_HEADLESS OFF) else() - find_package(OpenGL COMPONENTS EGL) + ocio_find_package(OpenGL COMPONENTS EGL) if(NOT OpenGL_EGL_FOUND) message(WARNING "EGL component missing; can't render headlessly") set(OCIO_USE_HEADLESS OFF) diff --git a/share/cmake/utils/Colors.cmake b/share/cmake/utils/Colors.cmake new file mode 100644 index 0000000000..888ac6e5b9 --- /dev/null +++ b/share/cmake/utils/Colors.cmake @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +string (ASCII 27 ColorEsc) + +set(ColorReset "${ColorEsc}[m") + +# Error +set(ColorError "${ColorEsc}[31m") +# Green +set(ColorSuccess "${ColorEsc}[32m") +# Yellow +set(ColorWarning "${ColorEsc}[33m") +set(ColorInfo "${ColorEsc}[34m") + +set(ColorBoldWhite "${ColorEsc}[1;37m") \ No newline at end of file diff --git a/share/cmake/utils/CompilerFlags.cmake b/share/cmake/utils/CompilerFlags.cmake index 9e56d55ae8..57e74a2b42 100644 --- a/share/cmake/utils/CompilerFlags.cmake +++ b/share/cmake/utils/CompilerFlags.cmake @@ -86,6 +86,8 @@ set_unless_defined(CMAKE_VISIBILITY_INLINES_HIDDEN YES) ############################################################################### # Define if SSE2 can be used. +message(STATUS "") +message(STATUS "Checking for SSE2 support...") include(CheckSupportSSE2) if(NOT HAVE_SSE2) diff --git a/src/cmake/Config.cmake.in b/src/cmake/Config.cmake.in index 6a4932a836..7910959c3f 100644 --- a/src/cmake/Config.cmake.in +++ b/src/cmake/Config.cmake.in @@ -62,6 +62,7 @@ if (NOT @BUILD_SHARED_LIBS@) # NOT @BUILD_SHARED_LIBS@ endif() else() # For CMake < 3.24 since ZLIB_USE_STATIC_LIBS is not available. if(NOT ZLIB_LIBRARY) + set(_cmake_find_library_x_changed true) if(DEFINED CMAKE_FIND_LIBRARY_PREFIXES) set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") else() @@ -91,23 +92,26 @@ if (NOT @BUILD_SHARED_LIBS@) # NOT @BUILD_SHARED_LIBS@ endif() endif() + if (@ZLIB_VERSION@) # @ZLIB_VERSION@ find_dependency(ZLIB @ZLIB_VERSION@) else() find_dependency(ZLIB @ZLIB_VERSION_STRING@) endif() - # Restore the original find library ordering - if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) - set(CMAKE_FIND_LIBRARY_SUFFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}") - else() - set(CMAKE_FIND_LIBRARY_SUFFIXES) - endif() + if(_cmake_find_library_x_changed) + # Restore the original find library ordering + if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) + set(CMAKE_FIND_LIBRARY_SUFFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}") + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES) + endif() - if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES) - set(CMAKE_FIND_LIBRARY_PREFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES}") - else() - set(CMAKE_FIND_LIBRARY_PREFIXES) + if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES) + set(CMAKE_FIND_LIBRARY_PREFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES}") + else() + set(CMAKE_FIND_LIBRARY_PREFIXES) + endif() endif() endif() From 56a671adef449fdf8526eadf910fa16fc8a2a442 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Wed, 25 Jan 2023 12:06:22 -0500 Subject: [PATCH 02/18] Removing a duplicate call to set_property in OpenImageIO find module. Setting policy CMP0042 when building ZLIB since that project is using an old CMake version as the cmake_minimum_required and that version has no knowledge of the policy. Fixing a potential issue in Installopenfx. Changing back the version to 1.4 as before. Ignoring warning from OpenImageIO for imageioapphelpers. The same warning are ignored for ociodisplay, ocioconvert and ociolutimage. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- share/cmake/macros/VersionUtils.cmake | 17 ++++++++++++++--- share/cmake/modules/FindExtPackages.cmake | 4 ++-- share/cmake/modules/FindOpenImageIO.cmake | 3 --- share/cmake/modules/install/InstallZLIB.cmake | 4 ++++ share/cmake/modules/install/Installopenfx.cmake | 8 ++++---- src/libutils/imageioapphelpers/CMakeLists.txt | 7 +++++++ 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/share/cmake/macros/VersionUtils.cmake b/share/cmake/macros/VersionUtils.cmake index 9349c5da56..0283774e4c 100644 --- a/share/cmake/macros/VersionUtils.cmake +++ b/share/cmake/macros/VersionUtils.cmake @@ -6,8 +6,19 @@ macro(split_version_string version_var output_prefix) string(REPLACE "." ";" _version_var_list ${version_var}) - list(GET _version_var_list 0 ${output_prefix}_VERSION_MAJOR) - list(GET _version_var_list 1 ${output_prefix}_VERSION_MINOR) - list(GET _version_var_list 2 ${output_prefix}_VERSION_PATCH) + list(LENGTH _version_var_list _version_var_list_length) + + if (_version_var_list_length GREATER_EQUAL 1) + list(GET _version_var_list 0 ${output_prefix}_VERSION_MAJOR) + endif() + + if (_version_var_list_length GREATER_EQUAL 2) + list(GET _version_var_list 1 ${output_prefix}_VERSION_MINOR) + endif() + + if (_version_var_list_length GREATER_EQUAL 3) + list(GET _version_var_list 2 ${output_prefix}_VERSION_PATCH) + endif() + unset(_version_var_list) endmacro() diff --git a/share/cmake/modules/FindExtPackages.cmake b/share/cmake/modules/FindExtPackages.cmake index 415e553065..78ead266c1 100644 --- a/share/cmake/modules/FindExtPackages.cmake +++ b/share/cmake/modules/FindExtPackages.cmake @@ -202,8 +202,8 @@ if(OCIO_BUILD_OPENFX) # openfx # https://github.com/ofxa/openfx ocio_find_package( openfx REQUIRED ALLOW_INSTALL - MIN_VERSION 1.4.0 - RECOMMENDED_MIN_VERSION 1.4.0 + MIN_VERSION 1.4 + RECOMMENDED_MIN_VERSION 1.4 RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") endif() diff --git a/share/cmake/modules/FindOpenImageIO.cmake b/share/cmake/modules/FindOpenImageIO.cmake index 828da451fa..087a00604e 100644 --- a/share/cmake/modules/FindOpenImageIO.cmake +++ b/share/cmake/modules/FindOpenImageIO.cmake @@ -165,9 +165,6 @@ if (OpenImageIO_FOUND AND NOT TARGET OpenImageIO::OpenImageIO) IMPORTED_LOCATION "${OpenImageIO_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${OpenImageIO_INCLUDE_DIR}") - set_property(TARGET OpenImageIO::OpenImageIO APPEND PROPERTY - IMPORTED_LOCATION "${OpenImageIO_LIBRARY}") - # Starting with OIIO v2.3, some utility classes are now only declared in OpenImageIO_Util # (and not in both libraries like in older versions). if (${OpenImageIO_VERSION} VERSION_GREATER_EQUAL "2.3" AND NOT TARGET OpenImageIO::OpenImageIO_Util) diff --git a/share/cmake/modules/install/InstallZLIB.cmake b/share/cmake/modules/install/InstallZLIB.cmake index 3859149c29..e9aaffa5a7 100644 --- a/share/cmake/modules/install/InstallZLIB.cmake +++ b/share/cmake/modules/install/InstallZLIB.cmake @@ -70,6 +70,10 @@ if(NOT ZLIB_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGE if(_ZLIB_TARGET_CREATE) set(ZLIB_CMAKE_ARGS ${ZLIB_CMAKE_ARGS} + # Setting policy CMP0042 when building ZLIB since that project is using an old CMake + # version as the cmake_minimum_required and that version has no knowledge of the policy. + # Since that policy gets unset, it causes a warning with CMake 3.25+. + -DCMAKE_POLICY_DEFAULT_CMP0042=NEW -DCMAKE_CXX_VISIBILITY_PRESET=${CMAKE_CXX_VISIBILITY_PRESET} -DCMAKE_VISIBILITY_INLINES_HIDDEN=${CMAKE_VISIBILITY_INLINES_HIDDEN} -DCMAKE_POSITION_INDEPENDENT_CODE=ON diff --git a/share/cmake/modules/install/Installopenfx.cmake b/share/cmake/modules/install/Installopenfx.cmake index 5966a81978..0596bed2bf 100644 --- a/share/cmake/modules/install/Installopenfx.cmake +++ b/share/cmake/modules/install/Installopenfx.cmake @@ -33,13 +33,13 @@ if(NOT openfx_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKA # Hack to let imported target be built from ExternalProject_Add file(MAKE_DIRECTORY ${openfx_INCLUDE_DIR}) - string(REPLACE "." ";" VERSION_LIST ${openfx_VERSION}) - list(GET VERSION_LIST 0 openfx_VERSION_MAJOR) - list(GET VERSION_LIST 1 openfx_VERSION_MINOR) - list(GET VERSION_LIST 2 openfx_VERSION_PATCH) + include(VersionUtils) + split_version_string(${openfx_VERSION} openfx) ExternalProject_Add(openfx_install GIT_REPOSITORY "https://github.com/ofxa/openfx.git" + # The latest version from 2015 is OFX_Release_1_4_TAG. + # Need to be careful since older version might have the patch number in the tag. GIT_TAG "OFX_Release_${openfx_VERSION_MAJOR}_${openfx_VERSION_MINOR}_TAG" GIT_CONFIG advice.detachedHead=false GIT_SHALLOW TRUE diff --git a/src/libutils/imageioapphelpers/CMakeLists.txt b/src/libutils/imageioapphelpers/CMakeLists.txt index 3f2bcb1f86..eb47c9528e 100644 --- a/src/libutils/imageioapphelpers/CMakeLists.txt +++ b/src/libutils/imageioapphelpers/CMakeLists.txt @@ -9,6 +9,13 @@ add_library(imageioapphelpers STATIC ${SOURCES}) set_target_properties(imageioapphelpers PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(imageioapphelpers PROPERTIES OUTPUT_NAME OpenColorIOimageioapphelpers) +if (USE_MSVC AND OCIO_IMAGE_BACKEND STREQUAL "OpenImageIO") + # Temporary until fixed in OpenImageIO: Mute some warnings from OpenImageIO farmhash.h + # C4267 (level 3) 'var' : conversion from 'size_t' to 'type', possible loss of data + # C4244 (level 3 & 4) 'conversion' conversion from 'type1' to 'type2', possible loss of data + target_compile_options(imageioapphelpers PRIVATE /wd4267 /wd4244) +endif() + if(NOT BUILD_SHARED_LIBS) target_compile_definitions(imageioapphelpers PUBLIC From 0a86c31118a4a0ce8ef06e8a7a8ab322bfc92c95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Thu, 26 Jan 2023 12:21:30 -0500 Subject: [PATCH 03/18] Fixed an issue with FindOpenImageIO that was found while testing on macOS. Renamed FindOpenShadingLanguage to FindOSL to match the project name used the OSL's CMakefile. Cleanup the code for FindOSL and removed duplicate warning about needed C++14. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the header comments for all Find and Install modules. Signed-off-by: Cédrik Fuoco --- share/cmake/modules/FindExtPackages.cmake | 6 +- share/cmake/modules/FindImath.cmake | 30 ++--- ...penShadingLanguage.cmake => FindOSL.cmake} | 104 ++++++++---------- share/cmake/modules/FindOpenEXR.cmake | 25 ++--- share/cmake/modules/FindOpenImageIO.cmake | 30 +++-- share/cmake/modules/FindSphinx.cmake | 13 ++- share/cmake/modules/Findexpat.cmake | 30 ++--- share/cmake/modules/Findlcms2.cmake | 20 ++-- share/cmake/modules/Findminizip-ng.cmake | 19 +++- share/cmake/modules/Findopenfx.cmake | 24 ++-- share/cmake/modules/Findpybind11.cmake | 18 +-- share/cmake/modules/Findpystring.cmake | 23 ++-- share/cmake/modules/Findyaml-cpp.cmake | 30 ++--- .../cmake/modules/install/InstallImath.cmake | 14 ++- .../modules/install/InstallOpenEXR.cmake | 23 ++-- share/cmake/modules/install/InstallZLIB.cmake | 16 ++- .../cmake/modules/install/Installexpat.cmake | 14 ++- .../cmake/modules/install/Installlcms2.cmake | 13 +++ .../modules/install/Installminizip-ng.cmake | 16 +++ .../cmake/modules/install/Installopenfx.cmake | 12 ++ .../modules/install/Installpybind11.cmake | 14 ++- .../modules/install/Installpystring.cmake | 13 +++ .../modules/install/Installyaml-cpp.cmake | 14 ++- 23 files changed, 315 insertions(+), 206 deletions(-) rename share/cmake/modules/{FindOpenShadingLanguage.cmake => FindOSL.cmake} (63%) diff --git a/share/cmake/modules/FindExtPackages.cmake b/share/cmake/modules/FindExtPackages.cmake index 78ead266c1..88fabb06c1 100644 --- a/share/cmake/modules/FindExtPackages.cmake +++ b/share/cmake/modules/FindExtPackages.cmake @@ -40,7 +40,7 @@ message(STATUS "") message(STATUS "Missing a dependency? Try the following possibilities:") message(STATUS "If the package provides a configuration file, use -D_DIR=.") message(STATUS "If it doesn't provide it, try -D_ROOT=.") -message(STATUS "Alternatively, try -D_LIBRARY= and -D_INCLUDE_DIR=.") +message(STATUS "Alternatively, try -D_LIBRARY= and/or -D_INCLUDE_DIR=.") message(STATUS "") message(STATUS "Please refer to the find module under share/cmake/modules for extra information.") @@ -294,12 +294,12 @@ if(OCIO_BUILD_TESTS) if(TARGET Imath::Imath) # OpenShadingLanguage # https://github.com/AcademySoftwareFoundation/OpenShadingLanguage - ocio_find_package( OpenShadingLanguage + ocio_find_package( OSL MIN_VERSION 1.11 RECOMMENDED_MIN_VERSION 1.11 RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") if(NOT OSL_FOUND) - message(WARNING "Skipping build of the OpenShadingLanguage unit tests (OpenShadingLanguage missing)") + message(WARNING "Skipping build of the OpenShadingLanguage unit tests (OSL missing)") endif() else() message(WARNING "Skipping build of the OpenShadingLanguage unit tests (Imath missing)") diff --git a/share/cmake/modules/FindImath.cmake b/share/cmake/modules/FindImath.cmake index cf99bfe0d9..a0f45330be 100644 --- a/share/cmake/modules/FindImath.cmake +++ b/share/cmake/modules/FindImath.cmake @@ -1,25 +1,27 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. # -# Locate or install Imath +# Locate Imath # # Variables defined by this module: -# Imath_FOUND - If FALSE, do not try to link to ilmbase -# Imath_LIBRARY - Imath library to link to -# Imath_INCLUDE_DIR - Where to find ImathConfig.h -# Imath_VERSION - The version of the library +# Imath_FOUND - Indicate whether the library was found or not +# Imath_LIBRARY - Path to the library file +# Imath_INCLUDE_DIR - Location of the header files +# Imath_VERSION - Library's version # -# Targets defined by this module: -# Imath::Imath - IMPORTED target, if found +# Global targets defined by this module: +# Imath::Imath # -# By default, the dynamic libraries of Imath will be found. To find the -# static ones instead, you must set the Imath_STATIC_LIBRARY variable to -# TRUE before calling find_package(Imath ...). +# The dynamic libraries will be located by default. +# By setting Imath_STATIC_LIBRARY variable to TRUE, the search for static libraries will +# be initiated, however it's not a guarentee that they will be located. # -# If Imath is not installed in a standard path, you can use the -# Imath_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, Imath will be -# downloaded, built, and statically-linked into libOpenColorIO at build time. +# If the library is not installed in a standard path, you can do the following the help +# the find module: +# +# If the package provides a configuration file, use -DImath_DIR=. +# If it doesn't provide it, try -DImath_ROOT=. +# Alternatively, try -DImath_LIBRARY= and -DImath_INCLUDE_DIR=. # ############################################################################### diff --git a/share/cmake/modules/FindOpenShadingLanguage.cmake b/share/cmake/modules/FindOSL.cmake similarity index 63% rename from share/cmake/modules/FindOpenShadingLanguage.cmake rename to share/cmake/modules/FindOSL.cmake index 5a07572f4a..185d6df6d6 100644 --- a/share/cmake/modules/FindOpenShadingLanguage.cmake +++ b/share/cmake/modules/FindOSL.cmake @@ -1,51 +1,55 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. # -# Locate or install OpenShadingLanguage (OSL) +# Locate OpenShadingLanguage (OSL) # -# If the library is not installed in a standard path, you can use the OSL_ROOT -# variable to tell CMake where to find it. +# Variables defined by this module: +# OSL_FOUND - Indicate whether the library was found or not +# OSL_LIB_DIR - Location of the libary files +# OSL_INCLUDE_DIR - Location of the header files +# OSL_VERSION - Library's version +# OSL_SHADERS_INCLUDE_DIR - Location of the shader's header files +# OSL_SHADERS_DIR - Used for OSL unit tests +# +# These variables are set only when OSL_ROOT is provided: +# oslcomp_LIBRARY - Path to the library file +# oslexec_LIBRARY - Path to the library file +# +# Global targets defined by this module: +# osl::osl +# +# The dynamic libraries will be located by default. +# +# If the library is not installed in a standard path, you can do the following the help +# the find module: +# +# If the package provides a configuration file, use -DOpenShadingLanguage_DIR=. +# If it doesn't provide it, try -DOpenShadingLanguage_ROOT=. # - - -if(NOT TARGET osl::osl) - add_library(osl::osl INTERFACE IMPORTED GLOBAL) - set(OSL_FOUND OFF) -endif() ############################################################################### ### Try to find package ### if(NOT DEFINED OSL_ROOT) - - find_package(OSL ${OpenShadingLanguage_FIND_VERSION} CONFIG QUIET) - - set(OpenShadingLanguage_VERSION ${OSL_VERSION}) - - # TODO: No variable to have the share directory? + find_package(OSL ${OSL_FIND_VERSION} CONFIG QUIET) set(OSL_SHADERS_INCLUDE_DIR ${OSL_INCLUDE_DIR}/../share) - # Variable used by the OSL unit tests. set(OSL_SHADERS_DIR ${OSL_SHADERS_INCLUDE_DIR}/OSL/shaders) include (FindPackageHandleStandardArgs) - find_package_handle_standard_args (OpenShadingLanguage - FOUND_VAR OpenShadingLanguage_FOUND - REQUIRED_VARS OSL_INCLUDE_DIR OSL_LIB_DIR OpenShadingLanguage_VERSION - VERSION_VAR OpenShadingLanguage_VERSION + find_package_handle_standard_args (OSL + REQUIRED_VARS + OSL_INCLUDE_DIR + OSL_LIB_DIR + VERSION_VAR + OSL_VERSION ) - - set(OSL_FOUND ${OpenShadingLanguage_FOUND}) - else() - set(OSL_INCLUDE_DIR ${OSL_ROOT}/include) - set(OSL_VERSION_HEADER "${OSL_INCLUDE_DIR}/OSL/oslversion.h") if(EXISTS "${OSL_VERSION_HEADER}") - # Try to figure out version number file (STRINGS "${OSL_VERSION_HEADER}" TMP REGEX "^#define OSL_LIBRARY_VERSION_MAJOR .*$") string (REGEX MATCHALL "[0-9]+" OSL_VERSION_MAJOR ${TMP}) @@ -54,12 +58,14 @@ else() file (STRINGS "${OSL_VERSION_HEADER}" TMP REGEX "^#define OSL_LIBRARY_VERSION_PATCH .*$") string (REGEX MATCHALL "[0-9]+" OSL_VERSION_PATCH ${TMP}) file (STRINGS "${OSL_VERSION_HEADER}" TMP REGEX "^#define OSL_LIBRARY_VERSION_TWEAK .*$") + if (TMP) string (REGEX MATCHALL "[0-9]+" OSL_VERSION_TWEAK ${TMP}) else () set (OSL_VERSION_TWEAK 0) endif () - set (OpenShadingLanguage_VERSION "${OSL_VERSION_MAJOR}.${OSL_VERSION_MINOR}.${OSL_VERSION_PATCH}.${OSL_VERSION_TWEAK}") + + set (OSL_VERSION "${OSL_VERSION_MAJOR}.${OSL_VERSION_MINOR}.${OSL_VERSION_PATCH}.${OSL_VERSION_TWEAK}") # Find the oslcomp library. find_library(oslcomp_LIBRARY @@ -92,58 +98,41 @@ else() ) set(OSL_SHADERS_INCLUDE_DIR ${OSL_ROOT}/share) - # Variable used by the OSL unit tests. set(OSL_SHADERS_DIR ${OSL_SHADERS_INCLUDE_DIR}/OSL/shaders) - - if(EXISTS "${OSL_SHADERS_DIR}") - - # Variable used by the OSL unit tests. - set(OSL_FOUND ON) - - endif() - endif() include (FindPackageHandleStandardArgs) - find_package_handle_standard_args (OpenShadingLanguage - FOUND_VAR OpenShadingLanguage_FOUND - REQUIRED_VARS OSL_INCLUDE_DIR oslcomp_LIBRARY oslexec_LIBRARY OpenShadingLanguage_VERSION - VERSION_VAR OpenShadingLanguage_VERSION + find_package_handle_standard_args (OSL + REQUIRED_VARS + OSL_INCLUDE_DIR + OSL_SHADERS_DIR + oslcomp_LIBRARY + oslexec_LIBRARY + VERSION_VAR + OSL_VERSION ) - - set(OSL_FOUND ${OpenShadingLanguage_FOUND}) - endif() ############################################################################### -### Check the C++ version ### +### Create target -# TODO: Which version starts to impose C++14? - -if(${CMAKE_CXX_STANDARD} LESS_EQUAL 11) - set(OSL_FOUND OFF) - message(WARNING "Need C++14 or higher to compile OpenShadingLanguage. Skipping build of the OSL unit tests") +if(NOT TARGET osl::osl) + add_library(osl::osl INTERFACE IMPORTED GLOBAL) endif() ############################################################################### ### Configure target ### if(OSL_FOUND) - - if (NOT OSL_FIND_QUIETLY) - message(STATUS "OpenShadingLanguage includes = ${OSL_INCLUDE_DIR}") - message(STATUS "OpenShadingLanguage shaders = ${OSL_SHADERS_DIR}") - message(STATUS "OpenShadingLanguage library dir = ${OSL_LIB_DIR}") - endif () - list(APPEND LIB_INCLUDE_DIRS ${OSL_INCLUDE_DIR}) list(APPEND LIB_INCLUDE_DIRS ${OSL_SHADERS_INCLUDE_DIR}) target_include_directories(osl::osl INTERFACE "${LIB_INCLUDE_DIRS}") target_link_libraries(osl::osl INTERFACE OSL::oslcomp OSL::oslexec) - if (${OpenShadingLanguage_VERSION} VERSION_GREATER_EQUAL "1.12" AND ${CMAKE_CXX_STANDARD} LESS_EQUAL 11) + # C++14 is required for OSL 1.12+ + if (${OSL_VERSION} VERSION_GREATER_EQUAL "1.12" AND ${CMAKE_CXX_STANDARD} LESS_EQUAL 11) set(OSL_FOUND OFF) message(WARNING "Need C++14 or higher to compile OpenShadingLanguage. Skipping build the OSL unit tests") endif() @@ -152,5 +141,4 @@ if(OSL_FOUND) oslcomp_LIBRARY oslcomp_FOUND oslexec_LIBRARY oslexec_FOUND ) - endif() diff --git a/share/cmake/modules/FindOpenEXR.cmake b/share/cmake/modules/FindOpenEXR.cmake index 1aabf0f2b9..eaddf81d2a 100644 --- a/share/cmake/modules/FindOpenEXR.cmake +++ b/share/cmake/modules/FindOpenEXR.cmake @@ -1,13 +1,13 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. # -# Locate or install OpenEXR. +# Locate OpenEXR. # # Variables defined by this module: -# OpenEXR_FOUND - If FALSE, do not try to link to OpenEXR -# OpenEXR_LIBRARY - OpenEXR library to link to -# OpenEXR_INCLUDE_DIR - Where to find OpenEXR headers -# OpenEXR_VERSION - The version of the library +# OpenEXR_FOUND - Indicate whether the library was found or not +# OpenEXR_LIBRARY - Path to the library file +# OpenEXR_INCLUDE_DIR - Location of the header files +# OpenEXR_VERSION - Library's version # # Imported targets defined by this module, if found: # OpenEXR::Iex @@ -19,15 +19,14 @@ # OpenEXR::OpenEXRCore # OpenEXR::OpenEXRUtil # -# By default, the dynamic libraries of OpenEXR will be found. To find the -# static ones instead, you must set the OpenEXR_STATIC_LIBRARY variable to -# TRUE before calling find_package(OpenEXR ...). +# By default, the dynamic libraries will be found. # -# If OpenEXR is not installed in a standard path, you can use the -# OpenEXR_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, OpenEXR will be -# downloaded, statically-built, and used to generate -# libOpenColorIOimageioapphelpers. +# If the library is not installed in a standard path, you can do the following the help +# the find module: +# +# If the package provides a configuration file, use -DOpenEXR_DIR=. +# If it doesn't provide it, try -DOpenEXR_ROOT=. +# Alternatively, try -DOpenEXR_LIBRARY= and -DOpenEXR_INCLUDE_DIR=. # ############################################################################### diff --git a/share/cmake/modules/FindOpenImageIO.cmake b/share/cmake/modules/FindOpenImageIO.cmake index 087a00604e..82e8ed5515 100644 --- a/share/cmake/modules/FindOpenImageIO.cmake +++ b/share/cmake/modules/FindOpenImageIO.cmake @@ -4,16 +4,25 @@ # Locate OpenImageIO # # Variables defined by this module: -# OpenImageIO_FOUND - If FALSE, do not try to link to OpenImageIO -# OpenImageIO_LIBRARY - OpenImageIO library to link to -# OpenImageIO_LIB_DIR - Libray directory -# OpenImageIO_INCLUDE_DIR - Where to find OpenImageIO.h -# OpenImageIO_VERSION - The version of the library +# OpenImageIO_FOUND - Indicate whether the library was found or not +# OpenImageIO_LIBRARY - Path to the library file +# OpenImageIO_LIB_DIR - Library's directory +# OpenImageIO_INCLUDE_DIR - Location of the header files +# OpenImageIO_VERSION - Library's version # -# Targets defined by this module: +# Global targets defined by this module: # OpenImageIO::OpenImageIO - The libOpenImageIO library # OpenImageIO::OpenImageIO_Util - Utility classes (v2.3+) # +# The dynamic libraries will be located by default. +# +# If the library is not installed in a standard path, you can do the following the help +# the find module: +# +# If the package provides a configuration file, use -DOpenImageIO_DIR=. +# If it doesn't provide it, try -DOpenImageIO_ROOT=. +# Alternatively, try -DOpenImageIO_LIBRARY= and -DOpenImageIO_INCLUDE_DIR=. +# if(NOT DEFINED OpenImageIO_ROOT) # Search for OpenImageIOConfig.cmake @@ -60,16 +69,13 @@ else() pkg_check_modules(PC_OpenImageIO QUIET "OpenImageIO>=${OpenImageIO_FIND_VERSION}") # Find include directory - # Since CMake 3.12, find_path search through _ROOT before everything else. + # Since CMake 3.12, find_path search through OpenImageIO_ROOT before everything else. find_path(OpenImageIO_INCLUDE_DIR NAMES - oiioversion.h + OpenImageIO/oiioversion.h HINTS ${PC_OpenImageIO_INCLUDE_DIRS} PATH_SUFFIXES - include/OpenImageIO - OpenImageIO - include OpenImageIO/include ) @@ -77,7 +83,7 @@ else() set(OpenImageIO_INCLUDES ${OpenImageIO_INCLUDE_DIR}) # Find library - # Since CMake 3.12, find_library search through _ROOT before everything else. + # Since CMake 3.12, find_library search through OpenImageIO_ROOT before everything else. find_library (OpenImageIO_LIBRARY NAMES OpenImageIO diff --git a/share/cmake/modules/FindSphinx.cmake b/share/cmake/modules/FindSphinx.cmake index adf1080988..768874eec4 100644 --- a/share/cmake/modules/FindSphinx.cmake +++ b/share/cmake/modules/FindSphinx.cmake @@ -4,14 +4,15 @@ # Locate Sphinx (Python documentation generator) # # Variables defined by this module: -# Sphinx_FOUND -# Sphinx_EXECUTABLE (CACHE) +# Sphinx_FOUND - Indicate whether the library was found or not +# Sphinx_EXECUTABLE - Path to the executable file # -# Usage: -# find_package(Sphinx) # -# If Sphinx is not installed in a standard path, add it to the Sphinx_ROOT -# variable to tell CMake where to find it. +# If the executable is not installed in a standard path, you can do the following the help +# the find module: +# +# Try -DSphinx_ROOT=. +# Alternatively, try -DSphinx_EXECUTABLE=. # find_package(Python QUIET COMPONENTS Interpreter) diff --git a/share/cmake/modules/Findexpat.cmake b/share/cmake/modules/Findexpat.cmake index ff26a3d071..7949d8efa1 100644 --- a/share/cmake/modules/Findexpat.cmake +++ b/share/cmake/modules/Findexpat.cmake @@ -1,25 +1,27 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. # -# Locate or install expat +# Locate 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 +# expat_FOUND - Indicate whether the library was found or not +# expat_LIBRARY - Path to the library file +# expat_INCLUDE_DIR - Location of the header files +# expat_VERSION - Library's version # -# Targets defined by this module: -# expat::expat - IMPORTED target, if found +# Global targets defined by this module: +# expat::expat # -# 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 ...). +# The dynamic libraries will be located by default. +# By setting expat_STATIC_LIBRARY variable to TRUE, the search for static libraries will +# be initiated, however it's not a guarentee that they will be located. # -# 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. +# If the library is not installed in a standard path, you can do the following the help +# the find module: +# +# If the package provides a configuration file, use -Dexpat_DIR=. +# If it doesn't provide it, try -Dexpat_ROOT=. +# Alternatively, try -Dexpat_LIBRARY= and -Dexpat_INCLUDE_DIR=. # ############################################################################### diff --git a/share/cmake/modules/Findlcms2.cmake b/share/cmake/modules/Findlcms2.cmake index e2387c468a..1bb8cebd8b 100644 --- a/share/cmake/modules/Findlcms2.cmake +++ b/share/cmake/modules/Findlcms2.cmake @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. # -# Locate or install lcms2 +# Locate lcms2 # # Variables defined by this module: # lcms2_FOUND - If FALSE, do not try to link to lcms @@ -9,17 +9,19 @@ # lcms2_INCLUDE_DIR - Where to find lcms2.h # lcms2_VERSION - The version of the library # -# Targets defined by this module: +# Global 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 ...). +# The dynamic libraries will be located by default. +# By setting lcms2_STATIC_LIBRARY variable to TRUE, the search for static libraries will +# be initiated, however it's not a guarentee that they will be located. # -# 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 -# downloaded, built, and statically-linked into libOpenColorIO at build time. +# If the library is not installed in a standard path, you can do the following the help +# the find module: +# +# If the package provides a configuration file, use -Dlcms2_DIR=. +# If it doesn't provide it, try -Dlcms2_ROOT=. +# Alternatively, try -Dlcms2_LIBRARY= and -Dlcms2_INCLUDE_DIR=. # ############################################################################### diff --git a/share/cmake/modules/Findminizip-ng.cmake b/share/cmake/modules/Findminizip-ng.cmake index 12a14ce9c4..23ed19e911 100644 --- a/share/cmake/modules/Findminizip-ng.cmake +++ b/share/cmake/modules/Findminizip-ng.cmake @@ -1,7 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. # -# Locate or install minizip-ng +# Locate minizip-ng # # Variables defined by this module: # minizip-ng_FOUND - If FALSE, do not try to link to minizip-ng @@ -9,13 +9,19 @@ # minizip-ng_INCLUDE_DIR - Where to find mz.h and other headers # minizip-ng_VERSION - The version of the library # -# Targets defined by this module: +# Global targets defined by this module: # MINIZIP::minizip-ng - IMPORTED target, if found # -# If minizip-ng is not installed in a standard path, you can use the minizip-ng_ROOT -# variable to tell CMake where to find it. If it is not found and -# OCIO_INSTALL_EXT_PACKAGES is set to MISSING or ALL, minizip-ng will be downloaded, -# built, and statically-linked into libOpenColorIO at build time. +# The dynamic libraries will be located by default. +# By setting minizip-ng_STATIC_LIBRARY variable to TRUE, the search for static libraries will +# be initiated, however it's not a guarentee that they will be located. +# +# If the library is not installed in a standard path, you can do the following the help +# the find module: +# +# If the package provides a configuration file, use -Dminizip-ng_DIR=. +# If it doesn't provide it, try -Dminizip-ng_ROOT=. +# Alternatively, try -Dminizip-ng_LIBRARY= and -Dminizip-ng_INCLUDE_DIR=. # # For external builds of minizip-ng, please note that the same build options should be used. # Using more options, such as enabling other compression methods, will provoke linking issue @@ -23,6 +29,7 @@ # # e.g. Setting MZ_BZIP2=ON will cause linking issue since OCIO will not be linked against BZIP2. # + ############################################################################### ### Try to find package ### diff --git a/share/cmake/modules/Findopenfx.cmake b/share/cmake/modules/Findopenfx.cmake index c639e72631..73c7d3a77d 100644 --- a/share/cmake/modules/Findopenfx.cmake +++ b/share/cmake/modules/Findopenfx.cmake @@ -1,20 +1,24 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. # -# Locate or install openfx +# Locate openfx # # Variables defined by this module: -# openfx_FOUND - If FALSE, do not try to include openfx -# openfx_INCLUDE_DIR - Where to find ofxCore.h -# openfx_VERSION - The version of the library +# openfx_FOUND - Indicate whether the library was found or not +# openfx_INCLUDE_DIR - Location of the header files +# openfx_VERSION - Library's version # -# Targets defined by this module: -# openfx::module - IMPORTED target, if found +# Global targets defined by this module: +# openfx::module # -# If openfx is not installed in a standard path, you can use the -# openfx_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, openfx will be -# downloaded at build time. +# The dynamic libraries will be located by default. +# +# If the library is not installed in a standard path, you can do the following the help +# the find module: +# +# If the package provides a configuration file, use -Dopenfx_DIR=. +# If it doesn't provide it, try -Dopenfx_ROOT=. +# Alternatively, try -Dopenfx_LIBRARY= and -Dopenfx_INCLUDE_DIR=. # ############################################################################### diff --git a/share/cmake/modules/Findpybind11.cmake b/share/cmake/modules/Findpybind11.cmake index 0ed436bf49..c9f0e331ed 100644 --- a/share/cmake/modules/Findpybind11.cmake +++ b/share/cmake/modules/Findpybind11.cmake @@ -1,20 +1,24 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. # -# Locate or install pybind11 +# Locate pybind11 # # Variables defined by this module: # pybind11_FOUND - If FALSE, do not try to link to pybind11 # pybind11_INCLUDE_DIR - Where to find pybind11.h # pybind11_VERSION - The version of the library # -# Targets defined by this module: -# pybind11::module - IMPORTED target, if found +# Global targets defined by this module: +# pybind11::module # -# If pybind11 is not installed in a standard path, you can use the -# 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. +# The dynamic libraries will be located by default. +# +# If the library is not installed in a standard path, you can do the following the help +# the find module: +# +# If the package provides a configuration file, use -Dpybind11_DIR=. +# If it doesn't provide it, try -Dpybind11_ROOT=. +# Alternatively, try -Dpybind11_INCLUDE_DIR=. # ############################################################################### diff --git a/share/cmake/modules/Findpystring.cmake b/share/cmake/modules/Findpystring.cmake index a83ed4a753..e749290bdb 100644 --- a/share/cmake/modules/Findpystring.cmake +++ b/share/cmake/modules/Findpystring.cmake @@ -1,20 +1,25 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. # -# Locate or install pystring +# Locate 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 - Indicate whether the library was found or not +# pystring_LIBRARY - Path to the library file +# pystring_INCLUDE_DIR - Location of the header files +# pystring_VERSION - Library's version # -# Targets defined by this module: +# Global targets defined by this module: # pystring::pystring - IMPORTED target, if found # -# If pystring is not installed in a standard path, you can use the -# 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. +# The dynamic libraries will be located by default. +# +# If the library is not installed in a standard path, you can do the following the help +# the find module: +# +# If the package provides a configuration file, use -Dpystring_DIR=. +# If it doesn't provide it, try -Dpystring_ROOT=. +# Alternatively, try -Dpystring_LIBRARY= and -Dpystring_INCLUDE_DIR=. # ############################################################################### diff --git a/share/cmake/modules/Findyaml-cpp.cmake b/share/cmake/modules/Findyaml-cpp.cmake index 9e651b98c0..69fb8b71d2 100644 --- a/share/cmake/modules/Findyaml-cpp.cmake +++ b/share/cmake/modules/Findyaml-cpp.cmake @@ -1,25 +1,27 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. # -# Locate or install yaml-cpp +# Locate 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 +# yaml-cpp_FOUND - Indicate whether the library was found or not +# yaml-cpp_LIBRARY - Path to the library file +# yaml-cpp_INCLUDE_DIR - Location of the header files +# yaml-cpp_VERSION - Library's version # -# Targets defined by this module: -# yaml-cpp - IMPORTED target, if found +# Global targets defined by this module: +# yaml-cpp # -# 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 ...). +# The dynamic libraries will be located by default. +# By setting yaml-cpp_STATIC_LIBRARY variable to TRUE, the search for static libraries will +# be initiated, however it's not a guarentee that they will be located. # -# 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. +# If the library is not installed in a standard path, you can do the following the help +# the find module: +# +# If the package provides a configuration file, use -Dyamp-cppDIR=. +# If it doesn't provide it, try -Dyamp-cppROOT=. +# Alternatively, try -Dyamp-cppLIBRARY= and -Dyamp-cppINCLUDE_DIR=. # ############################################################################### diff --git a/share/cmake/modules/install/InstallImath.cmake b/share/cmake/modules/install/InstallImath.cmake index 8e40bd8fb5..6ce5d3a15a 100644 --- a/share/cmake/modules/install/InstallImath.cmake +++ b/share/cmake/modules/install/InstallImath.cmake @@ -1,7 +1,19 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. +# +# Install Imath +# +# Variables defined by this module: +# Imath_FOUND - Indicate whether the library was found or not +# Imath_LIBRARY - Path to the library file +# Imath_INCLUDE_DIR - Location of the header files +# Imath_VERSION - Library's version +# +# Global targets defined by this module: +# Imath::Imath +# Imath::ImathConfig +# -# TODOCED Header ############################################################################### ### Create target diff --git a/share/cmake/modules/install/InstallOpenEXR.cmake b/share/cmake/modules/install/InstallOpenEXR.cmake index 414c548fb9..39877e3d75 100644 --- a/share/cmake/modules/install/InstallOpenEXR.cmake +++ b/share/cmake/modules/install/InstallOpenEXR.cmake @@ -1,13 +1,13 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. # -# Locate or install OpenEXR. +# Install OpenEXR # # Variables defined by this module: -# OpenEXR_FOUND - If FALSE, do not try to link to OpenEXR -# OpenEXR_LIBRARY - OpenEXR library to link to -# OpenEXR_INCLUDE_DIR - Where to find OpenEXR headers -# OpenEXR_VERSION - The version of the library +# OpenEXR_FOUND - Indicate whether the library was found or not +# OpenEXR_LIBRARY - Path to the library file +# OpenEXR_INCLUDE_DIR - Location of the header files +# OpenEXR_VERSION - Library's version # # Imported targets defined by this module, if found: # OpenEXR::Iex @@ -19,19 +19,10 @@ # OpenEXR::OpenEXRCore # OpenEXR::OpenEXRUtil # -# By default, the dynamic libraries of OpenEXR will be found. To find the -# static ones instead, you must set the OpenEXR_STATIC_LIBRARY variable to -# TRUE before calling find_package(OpenEXR ...). -# -# If OpenEXR is not installed in a standard path, you can use the -# OpenEXR_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, OpenEXR will be -# downloaded, statically-built, and used to generate -# libOpenColorIOimageioapphelpers. +# Depending on user options when configuring OCIO, OpenEXR can be used to +# build libOpenColorIOimageioapphelpers. # -############################################################################### -### Try to find package ### ############################################################################### ### Create target diff --git a/share/cmake/modules/install/InstallZLIB.cmake b/share/cmake/modules/install/InstallZLIB.cmake index e9aaffa5a7..edd229f96c 100644 --- a/share/cmake/modules/install/InstallZLIB.cmake +++ b/share/cmake/modules/install/InstallZLIB.cmake @@ -7,17 +7,15 @@ # CMake's FindZLIB when installing ZLIB manually. # # Variables defined by this module: -# ZLIB_FOUND - If FALSE, do not try to link to zlib -# ZLIB_LIBRARIES - ZLIB library to link to -# ZLIB_INCLUDE_DIRS - Where to find zlib.h and other headers -# ZLIB_VERSION - The version of the library +# ZLIB_FOUND - Indicate whether the library was found or not +# ZLIB_LIBRARY - Path to the library file +# ZLIB_INCLUDE_DIR - Location of the header files +# ZLIB_VERSION - Library's version # -# Targets defined by this module: -# ZLIB::ZLIB - Properties: -# IMPORTED_LOCATION ${ZLIB_LIBRARIES} -# INTERFACE_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRS} +# Global targets defined by this module: +# ZLIB::ZLIB # -############################################################################### + ############################################################################### ### Create target diff --git a/share/cmake/modules/install/Installexpat.cmake b/share/cmake/modules/install/Installexpat.cmake index e25f7a9bdb..b802a0ce01 100644 --- a/share/cmake/modules/install/Installexpat.cmake +++ b/share/cmake/modules/install/Installexpat.cmake @@ -1,7 +1,18 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. +# +# Install expat +# +# Variables defined by this module: +# expat_FOUND - Indicate whether the library was found or not +# expat_LIBRARY - Path to the library file +# expat_INCLUDE_DIR - Location of the header files +# expat_VERSION - Library's version +# +# Global targets defined by this module: +# expat::expat +# -# TODOCED Header ############################################################################### ### Create target @@ -23,7 +34,6 @@ if(NOT expat_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAG # Set find_package standard args set(expat_FOUND TRUE) - set(expat_VERSION ${expat_FIND_VERSION}) if(OCIO_expat_RECOMMENDED_VERSION) set(expat_VERSION ${OCIO_expat_RECOMMENDED_VERSION}) else() diff --git a/share/cmake/modules/install/Installlcms2.cmake b/share/cmake/modules/install/Installlcms2.cmake index e89bbed904..3356ee318f 100644 --- a/share/cmake/modules/install/Installlcms2.cmake +++ b/share/cmake/modules/install/Installlcms2.cmake @@ -1,5 +1,18 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. +# +# Install lcms2 +# +# Variables defined by this module: +# lcms2_FOUND - Indicate whether the library was found or not +# lcms2_LIBRARY - Path to the library file +# lcms2_INCLUDE_DIR - Location of the header files +# lcms2_VERSION - Library's version +# +# Global targets defined by this module: +# lcms2::lcms2 +# + ############################################################################### ### Configure target ### diff --git a/share/cmake/modules/install/Installminizip-ng.cmake b/share/cmake/modules/install/Installminizip-ng.cmake index 2ac7d0353e..b193b6263a 100644 --- a/share/cmake/modules/install/Installminizip-ng.cmake +++ b/share/cmake/modules/install/Installminizip-ng.cmake @@ -1,5 +1,21 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. +# +# Install minizip-ng +# +# Variables defined by this module: +# minizip-ng_FOUND - Indicate whether the library was found or not +# minizip-ng_LIBRARY - Path to the library file +# minizip-ng_INCLUDE_DIR - Location of the header files +# minizip-ng_VERSION - Library's version +# +# Global targets defined by this module: +# minizip-ng::minizip-ng +# +# Link against the following target: +# ZLIB::ZLIB +# + ############################################################################### ### Create target diff --git a/share/cmake/modules/install/Installopenfx.cmake b/share/cmake/modules/install/Installopenfx.cmake index 0596bed2bf..8d27135dd8 100644 --- a/share/cmake/modules/install/Installopenfx.cmake +++ b/share/cmake/modules/install/Installopenfx.cmake @@ -1,5 +1,17 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. +# +# Install openfx +# +# Variables defined by this module: +# openfx_FOUND - Indicate whether the library was found or not +# openfx_INCLUDE_DIR - Location of the header files +# openfx_VERSION - Library's version +# +# Global targets defined by this module: +# openfx::module +# + ############################################################################### ### Create target diff --git a/share/cmake/modules/install/Installpybind11.cmake b/share/cmake/modules/install/Installpybind11.cmake index 141549fad9..c0cc66b0c0 100644 --- a/share/cmake/modules/install/Installpybind11.cmake +++ b/share/cmake/modules/install/Installpybind11.cmake @@ -1,5 +1,17 @@ # SPDX-License-Identifier: BSD-3-Clause -# Copyright Contributors to the OpenColorIO Proj +# Copyright Contributors to the OpenColorIO Project. +# +# Install pybind11 +# +# Variables defined by this module: +# pybind11_FOUND - Indicate whether the library was found or not +# pybind11_INCLUDE_DIR - Location of the header files +# pybind11_VERSION - Library's version +# +# Global targets defined by this module: +# pybind11::module +# + ############################################################################### ### Create target ### diff --git a/share/cmake/modules/install/Installpystring.cmake b/share/cmake/modules/install/Installpystring.cmake index d966f05e70..69babd74f1 100644 --- a/share/cmake/modules/install/Installpystring.cmake +++ b/share/cmake/modules/install/Installpystring.cmake @@ -1,5 +1,18 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. +# +# Install pystring +# +# Variables defined by this module: +# pystring_FOUND - Indicate whether the library was found or not +# pystring_LIBRARY - Path to the library file +# pystring_INCLUDE_DIR - Location of the header files +# pystring_VERSION - Library's version +# +# Global targets defined by this module: +# pystring::pystring +# + ############################################################################### ### Configure target ### diff --git a/share/cmake/modules/install/Installyaml-cpp.cmake b/share/cmake/modules/install/Installyaml-cpp.cmake index 74f4db97f0..7cc747f9f8 100644 --- a/share/cmake/modules/install/Installyaml-cpp.cmake +++ b/share/cmake/modules/install/Installyaml-cpp.cmake @@ -1,7 +1,17 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. - -# TODOCED Header +# +# Install yaml-cpp +# +# Variables defined by this module: +# yaml-cpp_FOUND - Indicate whether the library was found or not +# yaml-cpp_LIBRARY - Path to the library file +# yaml-cpp_INCLUDE_DIR - Location of the header files +# yaml-cpp_VERSION - Library's version +# +# Global targets defined by this module: +# yaml-cpp::yaml-cpp +# ############################################################################### ### Create target (if previous 'find_package' call hasn't) ### From cd47a1b988f52a564fda1736aa3308a35aa3f6d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Fri, 27 Jan 2023 10:07:04 -0500 Subject: [PATCH 04/18] Fixing typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- share/cmake/modules/FindImath.cmake | 2 +- share/cmake/modules/FindOpenImageIO.cmake | 2 +- share/cmake/modules/Findexpat.cmake | 2 +- share/cmake/modules/Findlcms2.cmake | 2 +- share/cmake/modules/Findminizip-ng.cmake | 2 +- share/cmake/modules/Findyaml-cpp.cmake | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/share/cmake/modules/FindImath.cmake b/share/cmake/modules/FindImath.cmake index a0f45330be..cb68445dfb 100644 --- a/share/cmake/modules/FindImath.cmake +++ b/share/cmake/modules/FindImath.cmake @@ -14,7 +14,7 @@ # # The dynamic libraries will be located by default. # By setting Imath_STATIC_LIBRARY variable to TRUE, the search for static libraries will -# be initiated, however it's not a guarentee that they will be located. +# be initiated, however it's not guaranteed that they will be located. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/FindOpenImageIO.cmake b/share/cmake/modules/FindOpenImageIO.cmake index 82e8ed5515..74508c9cee 100644 --- a/share/cmake/modules/FindOpenImageIO.cmake +++ b/share/cmake/modules/FindOpenImageIO.cmake @@ -30,7 +30,7 @@ if(NOT DEFINED OpenImageIO_ROOT) endif() if (OpenImageIO_FOUND) - # IMPORTED_GLOBAL property must be set to TRUE since alisasing a non-global imported target + # IMPORTED_GLOBAL property must be set to TRUE since aliasing a non-global imported target # is not possible until CMake 3.18+. set_target_properties(OpenImageIO::OpenImageIO PROPERTIES IMPORTED_GLOBAL TRUE) diff --git a/share/cmake/modules/Findexpat.cmake b/share/cmake/modules/Findexpat.cmake index 7949d8efa1..bfaf36fad2 100644 --- a/share/cmake/modules/Findexpat.cmake +++ b/share/cmake/modules/Findexpat.cmake @@ -14,7 +14,7 @@ # # The dynamic libraries will be located by default. # By setting expat_STATIC_LIBRARY variable to TRUE, the search for static libraries will -# be initiated, however it's not a guarentee that they will be located. +# be initiated, however it's not guaranteed that they will be located. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findlcms2.cmake b/share/cmake/modules/Findlcms2.cmake index 1bb8cebd8b..569c2f4920 100644 --- a/share/cmake/modules/Findlcms2.cmake +++ b/share/cmake/modules/Findlcms2.cmake @@ -14,7 +14,7 @@ # # The dynamic libraries will be located by default. # By setting lcms2_STATIC_LIBRARY variable to TRUE, the search for static libraries will -# be initiated, however it's not a guarentee that they will be located. +# be initiated, however it's not guaranteed that they will be located. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findminizip-ng.cmake b/share/cmake/modules/Findminizip-ng.cmake index 23ed19e911..032ca96239 100644 --- a/share/cmake/modules/Findminizip-ng.cmake +++ b/share/cmake/modules/Findminizip-ng.cmake @@ -14,7 +14,7 @@ # # The dynamic libraries will be located by default. # By setting minizip-ng_STATIC_LIBRARY variable to TRUE, the search for static libraries will -# be initiated, however it's not a guarentee that they will be located. +# be initiated, however it's not guaranteed that they will be located. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findyaml-cpp.cmake b/share/cmake/modules/Findyaml-cpp.cmake index 69fb8b71d2..3e5181e11d 100644 --- a/share/cmake/modules/Findyaml-cpp.cmake +++ b/share/cmake/modules/Findyaml-cpp.cmake @@ -14,7 +14,7 @@ # # The dynamic libraries will be located by default. # By setting yaml-cpp_STATIC_LIBRARY variable to TRUE, the search for static libraries will -# be initiated, however it's not a guarentee that they will be located. +# be initiated, however it's not guaranteed that they will be located. # # If the library is not installed in a standard path, you can do the following the help # the find module: From dd04b455917c237ba6dc95af6113da14f139080f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Wed, 1 Feb 2023 14:05:12 -0500 Subject: [PATCH 05/18] Renamed ocio_find_package to ocio_handle_dependency Renamed ocio_install_package to ocio_install_dependency The "Installing [...]" message from Install module is now under OCIO_VERBOSE variable. Added a message in ocio_install_dependency instead Improve the colors usage in the logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- ...age.cmake => ocio_handle_dependency.cmake} | 70 ++++------- ...ge.cmake => ocio_install_dependency.cmake} | 6 +- share/cmake/modules/FindExtPackages.cmake | 110 +++++++++--------- .../cmake/modules/install/InstallImath.cmake | 4 +- .../modules/install/InstallOpenEXR.cmake | 8 +- share/cmake/modules/install/InstallZLIB.cmake | 4 +- .../cmake/modules/install/Installexpat.cmake | 4 +- .../cmake/modules/install/Installlcms2.cmake | 4 +- .../modules/install/Installminizip-ng.cmake | 4 +- .../cmake/modules/install/Installopenfx.cmake | 4 +- .../modules/install/Installpybind11.cmake | 4 +- .../modules/install/Installpystring.cmake | 4 +- .../modules/install/Installyaml-cpp.cmake | 6 +- share/cmake/utils/CheckSupportGL.cmake | 22 ++-- 14 files changed, 128 insertions(+), 126 deletions(-) rename share/cmake/macros/{ocio_find_package.cmake => ocio_handle_dependency.cmake} (65%) rename share/cmake/macros/{ocio_install_package.cmake => ocio_install_dependency.cmake} (77%) diff --git a/share/cmake/macros/ocio_find_package.cmake b/share/cmake/macros/ocio_handle_dependency.cmake similarity index 65% rename from share/cmake/macros/ocio_find_package.cmake rename to share/cmake/macros/ocio_handle_dependency.cmake index 74ccdd9208..b3e561e103 100644 --- a/share/cmake/macros/ocio_find_package.cmake +++ b/share/cmake/macros/ocio_handle_dependency.cmake @@ -1,32 +1,32 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. -include(ocio_install_package) +include(ocio_install_dependency) -macro (ocio_print_versions_error dep_name) +macro (ocio_print_versions_error dep_name message_color) if(NOT ocio_dep_MIN_VERSION AND NOT ocio_dep_MAX_VERSION AND NOT ocio_dep_RECOMMENDED_MIN_VERSION) - message(STATUS "${ColorError}Could not find ${dep_name} (no version specified)${ColorReset}") + message(STATUS "${message_color}Could NOT find ${dep_name} (no version specified)${ColorReset}") elseif(NOT ocio_dep_MIN_VERSION AND NOT ocio_dep_RECOMMENDED_MIN_VERSION) - message(STATUS "${ColorError}Could not find ${dep_name} (maximum version: \"${ocio_dep_MAX_VERSION)\"${ColorReset}") + message(STATUS "${message_color}Could NOT find ${dep_name} (maximum version: \"${ocio_dep_MAX_VERSION)\"${ColorReset}") elseif(NOT ocio_dep_MIN_VERSION AND NOT ocio_dep_MAX_VERSION) - message(STATUS "${ColorError}Could not find ${dep_name} (recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\")\"${ColorReset}") + message(STATUS "${message_color}Could NOT find ${dep_name} (recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\")\"${ColorReset}") elseif(NOT ocio_dep_RECOMMENDED_MIN_VERSION AND NOT ocio_dep_MAX_VERSION) - message(STATUS "${ColorError}Could not find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION})\"${ColorReset}") + message(STATUS "${message_color}Could NOT find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION})\"${ColorReset}") elseif(NOT ocio_dep_MIN_VERSION) - message(STATUS "${ColorError}Could not find ${dep_name} (recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\", maximum version: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") + message(STATUS "${message_color}Could NOT find ${dep_name} (recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\", maximum version: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") elseif(NOT ocio_dep_RECOMMENDED_MIN_VERSION) - message(STATUS "${ColorError}Could not find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", maximum version: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") + message(STATUS "${message_color}Could NOT find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", maximum version: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") elseif(NOT ocio_dep_MAX_VERSION) - message(STATUS "${ColorError}Could not find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\")${ColorReset}") + message(STATUS "${message_color}Could NOT find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\")${ColorReset}") else() - message(STATUS "${ColorError}Could not find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\", max: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") + message(STATUS "${message_color}Could NOT find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\", max: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") endif() endmacro() # Using a macro because OCIO wants the scope to be the same as the caller scope. # Find modules will set variables via the PARENT_SCOPE option and OCIO needs those # variables in the caller scope. -macro (ocio_find_package dep_name) +macro (ocio_handle_dependency dep_name) cmake_parse_arguments( # prefix ocio_dep @@ -60,6 +60,7 @@ macro (ocio_find_package dep_name) # Nothing to do. Already found. else() # Try to find the recommended version. + # Note that the recommended version should always be specified. find_package(${dep_name} ${ocio_dep_RECOMMENDED_MIN_VERSION} ${ocio_dep_CONFIG_string} @@ -78,37 +79,10 @@ macro (ocio_find_package dep_name) ${ocio_dep_UNPARSED_ARGUMENTS}) endif() - if(NOT ${dep_name}_FOUND AND ocio_dep_MAX_VERSION - AND NOT ocio_dep_MAX_VERSION VERSION_EQUAL ocio_dep_RECOMMENDED_MIN_VERSION) - # if the recommended version is not found, try to find dependency with the maximum version. - find_package(${dep_name} - ${ocio_dep_MAX_VERSION} EXACT - ${ocio_dep_CONFIG_string} - ${ocio_dep_COMPONENTS_string} - ${ocio_dep_COMPONENTS} - ${ocio_dep_QUIET_string} - ${ocio_dep_UNPARSED_ARGUMENTS}) - - if (NOT ${dep_name}_FOUND AND ocio_dep_PREFER_CONFIG) - # Try find_package in module mode instead of config mode. - find_package(${dep_name} - ${ocio_dep_MAX_VERSION} EXACT - ${ocio_dep_COMPONENTS_string} - ${ocio_dep_COMPONENTS} - ${ocio_dep_QUIET_string} - ${ocio_dep_UNPARSED_ARGUMENTS}) - endif() - endif() - if(NOT ${dep_name}_FOUND AND ocio_dep_MIN_VERSION AND NOT ocio_dep_MIN_VERSION VERSION_EQUAL ocio_dep_MAX_VERSION AND NOT ocio_dep_MIN_VERSION VERSION_EQUAL ocio_dep_RECOMMENDED_MIN_VERSION) - if (DEFINED ocio_dep_MAX_VERSION - AND ocio_dep_MIN_VERSION VERSION_LESS ocio_dep_MAX_VERSION) - - endif() - # if the maximum version is not found, try to find dependency with the minimum version. find_package(${dep_name} ${ocio_dep_MIN_VERSION} @@ -154,7 +128,7 @@ macro (ocio_find_package dep_name) set(_${dep_name}_found_displayed true) endif() endif() - + if(DEFINED ocio_dep_RECOMMENDED_MIN_VERSION) if (ocio_dep_VERSION VERSION_LESS ocio_dep_RECOMMENDED_MIN_VERSION) message(STATUS "${ColorSuccess}Found ${dep_name} (version \"${ocio_dep_VERSION}\") (recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\")${ColorReset}") @@ -169,21 +143,27 @@ macro (ocio_find_package dep_name) message(STATUS "${ColorSuccess}Found ${dep_name} (no version information)${ColorReset}") endif() else() - ocio_print_versions_error(${dep_name}) + if(ocio_dep_REQUIRED AND NOT ocio_dep_ALLOW_INSTALL) + set(message_color "${ColorError}") + else() + set(message_color "${ColorReset}") + endif() + + ocio_print_versions_error(${dep_name} ${message_color}) if(${dep_name}_ROOT) - message(STATUS "${ColorError} ${dep_name}_ROOT was: ${${dep_name}_ROOT} ${ColorReset}") + message(STATUS "${message_color} ${dep_name}_ROOT was: ${${dep_name}_ROOT} ${ColorReset}") elseif($ENV{${dep_name}_ROOT}) - message(STATUS "${ColorError} ENV ${dep_name}_ROOT was: ${${dep_name}_ROOT} ${ColorReset}") + message(STATUS "${message_color} ENV ${dep_name}_ROOT was: ${${dep_name}_ROOT} ${ColorReset}") endif() if(ocio_dep_ALLOW_INSTALL) - ocio_install_package(${dep_name} VERSION ${ocio_dep_RECOMMENDED_MIN_VERSION}) + ocio_install_dependency(${dep_name} VERSION ${ocio_dep_RECOMMENDED_MIN_VERSION}) endif() if(ocio_dep_REQUIRED) - if(NOT ${dep_name}_FOUND AND NOT ${ocio_dep_VERSION}) - message(FATAL_ERROR "${ColorError}${dep_name} is required, aborting.${ColorReset}") + if(NOT ${dep_name}_FOUND AND NOT ocio_dep_VERSION) + message(SEND_ERROR "${ColorError}${dep_name} is required, will abort at the end.${ColorReset}") endif() endif() endif() diff --git a/share/cmake/macros/ocio_install_package.cmake b/share/cmake/macros/ocio_install_dependency.cmake similarity index 77% rename from share/cmake/macros/ocio_install_package.cmake rename to share/cmake/macros/ocio_install_dependency.cmake index 1bd5892522..034d2dfc5c 100644 --- a/share/cmake/macros/ocio_install_package.cmake +++ b/share/cmake/macros/ocio_install_dependency.cmake @@ -3,7 +3,7 @@ # Install the specific dependency using OCIO's custom installXYZ module # where XYZ is the name of the dependency. -macro (ocio_install_package dep_name) +macro (ocio_install_dependency dep_name) cmake_parse_arguments( # prefix ocio_dep @@ -19,4 +19,8 @@ macro (ocio_install_package dep_name) set(OCIO_${dep_name}_RECOMMENDED_VERSION ${ocio_dep_VERSION}) include(Install${dep_name}) endif() + + if(${dep_name}_FOUND) + message(STATUS "${ColorSuccess}Installed ${dep_name} (version \"${ocio_dep_VERSION}\")${ColorReset}") + endif() endmacro() \ No newline at end of file diff --git a/share/cmake/modules/FindExtPackages.cmake b/share/cmake/modules/FindExtPackages.cmake index 88fabb06c1..badcafcb30 100644 --- a/share/cmake/modules/FindExtPackages.cmake +++ b/share/cmake/modules/FindExtPackages.cmake @@ -7,7 +7,7 @@ # include(Colors) -include(ocio_find_package) +include(ocio_handle_dependency) ############################################################################### ### Global package options ### @@ -54,31 +54,31 @@ message(STATUS "Checking for mandatory dependencies...") # expat # https://github.com/libexpat/libexpat -ocio_find_package( expat REQUIRED ALLOW_INSTALL - MIN_VERSION 2.4.1 - RECOMMENDED_MIN_VERSION 2.5.0 - RECOMMENDED_MIN_VERSION_REASON "CVE fixes and fix issue with symbol leakage when built as a static library") +ocio_handle_dependency( expat REQUIRED ALLOW_INSTALL + MIN_VERSION 2.4.1 + RECOMMENDED_MIN_VERSION 2.5.0 + RECOMMENDED_MIN_VERSION_REASON "CVE fixes and fix issue with symbol leakage when built as a static library") # yaml-cpp # https://github.com/jbeder/yaml-cpp -ocio_find_package( yaml-cpp REQUIRED ALLOW_INSTALL - MIN_VERSION 0.6.3 - RECOMMENDED_MIN_VERSION 0.7.0 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") +ocio_handle_dependency( yaml-cpp REQUIRED ALLOW_INSTALL + MIN_VERSION 0.6.3 + RECOMMENDED_MIN_VERSION 0.7.0 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") # pystring # https://github.com/imageworks/pystring -ocio_find_package( pystring REQUIRED ALLOW_INSTALL - MIN_VERSION 1.1.3 - RECOMMENDED_MIN_VERSION 1.1.3 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") +ocio_handle_dependency( pystring REQUIRED ALLOW_INSTALL + MIN_VERSION 1.1.3 + RECOMMENDED_MIN_VERSION 1.1.3 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") # Imath (>=3.1) # https://github.com/AcademySoftwareFoundation/Imath -ocio_find_package( Imath REQUIRED ALLOW_INSTALL - MIN_VERSION 3.1.1 - RECOMMENDED_MIN_VERSION 3.1.5 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") +ocio_handle_dependency( Imath REQUIRED ALLOW_INSTALL + MIN_VERSION 3.1.1 + RECOMMENDED_MIN_VERSION 3.1.5 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") ############################################################################### ### ZLIB (https://github.com/madler/zlib) @@ -142,11 +142,11 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) set(_ZLIB_REQUIRED "") endif() - ocio_find_package( ZLIB REQUIRED ALLOW_INSTALL - MIN_VERSION 1.2.10 - RECOMMENDED_MIN_VERSION 1.2.13 - RECOMMENDED_MIN_VERSION_REASON "CVE fixes" - VERSION_VARS ZLIB_VERSION_STRING ZLIB_VERSION ) + ocio_handle_dependency( ZLIB REQUIRED ALLOW_INSTALL + MIN_VERSION 1.2.10 + RECOMMENDED_MIN_VERSION 1.2.13 + RECOMMENDED_MIN_VERSION_REASON "CVE fixes" + VERSION_VARS ZLIB_VERSION_STRING ZLIB_VERSION ) # Restore the original find library ordering if(_cmake_find_library_x_changed) @@ -165,16 +165,16 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) endif() if(NOT ZLIB_FOUND) - ocio_install_package(ZLIB VERSION 1.2.13) + ocio_install_dependency(ZLIB VERSION 1.2.13) endif() ############################################################################### # minizip-ng # https://github.com/zlib-ng/minizip-ng -ocio_find_package( minizip-ng REQUIRED ALLOW_INSTALL - MIN_VERSION 3.0.6 - RECOMMENDED_MIN_VERSION 3.0.7 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") +ocio_handle_dependency( minizip-ng REQUIRED ALLOW_INSTALL + MIN_VERSION 3.0.6 + RECOMMENDED_MIN_VERSION 3.0.7 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") ############################################################################### ## @@ -192,19 +192,19 @@ if(OCIO_BUILD_APPS) # lcms2 # https://github.com/mm2/Little-CMS - ocio_find_package( lcms2 REQUIRED ALLOW_INSTALL - MIN_VERSION 2.2 - RECOMMENDED_MIN_VERSION 2.2 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + ocio_handle_dependency( lcms2 REQUIRED ALLOW_INSTALL + MIN_VERSION 2.2 + RECOMMENDED_MIN_VERSION 2.2 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") endif() if(OCIO_BUILD_OPENFX) # openfx # https://github.com/ofxa/openfx - ocio_find_package( openfx REQUIRED ALLOW_INSTALL - MIN_VERSION 1.4 - RECOMMENDED_MIN_VERSION 1.4 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + ocio_handle_dependency( openfx REQUIRED ALLOW_INSTALL + MIN_VERSION 1.4 + RECOMMENDED_MIN_VERSION 1.4 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") endif() if (OCIO_PYTHON_VERSION AND NOT OCIO_BUILD_PYTHON) @@ -228,20 +228,20 @@ if(OCIO_BUILD_PYTHON OR OCIO_BUILD_DOCS) # Python - ocio_find_package( Python REQUIRED - COMPONENTS ${_Python_COMPONENTS} - MIN_VERSION ${OCIO_PYTHON_VERSION} - RECOMMENDED_MIN_VERSION ${OCIO_PYTHON_VERSION} - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + ocio_handle_dependency( Python REQUIRED + COMPONENTS ${_Python_COMPONENTS} + MIN_VERSION ${OCIO_PYTHON_VERSION} + RECOMMENDED_MIN_VERSION ${OCIO_PYTHON_VERSION} + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") if(OCIO_BUILD_PYTHON) # pybind11 # https://github.com/pybind/pybind11 # pybind11 2.9 fixes issues with MS Visual Studio 2022 (Debug). - ocio_find_package( pybind11 REQUIRED ALLOW_INSTALL - MIN_VERSION 2.9.2 - RECOMMENDED_MIN_VERSION 2.9.2 - RECOMMENDED_MIN_VERSION_REASON "Pybind 2.10.0+ does not work with Python 2.7 anymore") + ocio_handle_dependency( pybind11 REQUIRED ALLOW_INSTALL + MIN_VERSION 2.9.2 + RECOMMENDED_MIN_VERSION 2.9.2 + RECOMMENDED_MIN_VERSION_REASON "Pybind 2.10.0+ does not work with Python 2.7 anymore") endif() endif() @@ -256,9 +256,9 @@ if((OCIO_BUILD_APPS AND OCIO_USE_OIIO_FOR_APPS) OR OCIO_BUILD_TESTS) # TODO: Try when OIIO 2.4 is released (https://github.com/OpenImageIO/oiio/pull/3322). # Supported from OIIO 2.4+. Setting this for lower versions doesn't affect anything. set(OPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH 1) - ocio_find_package( OpenImageIO - MIN_VERSION ${OIIO_VERSION} - RECOMMENDED_MIN_VERSION ${OIIO_RECOMMENDED_VERSION}) + ocio_handle_dependency( OpenImageIO + MIN_VERSION ${OIIO_VERSION} + RECOMMENDED_MIN_VERSION ${OIIO_RECOMMENDED_VERSION}) endif() if(OCIO_BUILD_APPS) @@ -269,10 +269,10 @@ if(OCIO_BUILD_APPS) else() # OpenEXR # https://github.com/AcademySoftwareFoundation/openexr - ocio_find_package( OpenEXR REQUIRED ALLOW_INSTALL - MIN_VERSION 3.0.4 - RECOMMENDED_MIN_VERSION 3.1.5 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + ocio_handle_dependency( OpenEXR REQUIRED ALLOW_INSTALL + MIN_VERSION 3.0.4 + RECOMMENDED_MIN_VERSION 3.1.5 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") if(OpenEXR_FOUND AND TARGET OpenEXR::OpenEXR) add_library(OpenColorIO::ImageIOBackend ALIAS OpenEXR::OpenEXR) @@ -294,10 +294,10 @@ if(OCIO_BUILD_TESTS) if(TARGET Imath::Imath) # OpenShadingLanguage # https://github.com/AcademySoftwareFoundation/OpenShadingLanguage - ocio_find_package( OSL - MIN_VERSION 1.11 - RECOMMENDED_MIN_VERSION 1.11 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + ocio_handle_dependency( OSL + MIN_VERSION 1.11 + RECOMMENDED_MIN_VERSION 1.11 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") if(NOT OSL_FOUND) message(WARNING "Skipping build of the OpenShadingLanguage unit tests (OSL missing)") endif() diff --git a/share/cmake/modules/install/InstallImath.cmake b/share/cmake/modules/install/InstallImath.cmake index 6ce5d3a15a..4f11d7d0a9 100644 --- a/share/cmake/modules/install/InstallImath.cmake +++ b/share/cmake/modules/install/InstallImath.cmake @@ -130,7 +130,9 @@ if(NOT Imath_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAG add_dependencies(Imath::Imath imath_install) - message(STATUS "Installing Imath: ${Imath_LIBRARY} (version \"${Imath_VERSION}\")") + if(OCIO_VERBOSE) + message(STATUS "Installing Imath: ${Imath_LIBRARY} (version \"${Imath_VERSION}\")") + endif() endif() endif() diff --git a/share/cmake/modules/install/InstallOpenEXR.cmake b/share/cmake/modules/install/InstallOpenEXR.cmake index 39877e3d75..ef74389faa 100644 --- a/share/cmake/modules/install/InstallOpenEXR.cmake +++ b/share/cmake/modules/install/InstallOpenEXR.cmake @@ -52,14 +52,14 @@ if(NOT OpenEXR_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACK # ZLIB is required for OCIO too. # Try to find ZLIB without specifying a version since at this point in the dependencies # check, ZLIB should already be found. If not, the configure step will fail either way. - ocio_find_package(ZLIB VERSION_VARS ZLIB_VERSION_STRING ZLIB_VERSION) + ocio_handle_dependency(ZLIB VERSION_VARS ZLIB_VERSION_STRING ZLIB_VERSION) if(NOT ZLIB_FOUND) message(STATUS "ZLIB is required to build OpenEXR.") return() endif() endif() - ocio_find_package(Threads) + ocio_handle_dependency(Threads) if(NOT Threads_FOUND) message(STATUS "Threads is required to build OpenEXR.") return() @@ -181,7 +181,9 @@ if(NOT OpenEXR_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACK add_dependencies(OpenEXR::OpenEXR openexr_install) - message(STATUS "Installing OpenEXR: ${OpenEXR_LIBRARY} (version \"${OpenEXR_VERSION}\")") + if(OCIO_VERBOSE) + message(STATUS "Installing OpenEXR: ${OpenEXR_LIBRARY} (version \"${OpenEXR_VERSION}\")") + endif() endif() endif() diff --git a/share/cmake/modules/install/InstallZLIB.cmake b/share/cmake/modules/install/InstallZLIB.cmake index edd229f96c..e0d31a0c3f 100644 --- a/share/cmake/modules/install/InstallZLIB.cmake +++ b/share/cmake/modules/install/InstallZLIB.cmake @@ -140,7 +140,9 @@ if(NOT ZLIB_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGE set(ZLIB_LIBRARY ${ZLIB_LIBRARIES}) set(ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIRS}) - message(STATUS "Installing ZLIB: ${ZLIB_LIBRARIES} (version \"${ZLIB_VERSION}\") ") + if(OCIO_VERBOSE) + message(STATUS "Installing ZLIB: ${ZLIB_LIBRARIES} (version \"${ZLIB_VERSION}\") ") + endif() endif() diff --git a/share/cmake/modules/install/Installexpat.cmake b/share/cmake/modules/install/Installexpat.cmake index b802a0ce01..3908d60cc9 100644 --- a/share/cmake/modules/install/Installexpat.cmake +++ b/share/cmake/modules/install/Installexpat.cmake @@ -142,7 +142,9 @@ if(NOT expat_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAG ) add_dependencies(expat::expat expat_install) - message(STATUS "Installing expat: ${expat_LIBRARY} (version \"${expat_VERSION}\")") + if(OCIO_VERBOSE) + message(STATUS "Installing expat: ${expat_LIBRARY} (version \"${expat_VERSION}\")") + endif() endif() endif() diff --git a/share/cmake/modules/install/Installlcms2.cmake b/share/cmake/modules/install/Installlcms2.cmake index 3356ee318f..94303df7a5 100644 --- a/share/cmake/modules/install/Installlcms2.cmake +++ b/share/cmake/modules/install/Installlcms2.cmake @@ -123,7 +123,9 @@ if(NOT lcms2_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAG ) add_dependencies(lcms2::lcms2 lcms2_install) - message(STATUS "Installing lcms2: ${lcms2_LIBRARY} (version \"${lcms2_VERSION}\")") + if(OCIO_VERBOSE) + message(STATUS "Installing lcms2: ${lcms2_LIBRARY} (version \"${lcms2_VERSION}\")") + endif() endif() endif() diff --git a/share/cmake/modules/install/Installminizip-ng.cmake b/share/cmake/modules/install/Installminizip-ng.cmake index b193b6263a..6cbc1e39bd 100644 --- a/share/cmake/modules/install/Installminizip-ng.cmake +++ b/share/cmake/modules/install/Installminizip-ng.cmake @@ -134,7 +134,9 @@ if(NOT minizip-ng_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_P ) add_dependencies(MINIZIP::minizip-ng minizip-ng_install) - message(STATUS "Installing minizip-ng: ${minizip-ng_LIBRARY} (version \"${minizip-ng_VERSION}\")") + if(OCIO_VERBOSE) + message(STATUS "Installing minizip-ng: ${minizip-ng_LIBRARY} (version \"${minizip-ng_VERSION}\")") + endif() endif() ############################################################################### diff --git a/share/cmake/modules/install/Installopenfx.cmake b/share/cmake/modules/install/Installopenfx.cmake index 8d27135dd8..36457f346f 100644 --- a/share/cmake/modules/install/Installopenfx.cmake +++ b/share/cmake/modules/install/Installopenfx.cmake @@ -68,7 +68,9 @@ if(NOT openfx_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKA ) add_dependencies(openfx::module openfx_install) - message(STATUS "Installing openfx: ${openfx_INCLUDE_DIR} (version \"${openfx_VERSION}\")") + if(OCIO_VERBOSE) + message(STATUS "Installing openfx: ${openfx_INCLUDE_DIR} (version \"${openfx_VERSION}\")") + endif() endif() endif() diff --git a/share/cmake/modules/install/Installpybind11.cmake b/share/cmake/modules/install/Installpybind11.cmake index c0cc66b0c0..9103c215cc 100644 --- a/share/cmake/modules/install/Installpybind11.cmake +++ b/share/cmake/modules/install/Installpybind11.cmake @@ -104,7 +104,9 @@ if(NOT pybind11_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PAC ) add_dependencies(pybind11::module pybind11_install) - message(STATUS "Installing pybind11: ${pybind11_INCLUDE_DIR} (version \"${pybind11_VERSION}\")") + if(OCIO_VERBOSE) + message(STATUS "Installing pybind11: ${pybind11_INCLUDE_DIR} (version \"${pybind11_VERSION}\")") + endif() endif() endif() diff --git a/share/cmake/modules/install/Installpystring.cmake b/share/cmake/modules/install/Installpystring.cmake index 69babd74f1..f60f490cde 100644 --- a/share/cmake/modules/install/Installpystring.cmake +++ b/share/cmake/modules/install/Installpystring.cmake @@ -115,7 +115,9 @@ if(NOT pystring_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PAC ) add_dependencies(pystring::pystring pystring_install) - message(STATUS "Installing pystring: ${pystring_LIBRARY} (version \"${pystring_VERSION}\")") + if(OCIO_VERBOSE) + message(STATUS "Installing pystring: ${pystring_LIBRARY} (version \"${pystring_VERSION}\")") + endif() endif() endif() diff --git a/share/cmake/modules/install/Installyaml-cpp.cmake b/share/cmake/modules/install/Installyaml-cpp.cmake index 7cc747f9f8..f58ff12b3a 100644 --- a/share/cmake/modules/install/Installyaml-cpp.cmake +++ b/share/cmake/modules/install/Installyaml-cpp.cmake @@ -134,9 +134,9 @@ if(NOT yaml-cpp_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PAC ) add_dependencies(yaml-cpp yaml-cpp_install) - message(STATUS - "Installing yaml-cpp: ${yaml-cpp_LIBRARY} (version \"${yaml-cpp_VERSION}\") " - ) + if(OCIO_VERBOSE) + message(STATUS "Installing yaml-cpp: ${yaml-cpp_LIBRARY} (version \"${yaml-cpp_VERSION}\")") + endif() endif() endif() diff --git a/share/cmake/utils/CheckSupportGL.cmake b/share/cmake/utils/CheckSupportGL.cmake index d603587c88..c5a62f5219 100644 --- a/share/cmake/utils/CheckSupportGL.cmake +++ b/share/cmake/utils/CheckSupportGL.cmake @@ -8,14 +8,14 @@ include(PackageUtils) include(SelectLibraryConfigurations) include(Colors) -include(ocio_find_package) +include(ocio_handle_dependency) if((OCIO_BUILD_TESTS AND OCIO_BUILD_GPU_TESTS) OR OCIO_BUILD_APPS) set(OCIO_GL_ENABLED ON) set(OCIO_USE_GLVND OFF) set(OCIO_EGL_HEADLESS OFF) - ocio_find_package(OpenGL COMPONENTS OpenGL) + ocio_handle_dependency(OpenGL COMPONENTS OpenGL) if(NOT OpenGL_OpenGL_FOUND AND NOT OPENGL_GLU_FOUND) package_root_message(OpenGL) set(OCIO_GL_ENABLED OFF) @@ -24,10 +24,10 @@ if((OCIO_BUILD_TESTS AND OCIO_BUILD_GPU_TESTS) OR OCIO_BUILD_APPS) if(NOT APPLE) # On some Linux platform, the glew-config.cmake is found first. # PREFER_CONFIG assure that config mode will be used first and fallback to module mode. - ocio_find_package( GLEW PREFER_CONFIG - MIN_VERSION 2.1.0 - RECOMMENDED_MIN_VERSION 2.1.0 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + ocio_handle_dependency( GLEW PREFER_CONFIG + MIN_VERSION 2.1.0 + RECOMMENDED_MIN_VERSION 2.1.0 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") if(NOT GLEW_FOUND) package_root_message(GLEW) set(OCIO_GL_ENABLED OFF) @@ -69,10 +69,10 @@ if((OCIO_BUILD_TESTS AND OCIO_BUILD_GPU_TESTS) OR OCIO_BUILD_APPS) endif() endif() - ocio_find_package( GLUT - MIN_VERSION 3.2.1 - RECOMMENDED_MIN_VERSION 3.2.1 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + ocio_handle_dependency( GLUT + MIN_VERSION 3.2.1 + RECOMMENDED_MIN_VERSION 3.2.1 + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") if(NOT GLUT_FOUND) package_root_message(GLUT) set(OCIO_GL_ENABLED OFF) @@ -95,7 +95,7 @@ if((OCIO_BUILD_TESTS AND OCIO_BUILD_GPU_TESTS) OR OCIO_BUILD_APPS) message(STATUS "Can't find EGL without GLVND support; can't render headlessly") set(OCIO_USE_HEADLESS OFF) else() - ocio_find_package(OpenGL COMPONENTS EGL) + ocio_handle_dependency(OpenGL COMPONENTS EGL) if(NOT OpenGL_EGL_FOUND) message(WARNING "EGL component missing; can't render headlessly") set(OCIO_USE_HEADLESS OFF) From 4e4dbf2593e8b216378d589a4460c61baac39451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Thu, 2 Feb 2023 08:46:00 -0500 Subject: [PATCH 06/18] Changed prefix for ocio_install_dependency since it was conflicting with the prefix of ocio_handle_dependency since they were the same. Removed FindOpenEXR.cmake and FindOpenImageIO.cmake since they are not needed anymore (for differente reason). Added PROMOTE_TARGET option for ocio_handle_dependency which promote the target to GLOBAL. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- .../cmake/macros/ocio_handle_dependency.cmake | 6 +- .../macros/ocio_install_dependency.cmake | 8 +- share/cmake/modules/FindExtPackages.cmake | 14 +- share/cmake/modules/FindOpenEXR.cmake | 65 ------ share/cmake/modules/FindOpenImageIO.cmake | 190 ------------------ 5 files changed, 18 insertions(+), 265 deletions(-) delete mode 100644 share/cmake/modules/FindOpenEXR.cmake delete mode 100644 share/cmake/modules/FindOpenImageIO.cmake diff --git a/share/cmake/macros/ocio_handle_dependency.cmake b/share/cmake/macros/ocio_handle_dependency.cmake index b3e561e103..6a4a0ade9f 100644 --- a/share/cmake/macros/ocio_handle_dependency.cmake +++ b/share/cmake/macros/ocio_handle_dependency.cmake @@ -33,7 +33,7 @@ macro (ocio_handle_dependency dep_name) # options "REQUIRED;PREFER_CONFIG;ALLOW_INSTALL;VERBOSE" # one value keywords - "MIN_VERSION;MAX_VERSION;RECOMMENDED_MIN_VERSION;RECOMMENDED_MIN_VERSION_REASON" + "MIN_VERSION;MAX_VERSION;RECOMMENDED_MIN_VERSION;RECOMMENDED_MIN_VERSION_REASON;PROMOTE_TARGET" # multi value keywords "VERSION_VARS;COMPONENTS" # args @@ -167,4 +167,8 @@ macro (ocio_handle_dependency dep_name) endif() endif() endif() + + if(${dep_name}_FOUND AND ocio_dep_PROMOTE_TARGET) + set_target_properties(${ocio_dep_PROMOTE_TARGET} PROPERTIES IMPORTED_GLOBAL TRUE) + endif() endmacro() \ No newline at end of file diff --git a/share/cmake/macros/ocio_install_dependency.cmake b/share/cmake/macros/ocio_install_dependency.cmake index 034d2dfc5c..8a1dd78222 100644 --- a/share/cmake/macros/ocio_install_dependency.cmake +++ b/share/cmake/macros/ocio_install_dependency.cmake @@ -5,8 +5,8 @@ # where XYZ is the name of the dependency. macro (ocio_install_dependency dep_name) cmake_parse_arguments( - # prefix - ocio_dep + # prefix - Must be different than the one used in ocio_handle_dependency.cmake. + ocio_id # options "" # one value keywords @@ -16,11 +16,11 @@ macro (ocio_install_dependency dep_name) # args ${ARGN}) if(NOT ${dep_name}_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) - set(OCIO_${dep_name}_RECOMMENDED_VERSION ${ocio_dep_VERSION}) + set(OCIO_${dep_name}_RECOMMENDED_VERSION ${ocio_id_VERSION}) include(Install${dep_name}) endif() if(${dep_name}_FOUND) - message(STATUS "${ColorSuccess}Installed ${dep_name} (version \"${ocio_dep_VERSION}\")${ColorReset}") + message(STATUS "${ColorSuccess}Installed ${dep_name} (version \"${ocio_id_VERSION}\")${ColorReset}") endif() endmacro() \ No newline at end of file diff --git a/share/cmake/modules/FindExtPackages.cmake b/share/cmake/modules/FindExtPackages.cmake index badcafcb30..c051418155 100644 --- a/share/cmake/modules/FindExtPackages.cmake +++ b/share/cmake/modules/FindExtPackages.cmake @@ -253,12 +253,15 @@ if((OCIO_BUILD_APPS AND OCIO_USE_OIIO_FOR_APPS) OR OCIO_BUILD_TESTS) set(OIIO_VERSION "2.2.14") set(OIIO_RECOMMENDED_VERSION "2.4") - # TODO: Try when OIIO 2.4 is released (https://github.com/OpenImageIO/oiio/pull/3322). # Supported from OIIO 2.4+. Setting this for lower versions doesn't affect anything. set(OPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH 1) - ocio_handle_dependency( OpenImageIO + + # Only using find_package in CONFIG mode using PREFER_CONFIG option as OIIO support + # config file since 2.1+ and OCIO minimum version is over that. + ocio_handle_dependency( OpenImageIO PREFER_CONFIG MIN_VERSION ${OIIO_VERSION} - RECOMMENDED_MIN_VERSION ${OIIO_RECOMMENDED_VERSION}) + RECOMMENDED_MIN_VERSION ${OIIO_RECOMMENDED_VERSION} + PROMOTE_TARGET OpenImageIO::OpenImageIO) endif() if(OCIO_BUILD_APPS) @@ -269,10 +272,11 @@ if(OCIO_BUILD_APPS) else() # OpenEXR # https://github.com/AcademySoftwareFoundation/openexr - ocio_handle_dependency( OpenEXR REQUIRED ALLOW_INSTALL + ocio_handle_dependency( OpenEXR REQUIRED PREFER_CONFIG ALLOW_INSTALL MIN_VERSION 3.0.4 RECOMMENDED_MIN_VERSION 3.1.5 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO" + PROMOTE_TARGET OpenEXR::OpenEXR) if(OpenEXR_FOUND AND TARGET OpenEXR::OpenEXR) add_library(OpenColorIO::ImageIOBackend ALIAS OpenEXR::OpenEXR) diff --git a/share/cmake/modules/FindOpenEXR.cmake b/share/cmake/modules/FindOpenEXR.cmake deleted file mode 100644 index eaddf81d2a..0000000000 --- a/share/cmake/modules/FindOpenEXR.cmake +++ /dev/null @@ -1,65 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright Contributors to the OpenColorIO Project. -# -# Locate OpenEXR. -# -# Variables defined by this module: -# OpenEXR_FOUND - Indicate whether the library was found or not -# OpenEXR_LIBRARY - Path to the library file -# OpenEXR_INCLUDE_DIR - Location of the header files -# OpenEXR_VERSION - Library's version -# -# Imported targets defined by this module, if found: -# OpenEXR::Iex -# OpenEXR::IexConfig -# OpenEXR::IlmThread -# OpenEXR::IlmThreadConfig -# OpenEXR::OpenEXR -# OpenEXR::OpenEXRConfig -# OpenEXR::OpenEXRCore -# OpenEXR::OpenEXRUtil -# -# By default, the dynamic libraries will be found. -# -# If the library is not installed in a standard path, you can do the following the help -# the find module: -# -# If the package provides a configuration file, use -DOpenEXR_DIR=. -# If it doesn't provide it, try -DOpenEXR_ROOT=. -# Alternatively, try -DOpenEXR_LIBRARY= and -DOpenEXR_INCLUDE_DIR=. -# - -############################################################################### -### Try to find package ### - -if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) - set(_OpenEXR_REQUIRED_VARS OpenEXR_LIBRARY) - set(_OpenEXR_LIB_VER "${OpenEXR_FIND_VERSION_MAJOR}_${OpenEXR_FIND_VERSION_MINOR}") - - if(NOT DEFINED OpenEXR_ROOT) - # Search for OpenEXRConfig.cmake - find_package(OpenEXR ${OpenEXR_FIND_VERSION} CONFIG QUIET) - endif() - - if(OpenEXR_FOUND) - get_target_property(OpenEXR_LIBRARY OpenEXR::OpenEXR LOCATION) - get_target_property(OpenEXR_INCLUDE_DIR OpenEXR::OpenEXR INTERFACE_INCLUDE_DIRECTORIES) - - # IMPORTED_GLOBAL property must be set to TRUE since alisasing a non-global imported target - # is not possible until CMake 3.18+. - set_target_properties(OpenEXR::OpenEXR PROPERTIES IMPORTED_GLOBAL TRUE) - endif() - - # Override REQUIRED if package can be installed - if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) - set(OpenEXR_FIND_REQUIRED FALSE) - endif() - - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(OpenEXR - REQUIRED_VARS - ${_OpenEXR_REQUIRED_VARS} - VERSION_VAR - OpenEXR_VERSION - ) -endif() diff --git a/share/cmake/modules/FindOpenImageIO.cmake b/share/cmake/modules/FindOpenImageIO.cmake deleted file mode 100644 index 74508c9cee..0000000000 --- a/share/cmake/modules/FindOpenImageIO.cmake +++ /dev/null @@ -1,190 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright Contributors to the OpenColorIO Project. -# -# Locate OpenImageIO -# -# Variables defined by this module: -# OpenImageIO_FOUND - Indicate whether the library was found or not -# OpenImageIO_LIBRARY - Path to the library file -# OpenImageIO_LIB_DIR - Library's directory -# OpenImageIO_INCLUDE_DIR - Location of the header files -# OpenImageIO_VERSION - Library's version -# -# Global targets defined by this module: -# OpenImageIO::OpenImageIO - The libOpenImageIO library -# OpenImageIO::OpenImageIO_Util - Utility classes (v2.3+) -# -# The dynamic libraries will be located by default. -# -# If the library is not installed in a standard path, you can do the following the help -# the find module: -# -# If the package provides a configuration file, use -DOpenImageIO_DIR=. -# If it doesn't provide it, try -DOpenImageIO_ROOT=. -# Alternatively, try -DOpenImageIO_LIBRARY= and -DOpenImageIO_INCLUDE_DIR=. -# - -if(NOT DEFINED OpenImageIO_ROOT) - # Search for OpenImageIOConfig.cmake - find_package(OpenImageIO ${OpenImageIO_FIND_VERSION} CONFIG QUIET) -endif() - -if (OpenImageIO_FOUND) - # IMPORTED_GLOBAL property must be set to TRUE since aliasing a non-global imported target - # is not possible until CMake 3.18+. - set_target_properties(OpenImageIO::OpenImageIO PROPERTIES IMPORTED_GLOBAL TRUE) - - # Set the ROOT directory by going up a directory from OpenImageIO_LIB_DIR. - get_filename_component(_PARENT_DIR ${OpenImageIO_LIB_DIR} DIRECTORY) - # find_library will prioritize OpenImageIO_ROOT before any other path. - set(OpenImageIO_ROOT ${_PARENT_DIR}) - - # Set OpenImageIO_LIBRARY since OpenImageIOConfig does not do it. - find_library (OpenImageIO_LIBRARY - NAMES - OpenImageIO - HINTS - ${OpenImageIO_LIB_DIR} - PATH_SUFFIXES - lib64 - lib - OpenImageIO/lib - ) - - # Find util library - find_library (OpenImageIO_UTIL_LIBRARY - NAMES - OpenImageIO_Util - HINTS - ${OpenImageIO_LIB_DIR} - PATH_SUFFIXES - lib64 - lib - OpenImageIO/lib - ) - -else() - # Search for pkg config file. - find_package(PkgConfig QUIET) - pkg_check_modules(PC_OpenImageIO QUIET "OpenImageIO>=${OpenImageIO_FIND_VERSION}") - - # Find include directory - # Since CMake 3.12, find_path search through OpenImageIO_ROOT before everything else. - find_path(OpenImageIO_INCLUDE_DIR - NAMES - OpenImageIO/oiioversion.h - HINTS - ${PC_OpenImageIO_INCLUDE_DIRS} - PATH_SUFFIXES - OpenImageIO/include - ) - - # Set OpenImageIO_INCLUDES since OpenImageIOConfig does it. - set(OpenImageIO_INCLUDES ${OpenImageIO_INCLUDE_DIR}) - - # Find library - # Since CMake 3.12, find_library search through OpenImageIO_ROOT before everything else. - find_library (OpenImageIO_LIBRARY - NAMES - OpenImageIO - HINTS - ${PC_OpenImageIO_LIBRARY_DIRS} - PATH_SUFFIXES - lib64 - lib - OpenImageIO/lib - ) - - # Find util library - find_library (OpenImageIO_UTIL_LIBRARY - NAMES - OpenImageIO_Util - HINTS - ${PC_OpenImageIO_LIBRARY_DIRS} - PATH_SUFFIXES - lib64 - lib - OpenImageIO/lib - ) - - # Set OpenImageIO_LIB_DIR since OpenImageIOConfig does it. - get_filename_component(OpenImageIO_LIB_DIR ${OpenImageIO_LIBRARY} DIRECTORY) - - if (OpenImageIO_INCLUDE_DIR) - # Try to figure out version number - list(GET OpenImageIO_INCLUDE_DIR 0 _OpenImageIO_INCLUDE_DIR) - if(EXISTS "${_OpenImageIO_INCLUDE_DIR}/oiioversion.h") - set(OIIO_VERSION_HEADER "${_OpenImageIO_INCLUDE_DIR}/oiioversion.h") - elseif(EXISTS "${_OpenImageIO_INCLUDE_DIR}/OpenImageIO/oiioversion.h") - set(OIIO_VERSION_HEADER "${_OpenImageIO_INCLUDE_DIR}/OpenImageIO/oiioversion.h") - endif() - - if (EXISTS "${OIIO_VERSION_HEADER}") - file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_MAJOR .*$") - string (REGEX MATCHALL "[0-9]+" OpenImageIO_VERSION_MAJOR ${TMP}) - file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_MINOR .*$") - string (REGEX MATCHALL "[0-9]+" OpenImageIO_VERSION_MINOR ${TMP}) - file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_PATCH .*$") - string (REGEX MATCHALL "[0-9]+" OpenImageIO_VERSION_PATCH ${TMP}) - file (STRINGS "${OIIO_VERSION_HEADER}" TMP REGEX "^#define OIIO_VERSION_TWEAK .*$") - if (TMP) - string (REGEX MATCHALL "[0-9]+" OpenImageIO_VERSION_TWEAK ${TMP}) - else () - set (OpenImageIO_VERSION_TWEAK 0) - endif () - set (OpenImageIO_VERSION "${OpenImageIO_VERSION_MAJOR}.${OpenImageIO_VERSION_MINOR}.${OpenImageIO_VERSION_PATCH}.${OpenImageIO_VERSION_TWEAK}") - endif () - - set (OIIO_IMATH_HEADER "${OpenImageIO_INCLUDE_DIR}/OpenImageIO/Imath.h") - if (EXISTS "${OIIO_IMATH_HEADER}") - file (STRINGS "${OIIO_IMATH_HEADER}" TMP REGEX "^#define OIIO_USING_IMATH .*$") - string (REGEX MATCHALL "[0-9]" OIIO_IMATH_VERSION ${TMP}) - if (OIIO_IMATH_VERSION LESS 3) - message(STATUS "Skipping OpenImageIO built against OpenEXR 2, please use version 3 or greater.") - return () - endif () - endif () - elseif(PC_OpenImageIO_FOUND) - set(OpenImageIO_VERSION "${PC_OpenImageIO_VERSION}") - endif() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(OpenImageIO - REQUIRED_VARS - OpenImageIO_LIB_DIR - OpenImageIO_INCLUDE_DIR - OpenImageIO_LIBRARY - VERSION_VAR - OpenImageIO_VERSION -) - -############################################################################### -### Create target - -if (OpenImageIO_FOUND AND NOT TARGET OpenImageIO::OpenImageIO) - add_library(OpenImageIO::OpenImageIO UNKNOWN IMPORTED GLOBAL) - - # Configure target - - set_target_properties(OpenImageIO::OpenImageIO PROPERTIES - IMPORTED_LOCATION "${OpenImageIO_LIBRARY}" - INTERFACE_INCLUDE_DIRECTORIES "${OpenImageIO_INCLUDE_DIR}") - - # Starting with OIIO v2.3, some utility classes are now only declared in OpenImageIO_Util - # (and not in both libraries like in older versions). - if (${OpenImageIO_VERSION} VERSION_GREATER_EQUAL "2.3" AND NOT TARGET OpenImageIO::OpenImageIO_Util) - add_library(OpenImageIO::OpenImageIO_Util UNKNOWN IMPORTED) - set_target_properties(OpenImageIO::OpenImageIO_Util PROPERTIES - IMPORTED_LOCATION "${OpenImageIO_UTIL_LIBRARY}") - target_link_libraries(OpenImageIO::OpenImageIO INTERFACE OpenImageIO::OpenImageIO_Util) - endif () - - # Starting with OIIO v2.3, OIIO needs to compile at least in C++14. - if (${OpenImageIO_VERSION} VERSION_GREATER_EQUAL "2.3" AND ${CMAKE_CXX_STANDARD} LESS_EQUAL 11) - set(OpenImageIO_FOUND OFF) - message(WARNING "Need C++14 or higher to compile with OpenImageIO ${OpenImageIO_VERSION}.") - endif () - - mark_as_advanced(OpenImageIO_INCLUDE_DIR OpenImageIO_LIBRARY OpenImageIO_VERSION) -endif() \ No newline at end of file From be2dabe90a07db7c494aca9ed1c9c8c38bece14e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Thu, 2 Feb 2023 14:08:33 -0500 Subject: [PATCH 07/18] Mostly comments and documentations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- .../cmake/macros/ocio_handle_dependency.cmake | 53 ++++++++++++++++++- .../macros/ocio_install_dependency.cmake | 11 ++++ 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/share/cmake/macros/ocio_handle_dependency.cmake b/share/cmake/macros/ocio_handle_dependency.cmake index 6a4a0ade9f..b033f0e47c 100644 --- a/share/cmake/macros/ocio_handle_dependency.cmake +++ b/share/cmake/macros/ocio_handle_dependency.cmake @@ -3,6 +3,15 @@ include(ocio_install_dependency) +################################################################################################### +# ocio_print_versions_error is a wrapper for messages when the dependency is not found. +# +# Arguments: +# dep_name is the name of the dependency (package). Please note that dep_name is case sensitive. +# message_color is the color of the message. +# +# Note that this marco is used in ocio_handle_dependency and should be there only. +################################################################################################### macro (ocio_print_versions_error dep_name message_color) if(NOT ocio_dep_MIN_VERSION AND NOT ocio_dep_MAX_VERSION AND NOT ocio_dep_RECOMMENDED_MIN_VERSION) message(STATUS "${message_color}Could NOT find ${dep_name} (no version specified)${ColorReset}") @@ -26,6 +35,41 @@ endmacro() # Using a macro because OCIO wants the scope to be the same as the caller scope. # Find modules will set variables via the PARENT_SCOPE option and OCIO needs those # variables in the caller scope. + +################################################################################################### +# ocio_handle_dependency is a wrapper for find_package with extra options (features). +# +# Argument: +# dep_name is the name of the dependency (package). Please note that dep_name is case sensitive. +# +# Options (no value): +# REQUIRED - Whether the dependency is required or not. Fails if missing. +# PREFER_CONFIG - Call find_package in CONFIG mode internally. +# Note that it tries to find Config.cmake or +# -Config.cmake directly. +# ALLOW_INSTALL - Try to install the dependency if not found. Note that a +# corresponding Install.cmake file must exist. +# VERBOSE - Enable extra logging. +# +# Options (one value): +# MIN_VERSION - Minimum version for the dependency. +# MAX_VERSION - Maximum version for the dependency. +# RECOMMENDED_MIN_VERSION - Recommended version for the dependency. +# RECOMMENDED_MIN_VERSION_REASON - Reason for the recommended version. +# +# Options (multiple values): +# VERSION_VARS - List of version variables. Default to _VERSION. +# COMPONENTS - List of components to find. Just like find_package option. +# PROMOTE_TARGET - List of targets that needs to be globally visible by setting +# the targets property IMPORTED_GLOBAL to true. Note that the +# targets must be created by the dependency. +# +# This is a macro because OCIO wants the scope to be the same as the caller scope. +# Find modules will set variables via the PARENT_SCOPE option and OCIO needs those +# variables in the caller scope. +# +################################################################################################### + macro (ocio_handle_dependency dep_name) cmake_parse_arguments( # prefix @@ -124,7 +168,7 @@ macro (ocio_handle_dependency dep_name) if(DEFINED ocio_dep_MAX_VERSION) if(ocio_dep_VERSION VERSION_GREATER ocio_dep_MAX_VERSION) # Display it as an error, but do not abort right now. - message(SEND_ERROR "${ColorError}Found ${dep_name} ${ocio_dep_VERSION}, but is it over the recommended maximum version \"${ocio_dep_MAX_VERSION}\" ${ColorReset}") + message(SEND_ERROR "${ColorError}Found ${dep_name} ${ocio_dep_VERSION}, but it is over the maximum version \"${ocio_dep_MAX_VERSION}\" ${ColorReset}") set(_${dep_name}_found_displayed true) endif() endif() @@ -132,6 +176,9 @@ macro (ocio_handle_dependency dep_name) if(DEFINED ocio_dep_RECOMMENDED_MIN_VERSION) if (ocio_dep_VERSION VERSION_LESS ocio_dep_RECOMMENDED_MIN_VERSION) message(STATUS "${ColorSuccess}Found ${dep_name} (version \"${ocio_dep_VERSION}\") (recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\")${ColorReset}") + if (ocio_dep_RECOMMENDED_MIN_VERSION_REASON) + message(STATUS " Reason: ${ocio_dep_RECOMMENDED_MIN_VERSION_REASON}") + endif() set(_${dep_name}_found_displayed true) endif() endif() @@ -169,6 +216,8 @@ macro (ocio_handle_dependency dep_name) endif() if(${dep_name}_FOUND AND ocio_dep_PROMOTE_TARGET) - set_target_properties(${ocio_dep_PROMOTE_TARGET} PROPERTIES IMPORTED_GLOBAL TRUE) + foreach (_target_to_be_promoted_ ${ocio_dep_PROMOTE_TARGET}) + set_target_properties(${_target_to_be_promoted_} PROPERTIES IMPORTED_GLOBAL TRUE) + endforeach() endif() endmacro() \ No newline at end of file diff --git a/share/cmake/macros/ocio_install_dependency.cmake b/share/cmake/macros/ocio_install_dependency.cmake index 8a1dd78222..0f7ca1072f 100644 --- a/share/cmake/macros/ocio_install_dependency.cmake +++ b/share/cmake/macros/ocio_install_dependency.cmake @@ -3,6 +3,17 @@ # Install the specific dependency using OCIO's custom installXYZ module # where XYZ is the name of the dependency. + +################################################################################################### +# ocio_install_dependency installs a dependency by calling the corresponding Install module. +# e.g. Install.cmake +# +# Argument: +# dep_name is the name of the dependency (package). Please note that dep_name is case sensitive. +# +# Options (one value): +# VERSION - Version to install. +################################################################################################### macro (ocio_install_dependency dep_name) cmake_parse_arguments( # prefix - Must be different than the one used in ocio_handle_dependency.cmake. From f45ac540cdc3c5232f90cff777ad4e0da6aae619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Thu, 2 Feb 2023 14:10:56 -0500 Subject: [PATCH 08/18] Small update of the Existing Install Hints section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- docs/quick_start/installation.rst | 89 ++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 26 deletions(-) diff --git a/docs/quick_start/installation.rst b/docs/quick_start/installation.rst index 600fa89e12..d8a70fea9b 100644 --- a/docs/quick_start/installation.rst +++ b/docs/quick_start/installation.rst @@ -187,10 +187,42 @@ Three ``OCIO_INSTALL_EXT_PACKAGES`` options are available:: Existing Install Hints ++++++++++++++++++++++ -When using libraries already on your system, the CMake variable -``-D _ROOT=`` may be used to specify the path to the include and -library root directory rather than have CMake try to find it. The package names used -by OCIO are as follows (note that these are case-sensitive): +The recommended way to find a dependency is by using their configuration file. Most dependencies +provides those files. These configuration files sets all the necessary targets and variables. +CMake needs to know where to find these configuration files. If CMake doesn't find them in any of +the default locations, you may use the variable ``-D_DIR=``. + +Note that ``lcms2``, ``openfx``, ``pystring`` and ``sphinx`` does **not** support ``_DIR``. + +Alternative methods exist to aid CMake in locating dependencies, but they should only be used in specific +situations, such as when attempting to help CMake find dependencies that do not have configuration +files available or when the static version of a dependency is needed. + +An alternative method is using the CMake variable ``-D_ROOT=``. That +variable may be used to specify the path to the include and library root directory. + +Note that ``OpenImageIO`` and ``OpenEXR`` does **not** support ``_ROOT``. + +There are scenarios in which some of the dependencies may not be compiled into an +OCIO dynamic library. This is more likely when OCIO does not download the packages +itself. In these cases, it may be helpful to specify an additional CMake variable. While using +``_ROOT``, some dependencies allows the usage of ``-D_STATIC_LIBRARY=ON``. +If ``_STATIC_LIBRARY`` is set, CMake will try to find static version of the dependency. + +The following package **support** ``-D_STATIC_LIBRARY=ON``: +``expat``, ``yaml-cpp``, ``Imath``, ``lcms2``, ``ZLIB``, and ``minizip-ng``. + +Rather than using ``_ROOT``, and possibly ``_STATIC_LIBRARY``, you may +instead use ``-D_LIBRARY=`` +and ``-D_INCLUDE_DIR=``. In this case, the library path will +control whether a static or dynamic library is used. It may also be used to handle situations where +the library and/or include files are not in the typical location relative to the root directory. + +The following package **support** ``_LIBRARY`` and ``_INCLUDE_DIR``: +``expat``, ``yaml-cpp``, ``Imath``, ``lcms2``, ``openfx``, ``OSL``, ``pybind11``, ``pystring``, +``yaml-cpp``, ``ZLIB``, and ``minizip-ng``. + +The package names used by OCIO are as follows (note that these are case-sensitive): Required: @@ -214,21 +246,6 @@ Optional: - ``GLUT`` - ``Python`` -There are scenarios in which some of the dependencies may not be compiled into an -OCIO dynamic library. This is more likely when OCIO does not download the packages -itself. In these cases, it may be helpful to additionally specify the CMake variable -``-D _STATIC_LIBRARY=ON``. The following package names support this hint: -``expat``, ``yaml-cpp``, ``Imath``, ``lcms2``, ``ZLIB``, and ``minizip-ng``. - -Rather than using ``_ROOT``, and possibly ``_STATIC_LIBRARY``, you may instead use -``-D _LIBRARY=`` and ``-D _INCLUDE_DIR=``. -In this case, the library path will control whether a static or dynamic library is used. -It may also be used to handle situations where the library and/or include files are not -in the typical location relative to the root directory. - -The OCIO `CMake find modules `_ -may be consulted for more detail on the handling of a given package and the CMake -variables it uses. Please note that if you provide your own ``minizip-ng``, rather than having OCIO's CMake download and build it, you will likely need to set its CMake variables the same way @@ -237,6 +254,10 @@ from various package managers (e.g., Homebrew) probably won't work. Please see settings that begin with ``-DMZ_`` that are used in the OCIO `minizip-ng find module. `_ +The OCIO `CMake find modules `_ +may be consulted for more detail on the handling of a given package and the CMake +variables it uses. + Please note that if you build a static OCIO library, it will not contain the libraries for the external packages and so you will need to list those separately when linking your client application. If you had OCIO download and build these packages, you will @@ -384,7 +405,7 @@ Windows While build environments may vary between users, the recommended way to build OCIO from source on Windows 7 or newer is to use the scripts provided in the Windows `share `_ -section of the OCIO repository. There are two scripts currently available. +section of the OCIO repository. There are two scripts currently available. The first script is called `ocio_deps.bat `_ @@ -396,14 +417,18 @@ and it provides some automation to install the most difficult dependencies. Thos - Glew - Python dependencies for documentation -Run this command to execute the ocio_deps.bat script:: +Run this command to execute the ocio_deps.bat script: +.. code-block:: bash + ocio_deps.bat --vcpkg The second script is called `ocio.bat `_ and it provide a way to configure and build OCIO from source. Moreover, this script executes the -install step of ``cmake`` as well as the unit tests. The main use case is the following:: +install step of ``cmake`` as well as the unit tests. The main use case is the following: + +.. code-block:: bash ocio.bat --b --i --vcpkg --ocio --type Release @@ -422,14 +447,26 @@ Quick environment configuration The quickest way to set the required :ref:`environment-setup` is to source the ``share/ocio/setup_ocio.sh`` script installed with OCIO. -On Windows, use the corresponding setup_ocio.bat file. +On Windows, use the corresponding setup_ocio.bat file. See OCIO's install directory under +share/ocio. + +For a temporary configuration of your terminal, you can run the following script: + +.. code-block:: bash + + # Windows - Execute setup_ocio.bat + [... path to OCIO install directory]/share/ocio/setup_ocio.bat + # Unix - Execute setup_ocio.sh + [... path to OCIO install directory]\share\ocio\setup_ocio.sh -For a simple single-user setup, add the following to ``~/.bashrc`` +For a more permanent option, add the following to ``~/.bashrc`` (assuming you are using bash, and the example install directory of -``/software/ocio``):: +``/software/ocio``): - source /software/ocio/share/ocio/setup_ocio.sh +.. code-block:: bash + source /software/ocio/share/ocio/setup_ocio.sh + The only environment variable you must configure manually is :envvar:`OCIO`, which points to the configuration file you wish to use. For prebuilt config files, see the From fb30c9d9260d06f04130c6f70395f156821c6500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Fri, 3 Feb 2023 09:46:38 -0500 Subject: [PATCH 09/18] Changed RECOMMENDED_MIN_VERSION to RECOMMENDED_VERSION Re-worded some of the comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- .../cmake/macros/ocio_handle_dependency.cmake | 47 ++++++++--------- .../macros/ocio_install_dependency.cmake | 3 -- share/cmake/modules/FindExtPackages.cmake | 50 +++++++++---------- share/cmake/modules/FindImath.cmake | 11 ++-- share/cmake/modules/FindOSL.cmake | 3 +- share/cmake/modules/Findexpat.cmake | 11 ++-- share/cmake/modules/Findlcms2.cmake | 11 ++-- share/cmake/modules/Findminizip-ng.cmake | 11 ++-- share/cmake/modules/Findopenfx.cmake | 3 +- share/cmake/modules/Findpybind11.cmake | 3 +- share/cmake/modules/Findpystring.cmake | 3 +- share/cmake/modules/Findyaml-cpp.cmake | 11 ++-- share/cmake/utils/CheckSupportGL.cmake | 8 +-- 13 files changed, 101 insertions(+), 74 deletions(-) diff --git a/share/cmake/macros/ocio_handle_dependency.cmake b/share/cmake/macros/ocio_handle_dependency.cmake index b033f0e47c..34fca3ec1b 100644 --- a/share/cmake/macros/ocio_handle_dependency.cmake +++ b/share/cmake/macros/ocio_handle_dependency.cmake @@ -10,25 +10,25 @@ include(ocio_install_dependency) # dep_name is the name of the dependency (package). Please note that dep_name is case sensitive. # message_color is the color of the message. # -# Note that this marco is used in ocio_handle_dependency and should be there only. +# Note that this macro is used in ocio_handle_dependency and should be there only. ################################################################################################### macro (ocio_print_versions_error dep_name message_color) - if(NOT ocio_dep_MIN_VERSION AND NOT ocio_dep_MAX_VERSION AND NOT ocio_dep_RECOMMENDED_MIN_VERSION) + if(NOT ocio_dep_MIN_VERSION AND NOT ocio_dep_MAX_VERSION AND NOT ocio_dep_RECOMMENDED_VERSION) message(STATUS "${message_color}Could NOT find ${dep_name} (no version specified)${ColorReset}") - elseif(NOT ocio_dep_MIN_VERSION AND NOT ocio_dep_RECOMMENDED_MIN_VERSION) + elseif(NOT ocio_dep_MIN_VERSION AND NOT ocio_dep_RECOMMENDED_VERSION) message(STATUS "${message_color}Could NOT find ${dep_name} (maximum version: \"${ocio_dep_MAX_VERSION)\"${ColorReset}") elseif(NOT ocio_dep_MIN_VERSION AND NOT ocio_dep_MAX_VERSION) - message(STATUS "${message_color}Could NOT find ${dep_name} (recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\")\"${ColorReset}") - elseif(NOT ocio_dep_RECOMMENDED_MIN_VERSION AND NOT ocio_dep_MAX_VERSION) + message(STATUS "${message_color}Could NOT find ${dep_name} (recommended version: \"${ocio_dep_RECOMMENDED_VERSION}\")\"${ColorReset}") + elseif(NOT ocio_dep_RECOMMENDED_VERSION AND NOT ocio_dep_MAX_VERSION) message(STATUS "${message_color}Could NOT find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION})\"${ColorReset}") elseif(NOT ocio_dep_MIN_VERSION) - message(STATUS "${message_color}Could NOT find ${dep_name} (recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\", maximum version: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") - elseif(NOT ocio_dep_RECOMMENDED_MIN_VERSION) + message(STATUS "${message_color}Could NOT find ${dep_name} (recommended version: \"${ocio_dep_RECOMMENDED_VERSION}\", maximum version: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") + elseif(NOT ocio_dep_RECOMMENDED_VERSION) message(STATUS "${message_color}Could NOT find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", maximum version: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") elseif(NOT ocio_dep_MAX_VERSION) - message(STATUS "${message_color}Could NOT find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\")${ColorReset}") + message(STATUS "${message_color}Could NOT find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", recommended version: \"${ocio_dep_RECOMMENDED_VERSION}\")${ColorReset}") else() - message(STATUS "${message_color}Could NOT find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\", max: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") + message(STATUS "${message_color}Could NOT find ${dep_name} (minimum version: \"${ocio_dep_MIN_VERSION}\", recommended version: \"${ocio_dep_RECOMMENDED_VERSION}\", max: \"${ocio_dep_MAX_VERSION}\")${ColorReset}") endif() endmacro() @@ -54,8 +54,8 @@ endmacro() # Options (one value): # MIN_VERSION - Minimum version for the dependency. # MAX_VERSION - Maximum version for the dependency. -# RECOMMENDED_MIN_VERSION - Recommended version for the dependency. -# RECOMMENDED_MIN_VERSION_REASON - Reason for the recommended version. +# RECOMMENDED_VERSION - Recommended version for the dependency. +# RECOMMENDED_VERSION_REASON - Reason for the recommended version. # # Options (multiple values): # VERSION_VARS - List of version variables. Default to _VERSION. @@ -77,7 +77,7 @@ macro (ocio_handle_dependency dep_name) # options "REQUIRED;PREFER_CONFIG;ALLOW_INSTALL;VERBOSE" # one value keywords - "MIN_VERSION;MAX_VERSION;RECOMMENDED_MIN_VERSION;RECOMMENDED_MIN_VERSION_REASON;PROMOTE_TARGET" + "MIN_VERSION;MAX_VERSION;RECOMMENDED_VERSION;RECOMMENDED_VERSION_REASON;PROMOTE_TARGET" # multi value keywords "VERSION_VARS;COMPONENTS" # args @@ -103,10 +103,10 @@ macro (ocio_handle_dependency dep_name) if (${dep_name}_FOUND) # Nothing to do. Already found. else() - # Try to find the recommended version. + # Try to find the recommended, or higher, version. # Note that the recommended version should always be specified. find_package(${dep_name} - ${ocio_dep_RECOMMENDED_MIN_VERSION} + ${ocio_dep_RECOMMENDED_VERSION} ${ocio_dep_CONFIG_string} ${ocio_dep_COMPONENTS_string} ${ocio_dep_COMPONENTS} @@ -116,7 +116,7 @@ macro (ocio_handle_dependency dep_name) if (NOT ${dep_name}_FOUND AND ocio_dep_PREFER_CONFIG) # Try find_package in module mode instead of config mode. find_package(${dep_name} - ${ocio_dep_RECOMMENDED_MIN_VERSION} + ${ocio_dep_RECOMMENDED_VERSION} ${ocio_dep_COMPONENTS_string} ${ocio_dep_COMPONENTS} ${ocio_dep_QUIET_string} @@ -125,9 +125,10 @@ macro (ocio_handle_dependency dep_name) if(NOT ${dep_name}_FOUND AND ocio_dep_MIN_VERSION AND NOT ocio_dep_MIN_VERSION VERSION_EQUAL ocio_dep_MAX_VERSION - AND NOT ocio_dep_MIN_VERSION VERSION_EQUAL ocio_dep_RECOMMENDED_MIN_VERSION) + AND NOT ocio_dep_MIN_VERSION VERSION_EQUAL ocio_dep_RECOMMENDED_VERSION) - # if the maximum version is not found, try to find dependency with the minimum version. + # if the recommended, or higher, version is not found, try to find dependency with + # the minimum version. find_package(${dep_name} ${ocio_dep_MIN_VERSION} ${ocio_dep_CONFIG_string} @@ -173,11 +174,11 @@ macro (ocio_handle_dependency dep_name) endif() endif() - if(DEFINED ocio_dep_RECOMMENDED_MIN_VERSION) - if (ocio_dep_VERSION VERSION_LESS ocio_dep_RECOMMENDED_MIN_VERSION) - message(STATUS "${ColorSuccess}Found ${dep_name} (version \"${ocio_dep_VERSION}\") (recommended version: \"${ocio_dep_RECOMMENDED_MIN_VERSION}\")${ColorReset}") - if (ocio_dep_RECOMMENDED_MIN_VERSION_REASON) - message(STATUS " Reason: ${ocio_dep_RECOMMENDED_MIN_VERSION_REASON}") + if(DEFINED ocio_dep_RECOMMENDED_VERSION) + if (ocio_dep_VERSION VERSION_LESS ocio_dep_RECOMMENDED_VERSION) + message(STATUS "${ColorSuccess}Found ${dep_name} (version \"${ocio_dep_VERSION}\") (recommended version: \"${ocio_dep_RECOMMENDED_VERSION}\")${ColorReset}") + if (ocio_dep_RECOMMENDED_VERSION_REASON) + message(STATUS " Reason: ${ocio_dep_RECOMMENDED_VERSION_REASON}") endif() set(_${dep_name}_found_displayed true) endif() @@ -205,7 +206,7 @@ macro (ocio_handle_dependency dep_name) endif() if(ocio_dep_ALLOW_INSTALL) - ocio_install_dependency(${dep_name} VERSION ${ocio_dep_RECOMMENDED_MIN_VERSION}) + ocio_install_dependency(${dep_name} VERSION ${ocio_dep_RECOMMENDED_VERSION}) endif() if(ocio_dep_REQUIRED) diff --git a/share/cmake/macros/ocio_install_dependency.cmake b/share/cmake/macros/ocio_install_dependency.cmake index 0f7ca1072f..2923a2bcee 100644 --- a/share/cmake/macros/ocio_install_dependency.cmake +++ b/share/cmake/macros/ocio_install_dependency.cmake @@ -1,9 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright Contributors to the OpenColorIO Project. -# Install the specific dependency using OCIO's custom installXYZ module -# where XYZ is the name of the dependency. - ################################################################################################### # ocio_install_dependency installs a dependency by calling the corresponding Install module. # e.g. Install.cmake diff --git a/share/cmake/modules/FindExtPackages.cmake b/share/cmake/modules/FindExtPackages.cmake index c051418155..72a385449c 100644 --- a/share/cmake/modules/FindExtPackages.cmake +++ b/share/cmake/modules/FindExtPackages.cmake @@ -56,29 +56,29 @@ message(STATUS "Checking for mandatory dependencies...") # https://github.com/libexpat/libexpat ocio_handle_dependency( expat REQUIRED ALLOW_INSTALL MIN_VERSION 2.4.1 - RECOMMENDED_MIN_VERSION 2.5.0 - RECOMMENDED_MIN_VERSION_REASON "CVE fixes and fix issue with symbol leakage when built as a static library") + RECOMMENDED_VERSION 2.5.0 + RECOMMENDED_VERSION_REASON "CVE fixes and fix issue with symbol leakage when built as a static library") # yaml-cpp # https://github.com/jbeder/yaml-cpp ocio_handle_dependency( yaml-cpp REQUIRED ALLOW_INSTALL MIN_VERSION 0.6.3 - RECOMMENDED_MIN_VERSION 0.7.0 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + RECOMMENDED_VERSION 0.7.0 + RECOMMENDED_VERSION_REASON "Latest version tested with OCIO") # pystring # https://github.com/imageworks/pystring ocio_handle_dependency( pystring REQUIRED ALLOW_INSTALL MIN_VERSION 1.1.3 - RECOMMENDED_MIN_VERSION 1.1.3 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + RECOMMENDED_VERSION 1.1.3 + RECOMMENDED_VERSION_REASON "Latest version tested with OCIO") # Imath (>=3.1) # https://github.com/AcademySoftwareFoundation/Imath ocio_handle_dependency( Imath REQUIRED ALLOW_INSTALL MIN_VERSION 3.1.1 - RECOMMENDED_MIN_VERSION 3.1.5 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + RECOMMENDED_VERSION 3.1.5 + RECOMMENDED_VERSION_REASON "Latest version tested with OCIO") ############################################################################### ### ZLIB (https://github.com/madler/zlib) @@ -144,8 +144,8 @@ if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) ocio_handle_dependency( ZLIB REQUIRED ALLOW_INSTALL MIN_VERSION 1.2.10 - RECOMMENDED_MIN_VERSION 1.2.13 - RECOMMENDED_MIN_VERSION_REASON "CVE fixes" + RECOMMENDED_VERSION 1.2.13 + RECOMMENDED_VERSION_REASON "CVE fixes" VERSION_VARS ZLIB_VERSION_STRING ZLIB_VERSION ) # Restore the original find library ordering @@ -173,8 +173,8 @@ endif() # https://github.com/zlib-ng/minizip-ng ocio_handle_dependency( minizip-ng REQUIRED ALLOW_INSTALL MIN_VERSION 3.0.6 - RECOMMENDED_MIN_VERSION 3.0.7 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + RECOMMENDED_VERSION 3.0.7 + RECOMMENDED_VERSION_REASON "Latest version tested with OCIO") ############################################################################### ## @@ -194,8 +194,8 @@ if(OCIO_BUILD_APPS) # https://github.com/mm2/Little-CMS ocio_handle_dependency( lcms2 REQUIRED ALLOW_INSTALL MIN_VERSION 2.2 - RECOMMENDED_MIN_VERSION 2.2 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + RECOMMENDED_VERSION 2.2 + RECOMMENDED_VERSION_REASON "Latest version tested with OCIO") endif() if(OCIO_BUILD_OPENFX) @@ -203,8 +203,8 @@ if(OCIO_BUILD_OPENFX) # https://github.com/ofxa/openfx ocio_handle_dependency( openfx REQUIRED ALLOW_INSTALL MIN_VERSION 1.4 - RECOMMENDED_MIN_VERSION 1.4 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + RECOMMENDED_VERSION 1.4 + RECOMMENDED_VERSION_REASON "Latest version tested with OCIO") endif() if (OCIO_PYTHON_VERSION AND NOT OCIO_BUILD_PYTHON) @@ -231,8 +231,8 @@ if(OCIO_BUILD_PYTHON OR OCIO_BUILD_DOCS) ocio_handle_dependency( Python REQUIRED COMPONENTS ${_Python_COMPONENTS} MIN_VERSION ${OCIO_PYTHON_VERSION} - RECOMMENDED_MIN_VERSION ${OCIO_PYTHON_VERSION} - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + RECOMMENDED_VERSION ${OCIO_PYTHON_VERSION} + RECOMMENDED_VERSION_REASON "Latest version tested with OCIO") if(OCIO_BUILD_PYTHON) # pybind11 @@ -240,8 +240,8 @@ if(OCIO_BUILD_PYTHON OR OCIO_BUILD_DOCS) # pybind11 2.9 fixes issues with MS Visual Studio 2022 (Debug). ocio_handle_dependency( pybind11 REQUIRED ALLOW_INSTALL MIN_VERSION 2.9.2 - RECOMMENDED_MIN_VERSION 2.9.2 - RECOMMENDED_MIN_VERSION_REASON "Pybind 2.10.0+ does not work with Python 2.7 anymore") + RECOMMENDED_VERSION 2.9.2 + RECOMMENDED_VERSION_REASON "Pybind 2.10.0+ does not work with Python 2.7 anymore") endif() endif() @@ -260,7 +260,7 @@ if((OCIO_BUILD_APPS AND OCIO_USE_OIIO_FOR_APPS) OR OCIO_BUILD_TESTS) # config file since 2.1+ and OCIO minimum version is over that. ocio_handle_dependency( OpenImageIO PREFER_CONFIG MIN_VERSION ${OIIO_VERSION} - RECOMMENDED_MIN_VERSION ${OIIO_RECOMMENDED_VERSION} + RECOMMENDED_VERSION ${OIIO_RECOMMENDED_VERSION} PROMOTE_TARGET OpenImageIO::OpenImageIO) endif() @@ -274,8 +274,8 @@ if(OCIO_BUILD_APPS) # https://github.com/AcademySoftwareFoundation/openexr ocio_handle_dependency( OpenEXR REQUIRED PREFER_CONFIG ALLOW_INSTALL MIN_VERSION 3.0.4 - RECOMMENDED_MIN_VERSION 3.1.5 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO" + RECOMMENDED_VERSION 3.1.5 + RECOMMENDED_VERSION_REASON "Latest version tested with OCIO" PROMOTE_TARGET OpenEXR::OpenEXR) if(OpenEXR_FOUND AND TARGET OpenEXR::OpenEXR) @@ -300,8 +300,8 @@ if(OCIO_BUILD_TESTS) # https://github.com/AcademySoftwareFoundation/OpenShadingLanguage ocio_handle_dependency( OSL MIN_VERSION 1.11 - RECOMMENDED_MIN_VERSION 1.11 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + RECOMMENDED_VERSION 1.11 + RECOMMENDED_VERSION_REASON "Latest version tested with OCIO") if(NOT OSL_FOUND) message(WARNING "Skipping build of the OpenShadingLanguage unit tests (OSL missing)") endif() diff --git a/share/cmake/modules/FindImath.cmake b/share/cmake/modules/FindImath.cmake index cb68445dfb..0a465428f4 100644 --- a/share/cmake/modules/FindImath.cmake +++ b/share/cmake/modules/FindImath.cmake @@ -12,9 +12,14 @@ # Global targets defined by this module: # Imath::Imath # -# The dynamic libraries will be located by default. -# By setting Imath_STATIC_LIBRARY variable to TRUE, the search for static libraries will -# be initiated, however it's not guaranteed that they will be located. +# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the +# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# +# If your installation has both static and dynamic libraries present, the dynamic one will be used +# by default. You may set Imath_STATIC_LIBRARY to TRUE to use the static one. If the static one is +# missing, CMake won't find anything even if the variable is set. If only the static one is present, +# that variable is unnecessary. It is ignored if OCIO is installing the library since OCIO builds +# the dependency as static library. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/FindOSL.cmake b/share/cmake/modules/FindOSL.cmake index 185d6df6d6..33f59cc149 100644 --- a/share/cmake/modules/FindOSL.cmake +++ b/share/cmake/modules/FindOSL.cmake @@ -18,7 +18,8 @@ # Global targets defined by this module: # osl::osl # -# The dynamic libraries will be located by default. +# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the +# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findexpat.cmake b/share/cmake/modules/Findexpat.cmake index bfaf36fad2..4855b41042 100644 --- a/share/cmake/modules/Findexpat.cmake +++ b/share/cmake/modules/Findexpat.cmake @@ -12,9 +12,14 @@ # Global targets defined by this module: # expat::expat # -# The dynamic libraries will be located by default. -# By setting expat_STATIC_LIBRARY variable to TRUE, the search for static libraries will -# be initiated, however it's not guaranteed that they will be located. +# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the +# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# +# If your installation has both static and dynamic libraries present, the dynamic one will be used +# by default. You may set expat_STATIC_LIBRARY to TRUE to use the static one. If the static one is +# missing, CMake won't find anything even if the variable is set. If only the static one is present, +# that variable is unnecessary. It is ignored if OCIO is installing the library since OCIO builds +# the dependency as static library. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findlcms2.cmake b/share/cmake/modules/Findlcms2.cmake index 569c2f4920..dd28a9ef02 100644 --- a/share/cmake/modules/Findlcms2.cmake +++ b/share/cmake/modules/Findlcms2.cmake @@ -12,9 +12,14 @@ # Global targets defined by this module: # lcms2::lcms2 - IMPORTED target, if found # -# The dynamic libraries will be located by default. -# By setting lcms2_STATIC_LIBRARY variable to TRUE, the search for static libraries will -# be initiated, however it's not guaranteed that they will be located. +# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the +# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# +# If your installation has both static and dynamic libraries present, the dynamic one will be used +# by default. You may set lcms2_STATIC_LIBRARY to TRUE to use the static one. If the static one is +# missing, CMake won't find anything even if the variable is set. If only the static one is present, +# that variable is unnecessary. It is ignored if OCIO is installing the library since OCIO builds +# the dependency as static library. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findminizip-ng.cmake b/share/cmake/modules/Findminizip-ng.cmake index 032ca96239..5439697591 100644 --- a/share/cmake/modules/Findminizip-ng.cmake +++ b/share/cmake/modules/Findminizip-ng.cmake @@ -12,9 +12,14 @@ # Global targets defined by this module: # MINIZIP::minizip-ng - IMPORTED target, if found # -# The dynamic libraries will be located by default. -# By setting minizip-ng_STATIC_LIBRARY variable to TRUE, the search for static libraries will -# be initiated, however it's not guaranteed that they will be located. +# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the +# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# +# If your installation has both static and dynamic libraries present, the dynamic one will be used +# by default. You may set minizip-ng_STATIC_LIBRARY to TRUE to use the static one. If the static one is +# missing, CMake won't find anything even if the variable is set. If only the static one is present, +# that variable is unnecessary. It is ignored if OCIO is installing the library since OCIO builds +# the dependency as static library. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findopenfx.cmake b/share/cmake/modules/Findopenfx.cmake index 73c7d3a77d..8a44d6534f 100644 --- a/share/cmake/modules/Findopenfx.cmake +++ b/share/cmake/modules/Findopenfx.cmake @@ -11,7 +11,8 @@ # Global targets defined by this module: # openfx::module # -# The dynamic libraries will be located by default. +# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the +# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findpybind11.cmake b/share/cmake/modules/Findpybind11.cmake index c9f0e331ed..bd8c5bfc31 100644 --- a/share/cmake/modules/Findpybind11.cmake +++ b/share/cmake/modules/Findpybind11.cmake @@ -11,7 +11,8 @@ # Global targets defined by this module: # pybind11::module # -# The dynamic libraries will be located by default. +# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the +# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findpystring.cmake b/share/cmake/modules/Findpystring.cmake index e749290bdb..f282cd13d1 100644 --- a/share/cmake/modules/Findpystring.cmake +++ b/share/cmake/modules/Findpystring.cmake @@ -12,7 +12,8 @@ # Global targets defined by this module: # pystring::pystring - IMPORTED target, if found # -# The dynamic libraries will be located by default. +# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the +# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findyaml-cpp.cmake b/share/cmake/modules/Findyaml-cpp.cmake index 3e5181e11d..c330e6c2d6 100644 --- a/share/cmake/modules/Findyaml-cpp.cmake +++ b/share/cmake/modules/Findyaml-cpp.cmake @@ -12,9 +12,14 @@ # Global targets defined by this module: # yaml-cpp # -# The dynamic libraries will be located by default. -# By setting yaml-cpp_STATIC_LIBRARY variable to TRUE, the search for static libraries will -# be initiated, however it's not guaranteed that they will be located. +# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the +# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# +# If your installation has both static and dynamic libraries present, the dynamic one will be used +# by default. You may set yaml-cpp_STATIC_LIBRARY to TRUE to use the static one. If the static one is +# missing, CMake won't find anything even if the variable is set. If only the static one is present, +# that variable is unnecessary. It is ignored if OCIO is installing the library since OCIO builds +# the dependency as static library. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/utils/CheckSupportGL.cmake b/share/cmake/utils/CheckSupportGL.cmake index c5a62f5219..35a1146981 100644 --- a/share/cmake/utils/CheckSupportGL.cmake +++ b/share/cmake/utils/CheckSupportGL.cmake @@ -26,8 +26,8 @@ if((OCIO_BUILD_TESTS AND OCIO_BUILD_GPU_TESTS) OR OCIO_BUILD_APPS) # PREFER_CONFIG assure that config mode will be used first and fallback to module mode. ocio_handle_dependency( GLEW PREFER_CONFIG MIN_VERSION 2.1.0 - RECOMMENDED_MIN_VERSION 2.1.0 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + RECOMMENDED_VERSION 2.1.0 + RECOMMENDED_VERSION_REASON "Latest version tested with OCIO") if(NOT GLEW_FOUND) package_root_message(GLEW) set(OCIO_GL_ENABLED OFF) @@ -71,8 +71,8 @@ if((OCIO_BUILD_TESTS AND OCIO_BUILD_GPU_TESTS) OR OCIO_BUILD_APPS) ocio_handle_dependency( GLUT MIN_VERSION 3.2.1 - RECOMMENDED_MIN_VERSION 3.2.1 - RECOMMENDED_MIN_VERSION_REASON "Latest version tested with OCIO") + RECOMMENDED_VERSION 3.2.1 + RECOMMENDED_VERSION_REASON "Latest version tested with OCIO") if(NOT GLUT_FOUND) package_root_message(GLUT) set(OCIO_GL_ENABLED OFF) From 669b2a641ce83e339c9c370693279f6a61158d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Fri, 3 Feb 2023 11:04:56 -0500 Subject: [PATCH 10/18] Fixing issue with ocio_handle_dependency macro where it wasn't respecting OCIO_INSTALL_EXT_PACKAGES option correctly. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- .../cmake/macros/ocio_handle_dependency.cmake | 220 +++++++++--------- 1 file changed, 115 insertions(+), 105 deletions(-) diff --git a/share/cmake/macros/ocio_handle_dependency.cmake b/share/cmake/macros/ocio_handle_dependency.cmake index 34fca3ec1b..f7bb593561 100644 --- a/share/cmake/macros/ocio_handle_dependency.cmake +++ b/share/cmake/macros/ocio_handle_dependency.cmake @@ -83,137 +83,147 @@ macro (ocio_handle_dependency dep_name) # args ${ARGN}) - set(ocio_dep_QUIET_string "") - # Do not set to QUIET when OCIO_VERBOSE is ON. - if(NOT ocio_dep_VERBOSE AND NOT OCIO_VERBOSE) - set(${dep_name}_FIND_QUIETLY true) - set(ocio_dep_QUIET_string "QUIET") + set(ocio_dep_FORCE_INSTALLATION OFF) + if(ocio_dep_ALLOW_INSTALL AND OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) + set(ocio_dep_FORCE_INSTALLATION ON) endif() + + if(NOT ocio_dep_FORCE_INSTALLATION) + set(ocio_dep_QUIET_string "") + # Do not set to QUIET when OCIO_VERBOSE is ON. + if(NOT ocio_dep_VERBOSE AND NOT OCIO_VERBOSE) + set(${dep_name}_FIND_QUIETLY true) + set(ocio_dep_QUIET_string "QUIET") + endif() - set(ocio_dep_CONFIG_string "") - if(ocio_dep_PREFER_CONFIG) - set(ocio_dep_CONFIG_string "CONFIG") - endif() + set(ocio_dep_CONFIG_string "") + if(ocio_dep_PREFER_CONFIG) + set(ocio_dep_CONFIG_string "CONFIG") + endif() - set(ocio_dep_COMPONENTS_string "") - if(ocio_dep_COMPONENTS) - set(ocio_dep_COMPONENTS_string "COMPONENTS") - endif() + set(ocio_dep_COMPONENTS_string "") + if(ocio_dep_COMPONENTS) + set(ocio_dep_COMPONENTS_string "COMPONENTS") + endif() - if (${dep_name}_FOUND) - # Nothing to do. Already found. - else() - # Try to find the recommended, or higher, version. - # Note that the recommended version should always be specified. - find_package(${dep_name} - ${ocio_dep_RECOMMENDED_VERSION} - ${ocio_dep_CONFIG_string} - ${ocio_dep_COMPONENTS_string} - ${ocio_dep_COMPONENTS} - ${ocio_dep_QUIET_string} - ${ocio_dep_UNPARSED_ARGUMENTS}) - - if (NOT ${dep_name}_FOUND AND ocio_dep_PREFER_CONFIG) - # Try find_package in module mode instead of config mode. + if (${dep_name}_FOUND) + # Nothing to do. Already found. + else() + # Try to find the recommended, or higher, version. + # Note that the recommended version should always be specified. find_package(${dep_name} - ${ocio_dep_RECOMMENDED_VERSION} - ${ocio_dep_COMPONENTS_string} - ${ocio_dep_COMPONENTS} - ${ocio_dep_QUIET_string} - ${ocio_dep_UNPARSED_ARGUMENTS}) - endif() - - if(NOT ${dep_name}_FOUND AND ocio_dep_MIN_VERSION - AND NOT ocio_dep_MIN_VERSION VERSION_EQUAL ocio_dep_MAX_VERSION - AND NOT ocio_dep_MIN_VERSION VERSION_EQUAL ocio_dep_RECOMMENDED_VERSION) - - # if the recommended, or higher, version is not found, try to find dependency with - # the minimum version. - find_package(${dep_name} - ${ocio_dep_MIN_VERSION} - ${ocio_dep_CONFIG_string} - ${ocio_dep_COMPONENTS_string} - ${ocio_dep_COMPONENTS} - ${ocio_dep_QUIET_string} - ${ocio_dep_UNPARSED_ARGUMENTS}) + ${ocio_dep_RECOMMENDED_VERSION} + ${ocio_dep_CONFIG_string} + ${ocio_dep_COMPONENTS_string} + ${ocio_dep_COMPONENTS} + ${ocio_dep_QUIET_string} + ${ocio_dep_UNPARSED_ARGUMENTS}) + if (NOT ${dep_name}_FOUND AND ocio_dep_PREFER_CONFIG) # Try find_package in module mode instead of config mode. - find_package(${dep_name} - ${ocio_dep_MIN_VERSION} + find_package(${dep_name} + ${ocio_dep_RECOMMENDED_VERSION} ${ocio_dep_COMPONENTS_string} ${ocio_dep_COMPONENTS} ${ocio_dep_QUIET_string} ${ocio_dep_UNPARSED_ARGUMENTS}) endif() + + if(NOT ${dep_name}_FOUND AND ocio_dep_MIN_VERSION + AND NOT ocio_dep_MIN_VERSION VERSION_EQUAL ocio_dep_MAX_VERSION + AND NOT ocio_dep_MIN_VERSION VERSION_EQUAL ocio_dep_RECOMMENDED_VERSION) + + # if the recommended, or higher, version is not found, try to find dependency with + # the minimum version. + find_package(${dep_name} + ${ocio_dep_MIN_VERSION} + ${ocio_dep_CONFIG_string} + ${ocio_dep_COMPONENTS_string} + ${ocio_dep_COMPONENTS} + ${ocio_dep_QUIET_string} + ${ocio_dep_UNPARSED_ARGUMENTS}) + if (NOT ${dep_name}_FOUND AND ocio_dep_PREFER_CONFIG) + # Try find_package in module mode instead of config mode. + find_package(${dep_name} + ${ocio_dep_MIN_VERSION} + ${ocio_dep_COMPONENTS_string} + ${ocio_dep_COMPONENTS} + ${ocio_dep_QUIET_string} + ${ocio_dep_UNPARSED_ARGUMENTS}) + endif() + endif() endif() - endif() - - # Check which VERSION_VARS was set by find_package. - set(_VERSION_VAR "${dep_name}_VERSION") - foreach (_vervar ${ocio_dep_VERSION_VARS}) - if(${_vervar}) - set(_VERSION_VAR ${_vervar}) - break() - endif() - endforeach() + + # Check which VERSION_VARS was set by find_package. + set(_VERSION_VAR "${dep_name}_VERSION") + foreach (_vervar ${ocio_dep_VERSION_VARS}) + if(${_vervar}) + set(_VERSION_VAR ${_vervar}) + break() + endif() + endforeach() - if(_VERSION_VAR) - set(ocio_dep_VERSION ${${_VERSION_VAR}}) - endif() + if(_VERSION_VAR) + set(ocio_dep_VERSION ${${_VERSION_VAR}}) + endif() - # Expecting that the minimum and recommended version are always provided. - # Make sure that the version is within the valid range. - if(${dep_name}_FOUND) - if (ocio_dep_VERSION) - # Make sure that the version found is not greater than the maximum version. - if(DEFINED ocio_dep_MAX_VERSION) - if(ocio_dep_VERSION VERSION_GREATER ocio_dep_MAX_VERSION) - # Display it as an error, but do not abort right now. - message(SEND_ERROR "${ColorError}Found ${dep_name} ${ocio_dep_VERSION}, but it is over the maximum version \"${ocio_dep_MAX_VERSION}\" ${ColorReset}") - set(_${dep_name}_found_displayed true) + # Expecting that the minimum and recommended version are always provided. + # Make sure that the version is within the valid range. + if(${dep_name}_FOUND) + if (ocio_dep_VERSION) + # Make sure that the version found is not greater than the maximum version. + if(DEFINED ocio_dep_MAX_VERSION) + if(ocio_dep_VERSION VERSION_GREATER ocio_dep_MAX_VERSION) + # Display it as an error, but do not abort right now. + message(SEND_ERROR "${ColorError}Found ${dep_name} ${ocio_dep_VERSION}, but it is over the maximum version \"${ocio_dep_MAX_VERSION}\" ${ColorReset}") + set(_${dep_name}_found_displayed true) + endif() endif() - endif() - - if(DEFINED ocio_dep_RECOMMENDED_VERSION) - if (ocio_dep_VERSION VERSION_LESS ocio_dep_RECOMMENDED_VERSION) - message(STATUS "${ColorSuccess}Found ${dep_name} (version \"${ocio_dep_VERSION}\") (recommended version: \"${ocio_dep_RECOMMENDED_VERSION}\")${ColorReset}") - if (ocio_dep_RECOMMENDED_VERSION_REASON) - message(STATUS " Reason: ${ocio_dep_RECOMMENDED_VERSION_REASON}") + + if(DEFINED ocio_dep_RECOMMENDED_VERSION) + if (ocio_dep_VERSION VERSION_LESS ocio_dep_RECOMMENDED_VERSION) + message(STATUS "${ColorSuccess}Found ${dep_name} (version \"${ocio_dep_VERSION}\") (recommended version: \"${ocio_dep_RECOMMENDED_VERSION}\")${ColorReset}") + if (ocio_dep_RECOMMENDED_VERSION_REASON) + message(STATUS " Reason: ${ocio_dep_RECOMMENDED_VERSION_REASON}") + endif() + set(_${dep_name}_found_displayed true) endif() - set(_${dep_name}_found_displayed true) endif() - endif() - - if(NOT _${dep_name}_found_displayed) - message(STATUS "${ColorSuccess}Found ${dep_name} (version \"${ocio_dep_VERSION}\")${ColorReset}") + + if(NOT _${dep_name}_found_displayed) + message(STATUS "${ColorSuccess}Found ${dep_name} (version \"${ocio_dep_VERSION}\")${ColorReset}") + endif() + else() + message(STATUS "${ColorSuccess}Found ${dep_name} (no version information)${ColorReset}") endif() else() - message(STATUS "${ColorSuccess}Found ${dep_name} (no version information)${ColorReset}") - endif() - else() - if(ocio_dep_REQUIRED AND NOT ocio_dep_ALLOW_INSTALL) - set(message_color "${ColorError}") - else() - set(message_color "${ColorReset}") - endif() + if(ocio_dep_REQUIRED AND NOT ocio_dep_ALLOW_INSTALL) + set(message_color "${ColorError}") + else() + set(message_color "${ColorReset}") + endif() - ocio_print_versions_error(${dep_name} ${message_color}) + ocio_print_versions_error(${dep_name} ${message_color}) - if(${dep_name}_ROOT) - message(STATUS "${message_color} ${dep_name}_ROOT was: ${${dep_name}_ROOT} ${ColorReset}") - elseif($ENV{${dep_name}_ROOT}) - message(STATUS "${message_color} ENV ${dep_name}_ROOT was: ${${dep_name}_ROOT} ${ColorReset}") - endif() + if(${dep_name}_ROOT) + message(STATUS "${message_color} ${dep_name}_ROOT was: ${${dep_name}_ROOT} ${ColorReset}") + elseif($ENV{${dep_name}_ROOT}) + message(STATUS "${message_color} ENV ${dep_name}_ROOT was: ${${dep_name}_ROOT} ${ColorReset}") + endif() - if(ocio_dep_ALLOW_INSTALL) - ocio_install_dependency(${dep_name} VERSION ${ocio_dep_RECOMMENDED_VERSION}) - endif() + if(ocio_dep_ALLOW_INSTALL) + ocio_install_dependency(${dep_name} VERSION ${ocio_dep_RECOMMENDED_VERSION}) + endif() - if(ocio_dep_REQUIRED) - if(NOT ${dep_name}_FOUND AND NOT ocio_dep_VERSION) - message(SEND_ERROR "${ColorError}${dep_name} is required, will abort at the end.${ColorReset}") + if(ocio_dep_REQUIRED) + if(NOT ${dep_name}_FOUND AND NOT ocio_dep_VERSION) + message(SEND_ERROR "${ColorError}${dep_name} is required, will abort at the end.${ColorReset}") + endif() endif() endif() + elseif(ocio_dep_FORCE_INSTALLATION) + # Skip the search and install dependency right away. + ocio_install_dependency(${dep_name} VERSION ${ocio_dep_RECOMMENDED_VERSION}) endif() if(${dep_name}_FOUND AND ocio_dep_PROMOTE_TARGET) From 76157e3693a6d71d05befd479420f91ef69614c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Wed, 8 Feb 2023 15:16:44 -0500 Subject: [PATCH 11/18] Adding more documentations and dropping support to look for static zlib since the user can update their cmake in order to do that. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- docs/quick_start/installation.rst | 3 +- share/cmake/modules/FindExtPackages.cmake | 140 +++++++----------- share/cmake/modules/FindImath.cmake | 2 +- share/cmake/modules/FindOSL.cmake | 2 +- share/cmake/modules/Findexpat.cmake | 2 +- share/cmake/modules/Findlcms2.cmake | 2 +- share/cmake/modules/Findminizip-ng.cmake | 2 +- share/cmake/modules/Findopenfx.cmake | 2 +- share/cmake/modules/Findpybind11.cmake | 2 +- share/cmake/modules/Findpystring.cmake | 2 +- share/cmake/modules/Findyaml-cpp.cmake | 2 +- .../modules/install/InstallOpenEXR.cmake | 11 +- src/cmake/Config.cmake.in | 53 ------- 13 files changed, 69 insertions(+), 156 deletions(-) diff --git a/docs/quick_start/installation.rst b/docs/quick_start/installation.rst index d8a70fea9b..b30506a8d0 100644 --- a/docs/quick_start/installation.rst +++ b/docs/quick_start/installation.rst @@ -210,7 +210,8 @@ itself. In these cases, it may be helpful to specify an additional CMake variab If ``_STATIC_LIBRARY`` is set, CMake will try to find static version of the dependency. The following package **support** ``-D_STATIC_LIBRARY=ON``: -``expat``, ``yaml-cpp``, ``Imath``, ``lcms2``, ``ZLIB``, and ``minizip-ng``. +``expat``, ``yaml-cpp``, ``Imath``, ``lcms2``, and ``minizip-ng``. Using CMake 3.24+, it is +possible to prefer the static version of ZLIB with ``-DZLIB_USE_STATIC_LIBS=ON``. Rather than using ``_ROOT``, and possibly ``_STATIC_LIBRARY``, you may instead use ``-D_LIBRARY=`` diff --git a/share/cmake/modules/FindExtPackages.cmake b/share/cmake/modules/FindExtPackages.cmake index 72a385449c..351f7fb09f 100644 --- a/share/cmake/modules/FindExtPackages.cmake +++ b/share/cmake/modules/FindExtPackages.cmake @@ -38,7 +38,7 @@ endif() message(STATUS "") message(STATUS "Missing a dependency? Try the following possibilities:") -message(STATUS "If the package provides a configuration file, use -D_DIR=.") +message(STATUS "If the package provides CMake's configuration file, use -D_DIR=.") message(STATUS "If it doesn't provide it, try -D_ROOT=.") message(STATUS "Alternatively, try -D_LIBRARY= and/or -D_INCLUDE_DIR=.") message(STATUS "") @@ -81,92 +81,31 @@ ocio_handle_dependency( Imath REQUIRED ALLOW_INSTALL RECOMMENDED_VERSION_REASON "Latest version tested with OCIO") ############################################################################### -### ZLIB (https://github.com/madler/zlib) -### -### The following variables can be set: -### ZLIB_ROOT Location of ZLIB library file and includes folder. -### Alternatively, ZLIB_LIBRARY and ZLIB_INCLUDE_DIR can be used. -### -### ZLIB_LIBRARY Location of ZLIB library file. -### ZLIB_INCLUDE_DIR Location of ZLIB includes folder. -### -### ZLIB_VERSION ZLIB Version (CMake 3.26+) -### ZLIB_VERSION_STRING ZLIB Version (CMake < 3.26) -### +# ZLIB (https://github.com/madler/zlib) +# +# The following variables can be set: +# ZLIB_ROOT Location of ZLIB library file and includes folder. +# Alternatively, ZLIB_LIBRARY and ZLIB_INCLUDE_DIR can be used. +# +# ZLIB_LIBRARY Location of ZLIB library file. +# ZLIB_INCLUDE_DIR Location of ZLIB includes folder. +# +# ZLIB_VERSION ZLIB Version (CMake 3.26+) +# ZLIB_VERSION_STRING ZLIB Version (CMake < 3.26) +# +# +# ZLIB_USE_STATIC_LIBS Set to ON if static library is prefered (CMake 3.24+) +# ############################################################################### # ZLIB 1.2.13 is used since it fixes a critical vulnerability. # See https://nvd.nist.gov/vuln/detail/CVE-2022-37434 # See https://github.com/madler/zlib/releases/tag/v1.2.13 +ocio_handle_dependency( ZLIB REQUIRED ALLOW_INSTALL + MIN_VERSION 1.2.10 + RECOMMENDED_VERSION 1.2.13 + RECOMMENDED_VERSION_REASON "CVE fixes" + VERSION_VARS ZLIB_VERSION_STRING ZLIB_VERSION ) -if(NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL ALL) - # ZLIB_USE_STATIC_LIBS is supported only from CMake 3.24+. - if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0") - if (ZLIB_STATIC_LIBRARY) - set(ZLIB_USE_STATIC_LIBS "${ZLIB_STATIC_LIBRARY}") - endif() - else() # For CMake < 3.24 since ZLIB_USE_STATIC_LIBS is not available. - if(NOT ZLIB_LIBRARY) - set(_cmake_find_library_x_changed true) - if(DEFINED CMAKE_FIND_LIBRARY_PREFIXES) - set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") - else() - set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES) - endif() - - if(DEFINED CMAKE_FIND_LIBRARY_SUFFIXES) - set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}") - else() - set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) - endif() - - # Prefix/suffix for windows. - if(WIN32) - list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "" "lib") - list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a") - endif() - - # Check if static lib is preferred. - if(ZLIB_STATIC_LIBRARY OR ZLIB_USE_STATIC_LIBS) - if(WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - else() - set(CMAKE_FIND_LIBRARY_SUFFIXES .a) - endif() - endif() - endif() - endif() - - set(_ZLIB_REQUIRED REQUIRED) - # Override REQUIRED if package can be installed - if(OCIO_INSTALL_EXT_PACKAGES STREQUAL MISSING) - set(_ZLIB_REQUIRED "") - endif() - - ocio_handle_dependency( ZLIB REQUIRED ALLOW_INSTALL - MIN_VERSION 1.2.10 - RECOMMENDED_VERSION 1.2.13 - RECOMMENDED_VERSION_REASON "CVE fixes" - VERSION_VARS ZLIB_VERSION_STRING ZLIB_VERSION ) - - # Restore the original find library ordering - if(_cmake_find_library_x_changed) - if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) - set(CMAKE_FIND_LIBRARY_SUFFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}") - else() - set(CMAKE_FIND_LIBRARY_SUFFIXES) - endif() - - if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES) - set(CMAKE_FIND_LIBRARY_PREFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES}") - else() - set(CMAKE_FIND_LIBRARY_PREFIXES) - endif() - endif() -endif() - -if(NOT ZLIB_FOUND) - ocio_install_dependency(ZLIB VERSION 1.2.13) -endif() ############################################################################### # minizip-ng @@ -256,7 +195,21 @@ if((OCIO_BUILD_APPS AND OCIO_USE_OIIO_FOR_APPS) OR OCIO_BUILD_TESTS) # Supported from OIIO 2.4+. Setting this for lower versions doesn't affect anything. set(OPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH 1) - # Only using find_package in CONFIG mode using PREFER_CONFIG option as OIIO support + ############################################################################### + # OpenEXR (https://github.com/AcademySoftwareFoundation/openexr) + # + # Variables defined by OpemImageIO CMake's configuration files: + # OpenImageIO_FOUND - Indicate whether the library was found or not + # OpenImageIO_LIB_DIR - Library's directory + # OpenImageIO_INCLUDE_DIR - Location of the header files + # OpenImageIO_VERSION - Library's version + # + # Imported targets defined by this module, if found: + # OpenImageIO::OpenImageIO + # OpenImageIO::OpenImageIO_Util + # + ############################################################################### + # Calling find_package in CONFIG mode using PREFER_CONFIG option as OIIO support # config file since 2.1+ and OCIO minimum version is over that. ocio_handle_dependency( OpenImageIO PREFER_CONFIG MIN_VERSION ${OIIO_VERSION} @@ -270,8 +223,25 @@ if(OCIO_BUILD_APPS) add_library(OpenColorIO::ImageIOBackend ALIAS OpenImageIO::OpenImageIO) set(OCIO_IMAGE_BACKEND OpenImageIO) else() - # OpenEXR - # https://github.com/AcademySoftwareFoundation/openexr + ############################################################################### + # OpenEXR (https://github.com/AcademySoftwareFoundation/openexr) + # + # Variables defined by OpenEXR CMake's configuration files: + # OpenEXR_FOUND - Indicate whether the library was found or not + # OpenEXR_VERSION - Library's version + # + # Imported targets defined by this module, if found: + # OpenEXR::Iex + # OpenEXR::IexConfig + # OpenEXR::IlmThread + # OpenEXR::IlmThreadConfig + # OpenEXR::OpenEXR + # OpenEXR::OpenEXRConfig + # OpenEXR::OpenEXRCore + # OpenEXR::OpenEXRUtil + # + ############################################################################### + # Calling find_package in CONFIG mode using PREFER_CONFIG option. ocio_handle_dependency( OpenEXR REQUIRED PREFER_CONFIG ALLOW_INSTALL MIN_VERSION 3.0.4 RECOMMENDED_VERSION 3.1.5 diff --git a/share/cmake/modules/FindImath.cmake b/share/cmake/modules/FindImath.cmake index 0a465428f4..4ac608c0f3 100644 --- a/share/cmake/modules/FindImath.cmake +++ b/share/cmake/modules/FindImath.cmake @@ -24,7 +24,7 @@ # If the library is not installed in a standard path, you can do the following the help # the find module: # -# If the package provides a configuration file, use -DImath_DIR=. +# If the package provides CMake's configuration file, use -DImath_DIR=. # If it doesn't provide it, try -DImath_ROOT=. # Alternatively, try -DImath_LIBRARY= and -DImath_INCLUDE_DIR=. # diff --git a/share/cmake/modules/FindOSL.cmake b/share/cmake/modules/FindOSL.cmake index 33f59cc149..80e59b4f08 100644 --- a/share/cmake/modules/FindOSL.cmake +++ b/share/cmake/modules/FindOSL.cmake @@ -24,7 +24,7 @@ # If the library is not installed in a standard path, you can do the following the help # the find module: # -# If the package provides a configuration file, use -DOpenShadingLanguage_DIR=. +# If the package provides CMake's configuration file, use -DOpenShadingLanguage_DIR=. # If it doesn't provide it, try -DOpenShadingLanguage_ROOT=. # diff --git a/share/cmake/modules/Findexpat.cmake b/share/cmake/modules/Findexpat.cmake index 4855b41042..95b146357b 100644 --- a/share/cmake/modules/Findexpat.cmake +++ b/share/cmake/modules/Findexpat.cmake @@ -24,7 +24,7 @@ # If the library is not installed in a standard path, you can do the following the help # the find module: # -# If the package provides a configuration file, use -Dexpat_DIR=. +# If the package provides CMake's configuration file, use -Dexpat_DIR=. # If it doesn't provide it, try -Dexpat_ROOT=. # Alternatively, try -Dexpat_LIBRARY= and -Dexpat_INCLUDE_DIR=. # diff --git a/share/cmake/modules/Findlcms2.cmake b/share/cmake/modules/Findlcms2.cmake index dd28a9ef02..d6aac0253e 100644 --- a/share/cmake/modules/Findlcms2.cmake +++ b/share/cmake/modules/Findlcms2.cmake @@ -24,7 +24,7 @@ # If the library is not installed in a standard path, you can do the following the help # the find module: # -# If the package provides a configuration file, use -Dlcms2_DIR=. +# If the package provides CMake's configuration file, use -Dlcms2_DIR=. # If it doesn't provide it, try -Dlcms2_ROOT=. # Alternatively, try -Dlcms2_LIBRARY= and -Dlcms2_INCLUDE_DIR=. # diff --git a/share/cmake/modules/Findminizip-ng.cmake b/share/cmake/modules/Findminizip-ng.cmake index 5439697591..d2332f785f 100644 --- a/share/cmake/modules/Findminizip-ng.cmake +++ b/share/cmake/modules/Findminizip-ng.cmake @@ -24,7 +24,7 @@ # If the library is not installed in a standard path, you can do the following the help # the find module: # -# If the package provides a configuration file, use -Dminizip-ng_DIR=. +# If the package provides CMake's configuration file, use -Dminizip-ng_DIR=. # If it doesn't provide it, try -Dminizip-ng_ROOT=. # Alternatively, try -Dminizip-ng_LIBRARY= and -Dminizip-ng_INCLUDE_DIR=. # diff --git a/share/cmake/modules/Findopenfx.cmake b/share/cmake/modules/Findopenfx.cmake index 8a44d6534f..d1debb1a19 100644 --- a/share/cmake/modules/Findopenfx.cmake +++ b/share/cmake/modules/Findopenfx.cmake @@ -17,7 +17,7 @@ # If the library is not installed in a standard path, you can do the following the help # the find module: # -# If the package provides a configuration file, use -Dopenfx_DIR=. +# If the package provides CMake's configuration file, use -Dopenfx_DIR=. # If it doesn't provide it, try -Dopenfx_ROOT=. # Alternatively, try -Dopenfx_LIBRARY= and -Dopenfx_INCLUDE_DIR=. # diff --git a/share/cmake/modules/Findpybind11.cmake b/share/cmake/modules/Findpybind11.cmake index bd8c5bfc31..4cf2b59813 100644 --- a/share/cmake/modules/Findpybind11.cmake +++ b/share/cmake/modules/Findpybind11.cmake @@ -17,7 +17,7 @@ # If the library is not installed in a standard path, you can do the following the help # the find module: # -# If the package provides a configuration file, use -Dpybind11_DIR=. +# If the package provides CMake's configuration file, use -Dpybind11_DIR=. # If it doesn't provide it, try -Dpybind11_ROOT=. # Alternatively, try -Dpybind11_INCLUDE_DIR=. # diff --git a/share/cmake/modules/Findpystring.cmake b/share/cmake/modules/Findpystring.cmake index f282cd13d1..d66ddf87a9 100644 --- a/share/cmake/modules/Findpystring.cmake +++ b/share/cmake/modules/Findpystring.cmake @@ -18,7 +18,7 @@ # If the library is not installed in a standard path, you can do the following the help # the find module: # -# If the package provides a configuration file, use -Dpystring_DIR=. +# If the package provides CMake's configuration file, use -Dpystring_DIR=. # If it doesn't provide it, try -Dpystring_ROOT=. # Alternatively, try -Dpystring_LIBRARY= and -Dpystring_INCLUDE_DIR=. # diff --git a/share/cmake/modules/Findyaml-cpp.cmake b/share/cmake/modules/Findyaml-cpp.cmake index c330e6c2d6..c7fbd69f4e 100644 --- a/share/cmake/modules/Findyaml-cpp.cmake +++ b/share/cmake/modules/Findyaml-cpp.cmake @@ -24,7 +24,7 @@ # If the library is not installed in a standard path, you can do the following the help # the find module: # -# If the package provides a configuration file, use -Dyamp-cppDIR=. +# If the package provides CMake's configuration file, use -Dyamp-cppDIR=. # If it doesn't provide it, try -Dyamp-cppROOT=. # Alternatively, try -Dyamp-cppLIBRARY= and -Dyamp-cppINCLUDE_DIR=. # diff --git a/share/cmake/modules/install/InstallOpenEXR.cmake b/share/cmake/modules/install/InstallOpenEXR.cmake index ef74389faa..23b6fdfb6c 100644 --- a/share/cmake/modules/install/InstallOpenEXR.cmake +++ b/share/cmake/modules/install/InstallOpenEXR.cmake @@ -48,15 +48,10 @@ if(NOT OpenEXR_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACK set(_EXT_BUILD_ROOT "${CMAKE_BINARY_DIR}/ext/build") # Required dependency + # Not trying to find ZLIB here since it is a required dependency of OCIO. if(NOT ZLIB_FOUND) - # ZLIB is required for OCIO too. - # Try to find ZLIB without specifying a version since at this point in the dependencies - # check, ZLIB should already be found. If not, the configure step will fail either way. - ocio_handle_dependency(ZLIB VERSION_VARS ZLIB_VERSION_STRING ZLIB_VERSION) - if(NOT ZLIB_FOUND) - message(STATUS "ZLIB is required to build OpenEXR.") - return() - endif() + message(STATUS "ZLIB is required to build OpenEXR.") + return() endif() ocio_handle_dependency(Threads) diff --git a/src/cmake/Config.cmake.in b/src/cmake/Config.cmake.in index 7910959c3f..a3b03cc83d 100644 --- a/src/cmake/Config.cmake.in +++ b/src/cmake/Config.cmake.in @@ -54,65 +54,12 @@ if (NOT @BUILD_SHARED_LIBS@) # NOT @BUILD_SHARED_LIBS@ # ZLIB_VERSION is available starting CMake 3.26+. # ZLIB_VERSION_STRING is still available for backward compatibility. # See https://cmake.org/cmake/help/git-stage/module/FindZLIB.html - - # ZLIB_USE_STATIC_LIBS is supported only from CMake 3.24+. - if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24.0") - if (ZLIB_STATIC_LIBRARY) - set(ZLIB_USE_STATIC_LIBS "${ZLIB_STATIC_LIBRARY}") - endif() - else() # For CMake < 3.24 since ZLIB_USE_STATIC_LIBS is not available. - if(NOT ZLIB_LIBRARY) - set(_cmake_find_library_x_changed true) - if(DEFINED CMAKE_FIND_LIBRARY_PREFIXES) - set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}") - else() - set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES) - endif() - - if(DEFINED CMAKE_FIND_LIBRARY_SUFFIXES) - set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_FIND_LIBRARY_SUFFIXES}") - else() - set(_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) - endif() - - # Prefix/suffix for windows. - if(WIN32) - list(APPEND CMAKE_FIND_LIBRARY_PREFIXES "" "lib") - list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES ".dll.a") - endif() - - # Check if static lib is preferred. - if(ZLIB_STATIC_LIBRARY OR ZLIB_USE_STATIC_LIBS) - if(WIN32) - set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) - else() - set(CMAKE_FIND_LIBRARY_SUFFIXES .a) - endif() - endif() - endif() - endif() - if (@ZLIB_VERSION@) # @ZLIB_VERSION@ find_dependency(ZLIB @ZLIB_VERSION@) else() find_dependency(ZLIB @ZLIB_VERSION_STRING@) endif() - - if(_cmake_find_library_x_changed) - # Restore the original find library ordering - if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES) - set(CMAKE_FIND_LIBRARY_SUFFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}") - else() - set(CMAKE_FIND_LIBRARY_SUFFIXES) - endif() - - if(DEFINED _ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES) - set(CMAKE_FIND_LIBRARY_PREFIXES "${_ZLIB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES}") - else() - set(CMAKE_FIND_LIBRARY_PREFIXES) - endif() - endif() endif() if (NOT MINIZIP::minizip-ng) From 8f2f41ab029b346ebbb3e900431c40408a79f1cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Mon, 20 Feb 2023 10:21:07 -0500 Subject: [PATCH 12/18] Documentations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- docs/quick_start/installation.rst | 46 +++++++++--------------- share/cmake/modules/FindImath.cmake | 11 +++--- share/cmake/modules/FindOSL.cmake | 3 +- share/cmake/modules/Findexpat.cmake | 11 +++--- share/cmake/modules/Findlcms2.cmake | 14 +++----- share/cmake/modules/Findminizip-ng.cmake | 11 +++--- share/cmake/modules/Findopenfx.cmake | 7 ++-- share/cmake/modules/Findpybind11.cmake | 3 +- share/cmake/modules/Findpystring.cmake | 6 ++-- share/cmake/modules/Findyaml-cpp.cmake | 17 ++++----- 10 files changed, 47 insertions(+), 82 deletions(-) diff --git a/docs/quick_start/installation.rst b/docs/quick_start/installation.rst index b30506a8d0..fc6e357b92 100644 --- a/docs/quick_start/installation.rst +++ b/docs/quick_start/installation.rst @@ -187,41 +187,29 @@ Three ``OCIO_INSTALL_EXT_PACKAGES`` options are available:: Existing Install Hints ++++++++++++++++++++++ -The recommended way to find a dependency is by using their configuration file. Most dependencies -provides those files. These configuration files sets all the necessary targets and variables. -CMake needs to know where to find these configuration files. If CMake doesn't find them in any of -the default locations, you may use the variable ``-D_DIR=``. - -Note that ``lcms2``, ``openfx``, ``pystring`` and ``sphinx`` does **not** support ``_DIR``. - -Alternative methods exist to aid CMake in locating dependencies, but they should only be used in specific -situations, such as when attempting to help CMake find dependencies that do not have configuration -files available or when the static version of a dependency is needed. +By default, dynamic libraries are given priority over static libraries. You may set ``_STATIC_LIBRARY`` +to ``ON`` to prefer the use static library for the following +packages: ``expat``, ``yaml-cpp``, ``Imath``, ``lcms2``, and ``minizip-ng``. Using CMake 3.24+, it is +possible to prefer the static version of ZLIB with ``-DZLIB_USE_STATIC_LIBS=ON``. -An alternative method is using the CMake variable ``-D_ROOT=``. That -variable may be used to specify the path to the include and library root directory. +If the static library the only one available, that variable does not need to be specified. +It is ignored if OCIO is installing the library since OCIO builds the dependency as static library. -Note that ``OpenImageIO`` and ``OpenEXR`` does **not** support ``_ROOT``. +If the library is not installed in a standard path, you can do the following the help +the find module: -There are scenarios in which some of the dependencies may not be compiled into an -OCIO dynamic library. This is more likely when OCIO does not download the packages -itself. In these cases, it may be helpful to specify an additional CMake variable. While using -``_ROOT``, some dependencies allows the usage of ``-D_STATIC_LIBRARY=ON``. -If ``_STATIC_LIBRARY`` is set, CMake will try to find static version of the dependency. +The recommended way is to specify the CMake's configurations files by using ``-D_DIR=``. +This method is supported by ``expat``, ``Imath``, ``lcms2``, ``ZLIB``, ``minizip-ng``, ``openfx``, +``OSL``, ``pybind11``, ``pystring``, ``yaml-cpp``, ``OpenEXR`` and ``OpenImageIO``. -The following package **support** ``-D_STATIC_LIBRARY=ON``: -``expat``, ``yaml-cpp``, ``Imath``, ``lcms2``, and ``minizip-ng``. Using CMake 3.24+, it is -possible to prefer the static version of ZLIB with ``-DZLIB_USE_STATIC_LIBS=ON``. +If the package does not provide a configuration file, you can try to specify the folder where the +libraries and includes files are. This can be done by using ``-D_ROOT=`` +or by specifying the libraries and includes paths individually by using +``-D_LIBRARY=`` and ``-D_INCLUDE_DIR=``. -Rather than using ``_ROOT``, and possibly ``_STATIC_LIBRARY``, you may -instead use ``-D_LIBRARY=`` -and ``-D_INCLUDE_DIR=``. In this case, the library path will -control whether a static or dynamic library is used. It may also be used to handle situations where -the library and/or include files are not in the typical location relative to the root directory. +These two methods are supported by ``expat``, ``Imath``, ``lcms2``, ``ZLIB``, ``minizip-ng``, ``openfx``, +``OSL``, ``pybind11``, ``pystring`` and ``yaml-cpp``. -The following package **support** ``_LIBRARY`` and ``_INCLUDE_DIR``: -``expat``, ``yaml-cpp``, ``Imath``, ``lcms2``, ``openfx``, ``OSL``, ``pybind11``, ``pystring``, -``yaml-cpp``, ``ZLIB``, and ``minizip-ng``. The package names used by OCIO are as follows (note that these are case-sensitive): diff --git a/share/cmake/modules/FindImath.cmake b/share/cmake/modules/FindImath.cmake index 4ac608c0f3..2b7805fcb4 100644 --- a/share/cmake/modules/FindImath.cmake +++ b/share/cmake/modules/FindImath.cmake @@ -12,14 +12,11 @@ # Global targets defined by this module: # Imath::Imath # -# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the -# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# By default, dynamic libraries are given priority over static libraries # -# If your installation has both static and dynamic libraries present, the dynamic one will be used -# by default. You may set Imath_STATIC_LIBRARY to TRUE to use the static one. If the static one is -# missing, CMake won't find anything even if the variable is set. If only the static one is present, -# that variable is unnecessary. It is ignored if OCIO is installing the library since OCIO builds -# the dependency as static library. +# You may set Imath_STATIC_LIBRARY to TRUE to prefer the use static library. +# If the static library the only one available, that variable does not need to be specified. +# It is ignored if OCIO is installing the library since OCIO builds the dependency as static library. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/FindOSL.cmake b/share/cmake/modules/FindOSL.cmake index 80e59b4f08..cfc2b41aac 100644 --- a/share/cmake/modules/FindOSL.cmake +++ b/share/cmake/modules/FindOSL.cmake @@ -18,8 +18,7 @@ # Global targets defined by this module: # osl::osl # -# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the -# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# By default, dynamic libraries are given priority over static libraries # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findexpat.cmake b/share/cmake/modules/Findexpat.cmake index 95b146357b..1846e42f22 100644 --- a/share/cmake/modules/Findexpat.cmake +++ b/share/cmake/modules/Findexpat.cmake @@ -12,14 +12,11 @@ # Global targets defined by this module: # expat::expat # -# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the -# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# By default, dynamic libraries are given priority over static libraries # -# If your installation has both static and dynamic libraries present, the dynamic one will be used -# by default. You may set expat_STATIC_LIBRARY to TRUE to use the static one. If the static one is -# missing, CMake won't find anything even if the variable is set. If only the static one is present, -# that variable is unnecessary. It is ignored if OCIO is installing the library since OCIO builds -# the dependency as static library. +# You may set expat_STATIC_LIBRARY to TRUE to prefer the use static library. +# If the static library the only one available, that variable does not need to be specified. +# It is ignored if OCIO is installing the library since OCIO builds the dependency as static library. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findlcms2.cmake b/share/cmake/modules/Findlcms2.cmake index d6aac0253e..4c5e6c809c 100644 --- a/share/cmake/modules/Findlcms2.cmake +++ b/share/cmake/modules/Findlcms2.cmake @@ -12,20 +12,16 @@ # Global targets defined by this module: # lcms2::lcms2 - IMPORTED target, if found # -# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the -# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# By default, dynamic libraries are given priority over static libraries # -# If your installation has both static and dynamic libraries present, the dynamic one will be used -# by default. You may set lcms2_STATIC_LIBRARY to TRUE to use the static one. If the static one is -# missing, CMake won't find anything even if the variable is set. If only the static one is present, -# that variable is unnecessary. It is ignored if OCIO is installing the library since OCIO builds -# the dependency as static library. +# You may set lcsm2_STATIC_LIBRARY to TRUE to prefer the use static library. +# If the static library the only one available, that variable does not need to be specified. +# It is ignored if OCIO is installing the library since OCIO builds the dependency as static library. # # If the library is not installed in a standard path, you can do the following the help # the find module: # -# If the package provides CMake's configuration file, use -Dlcms2_DIR=. -# If it doesn't provide it, try -Dlcms2_ROOT=. +# Try -Dlcms2_ROOT=. # Alternatively, try -Dlcms2_LIBRARY= and -Dlcms2_INCLUDE_DIR=. # diff --git a/share/cmake/modules/Findminizip-ng.cmake b/share/cmake/modules/Findminizip-ng.cmake index d2332f785f..24679a818d 100644 --- a/share/cmake/modules/Findminizip-ng.cmake +++ b/share/cmake/modules/Findminizip-ng.cmake @@ -12,14 +12,11 @@ # Global targets defined by this module: # MINIZIP::minizip-ng - IMPORTED target, if found # -# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the -# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# By default, dynamic libraries are given priority over static libraries # -# If your installation has both static and dynamic libraries present, the dynamic one will be used -# by default. You may set minizip-ng_STATIC_LIBRARY to TRUE to use the static one. If the static one is -# missing, CMake won't find anything even if the variable is set. If only the static one is present, -# that variable is unnecessary. It is ignored if OCIO is installing the library since OCIO builds -# the dependency as static library. +# You may set minizip-ng_STATIC_LIBRARY to TRUE to prefer the use static library. +# If the static library the only one available, that variable does not need to be specified. +# It is ignored if OCIO is installing the library since OCIO builds the dependency as static library. # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findopenfx.cmake b/share/cmake/modules/Findopenfx.cmake index d1debb1a19..7d0e797797 100644 --- a/share/cmake/modules/Findopenfx.cmake +++ b/share/cmake/modules/Findopenfx.cmake @@ -11,15 +11,12 @@ # Global targets defined by this module: # openfx::module # -# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the -# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# By default, dynamic libraries are given priority over static libraries # # If the library is not installed in a standard path, you can do the following the help # the find module: # -# If the package provides CMake's configuration file, use -Dopenfx_DIR=. -# If it doesn't provide it, try -Dopenfx_ROOT=. -# Alternatively, try -Dopenfx_LIBRARY= and -Dopenfx_INCLUDE_DIR=. +# If it doesn't provide it, try -Dopenfx_ROOT=. # ############################################################################### diff --git a/share/cmake/modules/Findpybind11.cmake b/share/cmake/modules/Findpybind11.cmake index 4cf2b59813..6c9cc4f279 100644 --- a/share/cmake/modules/Findpybind11.cmake +++ b/share/cmake/modules/Findpybind11.cmake @@ -11,8 +11,7 @@ # Global targets defined by this module: # pybind11::module # -# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the -# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# By default, dynamic libraries are given priority over static libraries # # If the library is not installed in a standard path, you can do the following the help # the find module: diff --git a/share/cmake/modules/Findpystring.cmake b/share/cmake/modules/Findpystring.cmake index d66ddf87a9..1f34f9f2cd 100644 --- a/share/cmake/modules/Findpystring.cmake +++ b/share/cmake/modules/Findpystring.cmake @@ -12,14 +12,12 @@ # Global targets defined by this module: # pystring::pystring - IMPORTED target, if found # -# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the -# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# By default, dynamic libraries are given priority over static libraries # # If the library is not installed in a standard path, you can do the following the help # the find module: # -# If the package provides CMake's configuration file, use -Dpystring_DIR=. -# If it doesn't provide it, try -Dpystring_ROOT=. +# Try -Dpystring_ROOT=. # Alternatively, try -Dpystring_LIBRARY= and -Dpystring_INCLUDE_DIR=. # diff --git a/share/cmake/modules/Findyaml-cpp.cmake b/share/cmake/modules/Findyaml-cpp.cmake index c7fbd69f4e..7c6cedf58d 100644 --- a/share/cmake/modules/Findyaml-cpp.cmake +++ b/share/cmake/modules/Findyaml-cpp.cmake @@ -12,21 +12,18 @@ # Global targets defined by this module: # yaml-cpp # -# The libraries files are search based on the CMake variable CMAKE_FIND_LIBRARY_SUFFIXES. On the -# majority of operating systems, the dynamic libaries are prefered first, and then static libraries. +# By default, dynamic libraries are given priority over static libraries # -# If your installation has both static and dynamic libraries present, the dynamic one will be used -# by default. You may set yaml-cpp_STATIC_LIBRARY to TRUE to use the static one. If the static one is -# missing, CMake won't find anything even if the variable is set. If only the static one is present, -# that variable is unnecessary. It is ignored if OCIO is installing the library since OCIO builds -# the dependency as static library. +# You may set yaml-cpp_STATIC_LIBRARY to TRUE to prefer the use static library. +# If the static library the only one available, that variable does not need to be specified. +# It is ignored if OCIO is installing the library since OCIO builds the dependency as static library. # # If the library is not installed in a standard path, you can do the following the help # the find module: # -# If the package provides CMake's configuration file, use -Dyamp-cppDIR=. -# If it doesn't provide it, try -Dyamp-cppROOT=. -# Alternatively, try -Dyamp-cppLIBRARY= and -Dyamp-cppINCLUDE_DIR=. +# If the package provides CMake's configuration file, use -Dyamp-cpp_DIR=. +# If it doesn't provide it, try -Dyamp-cpp_ROOT=. +# Alternatively, try -Dyamp-cpp_LIBRARY= and -Dyamp-cpp_INCLUDE_DIR=. # ############################################################################### From a4f78c56338be23f5cc0815c040f3ba1a5f0f836 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Wed, 22 Feb 2023 10:07:38 -0500 Subject: [PATCH 13/18] Documentations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- docs/quick_start/installation.rst | 35 +++++++++--------------- share/cmake/modules/FindImath.cmake | 20 ++++++-------- share/cmake/modules/FindOSL.cmake | 11 ++++---- share/cmake/modules/FindSphinx.cmake | 11 ++++---- share/cmake/modules/Findexpat.cmake | 20 ++++++-------- share/cmake/modules/Findlcms2.cmake | 18 ++++++------ share/cmake/modules/Findminizip-ng.cmake | 19 ++++++------- share/cmake/modules/Findopenfx.cmake | 9 +++--- share/cmake/modules/Findpybind11.cmake | 13 ++++----- share/cmake/modules/Findpystring.cmake | 12 ++++---- share/cmake/modules/Findyaml-cpp.cmake | 20 ++++++-------- 11 files changed, 83 insertions(+), 105 deletions(-) diff --git a/docs/quick_start/installation.rst b/docs/quick_start/installation.rst index fc6e357b92..788ae7e16b 100644 --- a/docs/quick_start/installation.rst +++ b/docs/quick_start/installation.rst @@ -187,29 +187,24 @@ Three ``OCIO_INSTALL_EXT_PACKAGES`` options are available:: Existing Install Hints ++++++++++++++++++++++ -By default, dynamic libraries are given priority over static libraries. You may set ``_STATIC_LIBRARY`` -to ``ON`` to prefer the use static library for the following -packages: ``expat``, ``yaml-cpp``, ``Imath``, ``lcms2``, and ``minizip-ng``. Using CMake 3.24+, it is -possible to prefer the static version of ZLIB with ``-DZLIB_USE_STATIC_LIBS=ON``. +If the library is not installed in a typical location where CMake will find it, +you may specify the location using one of the following methods: -If the static library the only one available, that variable does not need to be specified. -It is ignored if OCIO is installing the library since OCIO builds the dependency as static library. +- Set ``-D_DIR`` to point to the directory containing the CMake configuration file for the package. -If the library is not installed in a standard path, you can do the following the help -the find module: +- Set ``-D_ROOT`` to point to the directory containing the lib and include directories. -The recommended way is to specify the CMake's configurations files by using ``-D_DIR=``. -This method is supported by ``expat``, ``Imath``, ``lcms2``, ``ZLIB``, ``minizip-ng``, ``openfx``, -``OSL``, ``pybind11``, ``pystring``, ``yaml-cpp``, ``OpenEXR`` and ``OpenImageIO``. +- Set ``-D_LIBRARY`` and ``-D_INCLUDE_DIR`` to point to the lib and include directories. -If the package does not provide a configuration file, you can try to specify the folder where the -libraries and includes files are. This can be done by using ``-D_ROOT=`` -or by specifying the libraries and includes paths individually by using -``-D_LIBRARY=`` and ``-D_INCLUDE_DIR=``. - -These two methods are supported by ``expat``, ``Imath``, ``lcms2``, ``ZLIB``, ``minizip-ng``, ``openfx``, -``OSL``, ``pybind11``, ``pystring`` and ``yaml-cpp``. +Not all packages support all of the above options. Please refer the +OCIO CMake `find modules `_ for the package that you are having trouble with to see the options it supports. +Usually CMake will use the dynamic library rather than static, if both are present. In this case, +you may set _STATIC_LIBRARY to ON to request use of the static one. If only the +static library is present (such as when OCIO builds the dependency), then the option is not needed. +The following packages support this option: +``expat``, ``yaml-cpp``, ``Imath``, ``lcms2``, and ``minizip-ng``. Using CMake 3.24+, it is +possible to prefer the static version of ``ZLIB`` with ``-DZLIB_USE_STATIC_LIBS=ON``. The package names used by OCIO are as follows (note that these are case-sensitive): @@ -243,10 +238,6 @@ from various package managers (e.g., Homebrew) probably won't work. Please see settings that begin with ``-DMZ_`` that are used in the OCIO `minizip-ng find module. `_ -The OCIO `CMake find modules `_ -may be consulted for more detail on the handling of a given package and the CMake -variables it uses. - Please note that if you build a static OCIO library, it will not contain the libraries for the external packages and so you will need to list those separately when linking your client application. If you had OCIO download and build these packages, you will diff --git a/share/cmake/modules/FindImath.cmake b/share/cmake/modules/FindImath.cmake index 2b7805fcb4..6126b934f7 100644 --- a/share/cmake/modules/FindImath.cmake +++ b/share/cmake/modules/FindImath.cmake @@ -12,18 +12,16 @@ # Global targets defined by this module: # Imath::Imath # -# By default, dynamic libraries are given priority over static libraries +# Usually CMake will use the dynamic library rather than static, if both are present. +# In this case, you may set Imath_STATIC_LIBRARY to ON to request use of the static one. +# If only the static library is present (such as when OCIO builds the dependency), then the option +# is not needed. # -# You may set Imath_STATIC_LIBRARY to TRUE to prefer the use static library. -# If the static library the only one available, that variable does not need to be specified. -# It is ignored if OCIO is installing the library since OCIO builds the dependency as static library. -# -# If the library is not installed in a standard path, you can do the following the help -# the find module: -# -# If the package provides CMake's configuration file, use -DImath_DIR=. -# If it doesn't provide it, try -DImath_ROOT=. -# Alternatively, try -DImath_LIBRARY= and -DImath_INCLUDE_DIR=. +# If the library is not installed in a typical location where CMake will find it, you may specify +# the location using one of the following methods: +# -- Set -DImath_DIR to point to the directory containing the CMake configuration file for the package. +# -- Set -DImath_ROOT to point to the directory containing the lib and include directories. +# -- Set -DImath_LIBRARY and -DImath_INCLUDE_DIR to point to the lib and include directories. # ############################################################################### diff --git a/share/cmake/modules/FindOSL.cmake b/share/cmake/modules/FindOSL.cmake index cfc2b41aac..5cefe410bc 100644 --- a/share/cmake/modules/FindOSL.cmake +++ b/share/cmake/modules/FindOSL.cmake @@ -18,13 +18,12 @@ # Global targets defined by this module: # osl::osl # -# By default, dynamic libraries are given priority over static libraries +# Usually CMake will use the dynamic library rather than static, if both are present. # -# If the library is not installed in a standard path, you can do the following the help -# the find module: -# -# If the package provides CMake's configuration file, use -DOpenShadingLanguage_DIR=. -# If it doesn't provide it, try -DOpenShadingLanguage_ROOT=. +# If the library is not installed in a typical location where CMake will find it, you may specify +# the location using one of the following methods: +# -- Set -DOpenShadingLanguage_DIR to point to the directory containing the CMake configuration file for the package. +# -- Set -DOpenShadingLanguage_ROOT to point to the directory containing the lib and include directories. # ############################################################################### diff --git a/share/cmake/modules/FindSphinx.cmake b/share/cmake/modules/FindSphinx.cmake index 768874eec4..686c9b5fdf 100644 --- a/share/cmake/modules/FindSphinx.cmake +++ b/share/cmake/modules/FindSphinx.cmake @@ -4,15 +4,14 @@ # Locate Sphinx (Python documentation generator) # # Variables defined by this module: -# Sphinx_FOUND - Indicate whether the library was found or not +# Sphinx_FOUND - Indicate whether the executable was found or not # Sphinx_EXECUTABLE - Path to the executable file # # -# If the executable is not installed in a standard path, you can do the following the help -# the find module: -# -# Try -DSphinx_ROOT=. -# Alternatively, try -DSphinx_EXECUTABLE=. +# If the executable is not installed in a typical location where CMake will find it, you may specify +# the location using one of the following methods: +# -- Set -Dlcms2_ROOT to point to the directory containing the executable. +# -- Set -DSphinx_EXECUTABLE to point to executable file. # find_package(Python QUIET COMPONENTS Interpreter) diff --git a/share/cmake/modules/Findexpat.cmake b/share/cmake/modules/Findexpat.cmake index 1846e42f22..1e715bb0cf 100644 --- a/share/cmake/modules/Findexpat.cmake +++ b/share/cmake/modules/Findexpat.cmake @@ -12,18 +12,16 @@ # Global targets defined by this module: # expat::expat # -# By default, dynamic libraries are given priority over static libraries +# Usually CMake will use the dynamic library rather than static, if both are present. +# In this case, you may set expat_STATIC_LIBRARY to ON to request use of the static one. +# If only the static library is present (such as when OCIO builds the dependency), then the option +# is not needed. # -# You may set expat_STATIC_LIBRARY to TRUE to prefer the use static library. -# If the static library the only one available, that variable does not need to be specified. -# It is ignored if OCIO is installing the library since OCIO builds the dependency as static library. -# -# If the library is not installed in a standard path, you can do the following the help -# the find module: -# -# If the package provides CMake's configuration file, use -Dexpat_DIR=. -# If it doesn't provide it, try -Dexpat_ROOT=. -# Alternatively, try -Dexpat_LIBRARY= and -Dexpat_INCLUDE_DIR=. +# If the library is not installed in a typical location where CMake will find it, you may specify +# the location using one of the following methods: +# -- Set -Dexpat_DIR to point to the directory containing the CMake configuration file for the package. +# -- Set -Dexpat_ROOT to point to the directory containing the lib and include directories. +# -- Set -Dexpat_LIBRARY and -Dexpat_INCLUDE_DIR to point to the lib and include directories. # ############################################################################### diff --git a/share/cmake/modules/Findlcms2.cmake b/share/cmake/modules/Findlcms2.cmake index 4c5e6c809c..8183376330 100644 --- a/share/cmake/modules/Findlcms2.cmake +++ b/share/cmake/modules/Findlcms2.cmake @@ -12,17 +12,15 @@ # Global targets defined by this module: # lcms2::lcms2 - IMPORTED target, if found # -# By default, dynamic libraries are given priority over static libraries +# Usually CMake will use the dynamic library rather than static, if both are present. +# In this case, you may set lcms2_STATIC_LIBRARY to ON to request use of the static one. +# If only the static library is present (such as when OCIO builds the dependency), then the option +# is not needed. # -# You may set lcsm2_STATIC_LIBRARY to TRUE to prefer the use static library. -# If the static library the only one available, that variable does not need to be specified. -# It is ignored if OCIO is installing the library since OCIO builds the dependency as static library. -# -# If the library is not installed in a standard path, you can do the following the help -# the find module: -# -# Try -Dlcms2_ROOT=. -# Alternatively, try -Dlcms2_LIBRARY= and -Dlcms2_INCLUDE_DIR=. +# If the library is not installed in a typical location where CMake will find it, you may specify +# the location using one of the following methods: +# -- Set -Dlcms2_ROOT to point to the directory containing the lib and include directories. +# -- Set -Dlcms2_LIBRARY and -Dlcms2_INCLUDE_DIR to point to the lib and include directories. # ############################################################################### diff --git a/share/cmake/modules/Findminizip-ng.cmake b/share/cmake/modules/Findminizip-ng.cmake index 24679a818d..4d66093839 100644 --- a/share/cmake/modules/Findminizip-ng.cmake +++ b/share/cmake/modules/Findminizip-ng.cmake @@ -12,18 +12,17 @@ # Global targets defined by this module: # MINIZIP::minizip-ng - IMPORTED target, if found # -# By default, dynamic libraries are given priority over static libraries +# Usually CMake will use the dynamic library rather than static, if both are present. +# In this case, you may set minizip-ng_STATIC_LIBRARY to ON to request use of the static one. +# If only the static library is present (such as when OCIO builds the dependency), then the option +# is not needed. # -# You may set minizip-ng_STATIC_LIBRARY to TRUE to prefer the use static library. -# If the static library the only one available, that variable does not need to be specified. -# It is ignored if OCIO is installing the library since OCIO builds the dependency as static library. +# If the library is not installed in a typical location where CMake will find it, you may specify +# the location using one of the following methods: +# -- Set -Dminizip-ng_DIR to point to the directory containing the CMake configuration file for the package. +# -- Set -Dminizip-ng_ROOT to point to the directory containing the lib and include directories. +# -- Set -Dminizip-ng_LIBRARY and -Dminizip-ng_INCLUDE_DIR to point to the lib and include directories. # -# If the library is not installed in a standard path, you can do the following the help -# the find module: -# -# If the package provides CMake's configuration file, use -Dminizip-ng_DIR=. -# If it doesn't provide it, try -Dminizip-ng_ROOT=. -# Alternatively, try -Dminizip-ng_LIBRARY= and -Dminizip-ng_INCLUDE_DIR=. # # For external builds of minizip-ng, please note that the same build options should be used. # Using more options, such as enabling other compression methods, will provoke linking issue diff --git a/share/cmake/modules/Findopenfx.cmake b/share/cmake/modules/Findopenfx.cmake index 7d0e797797..40dfac7072 100644 --- a/share/cmake/modules/Findopenfx.cmake +++ b/share/cmake/modules/Findopenfx.cmake @@ -11,12 +11,11 @@ # Global targets defined by this module: # openfx::module # -# By default, dynamic libraries are given priority over static libraries +# Usually CMake will use the dynamic library rather than static, if both are present. # -# If the library is not installed in a standard path, you can do the following the help -# the find module: -# -# If it doesn't provide it, try -Dopenfx_ROOT=. +# If the library is not installed in a typical location where CMake will find it, you may specify +# the location using the following method: +# -- Set -Dopenfx_ROOT to point to the directory containing the lib and include directories. # ############################################################################### diff --git a/share/cmake/modules/Findpybind11.cmake b/share/cmake/modules/Findpybind11.cmake index 6c9cc4f279..ccbb53e656 100644 --- a/share/cmake/modules/Findpybind11.cmake +++ b/share/cmake/modules/Findpybind11.cmake @@ -11,14 +11,13 @@ # Global targets defined by this module: # pybind11::module # -# By default, dynamic libraries are given priority over static libraries +# Usually CMake will use the dynamic library rather than static, if both are present. # -# If the library is not installed in a standard path, you can do the following the help -# the find module: -# -# If the package provides CMake's configuration file, use -Dpybind11_DIR=. -# If it doesn't provide it, try -Dpybind11_ROOT=. -# Alternatively, try -Dpybind11_INCLUDE_DIR=. +# If the library is not installed in a typical location where CMake will find it, you may specify +# the location using one of the following methods: +# -- Set -Dpybind11_DIR to point to the directory containing the CMake configuration file for the package. +# -- Set -Dpybind11_ROOT to point to the directory containing the lib and include directories. +# -- Set -Dpybind11_LIBRARY and -Dpybind11_INCLUDE_DIR to point to the lib and include directories. # ############################################################################### diff --git a/share/cmake/modules/Findpystring.cmake b/share/cmake/modules/Findpystring.cmake index 1f34f9f2cd..c466115476 100644 --- a/share/cmake/modules/Findpystring.cmake +++ b/share/cmake/modules/Findpystring.cmake @@ -12,15 +12,15 @@ # Global targets defined by this module: # pystring::pystring - IMPORTED target, if found # -# By default, dynamic libraries are given priority over static libraries +# Usually CMake will use the dynamic library rather than static, if both are present. # -# If the library is not installed in a standard path, you can do the following the help -# the find module: -# -# Try -Dpystring_ROOT=. -# Alternatively, try -Dpystring_LIBRARY= and -Dpystring_INCLUDE_DIR=. +# If the library is not installed in a typical location where CMake will find it, you may specify +# the location using one of the following methods: +# -- Set -Dpystring_ROOT to point to the directory containing the lib and include directories. +# -- Set -Dpystring_LIBRARY and -Dpystring_INCLUDE_DIR to point to the lib and include directories. # + ############################################################################### ### Try to find package ### diff --git a/share/cmake/modules/Findyaml-cpp.cmake b/share/cmake/modules/Findyaml-cpp.cmake index 7c6cedf58d..55e25e2c84 100644 --- a/share/cmake/modules/Findyaml-cpp.cmake +++ b/share/cmake/modules/Findyaml-cpp.cmake @@ -12,18 +12,16 @@ # Global targets defined by this module: # yaml-cpp # -# By default, dynamic libraries are given priority over static libraries +# Usually CMake will use the dynamic library rather than static, if both are present. +# In this case, you may set yaml-cpp_STATIC_LIBRARY to ON to request use of the static one. +# If only the static library is present (such as when OCIO builds the dependency), then the option +# is not needed. # -# You may set yaml-cpp_STATIC_LIBRARY to TRUE to prefer the use static library. -# If the static library the only one available, that variable does not need to be specified. -# It is ignored if OCIO is installing the library since OCIO builds the dependency as static library. -# -# If the library is not installed in a standard path, you can do the following the help -# the find module: -# -# If the package provides CMake's configuration file, use -Dyamp-cpp_DIR=. -# If it doesn't provide it, try -Dyamp-cpp_ROOT=. -# Alternatively, try -Dyamp-cpp_LIBRARY= and -Dyamp-cpp_INCLUDE_DIR=. +# If the library is not installed in a typical location where CMake will find it, you may specify +# the location using one of the following methods: +# -- Set -Dyaml-cpp_DIR to point to the directory containing the CMake configuration file for the package. +# -- Set -Dyaml-cpp_ROOT to point to the directory containing the lib and include directories. +# -- Set -Dyaml-cpp_LIBRARY and -Dyaml-cpp_INCLUDE_DIR to point to the lib and include directories. # ############################################################################### From 2019486132ca034b29844d6637b61017a9c278c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Thu, 23 Feb 2023 12:48:14 -0500 Subject: [PATCH 14/18] fixing typo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- share/cmake/modules/FindSphinx.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/cmake/modules/FindSphinx.cmake b/share/cmake/modules/FindSphinx.cmake index 686c9b5fdf..9278c57d9a 100644 --- a/share/cmake/modules/FindSphinx.cmake +++ b/share/cmake/modules/FindSphinx.cmake @@ -10,7 +10,7 @@ # # If the executable is not installed in a typical location where CMake will find it, you may specify # the location using one of the following methods: -# -- Set -Dlcms2_ROOT to point to the directory containing the executable. +# -- Set -DSphinx_ROOT to point to the directory containing the executable. # -- Set -DSphinx_EXECUTABLE to point to executable file. # From c650c427ec403e8acb974e6223f87195fca055b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Thu, 9 Mar 2023 13:34:47 -0500 Subject: [PATCH 15/18] Fix typo and fix issue when OCIO is installing ZLIB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- share/cmake/modules/FindExtPackages.cmake | 2 +- share/cmake/modules/install/InstallZLIB.cmake | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/share/cmake/modules/FindExtPackages.cmake b/share/cmake/modules/FindExtPackages.cmake index 3d25aa8301..9ff569b532 100644 --- a/share/cmake/modules/FindExtPackages.cmake +++ b/share/cmake/modules/FindExtPackages.cmake @@ -196,7 +196,7 @@ if((OCIO_BUILD_APPS AND OCIO_USE_OIIO_FOR_APPS) OR OCIO_BUILD_TESTS) set(OPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH 1) ############################################################################### - # OpenEXR (https://github.com/AcademySoftwareFoundation/openexr) + # OpenImageIO (https://github.com/OpenImageIO/oiio) # # Variables defined by OpemImageIO CMake's configuration files: # OpenImageIO_FOUND - Indicate whether the library was found or not diff --git a/share/cmake/modules/install/InstallZLIB.cmake b/share/cmake/modules/install/InstallZLIB.cmake index e0d31a0c3f..6aa3261fb9 100644 --- a/share/cmake/modules/install/InstallZLIB.cmake +++ b/share/cmake/modules/install/InstallZLIB.cmake @@ -136,10 +136,14 @@ if(NOT ZLIB_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGE add_dependencies(ZLIB::ZLIB ZLIB_install) - # Setting those variables to follow the same naming as the other OCIO custom find modules. - set(ZLIB_LIBRARY ${ZLIB_LIBRARIES}) - set(ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIRS}) - + # FindZLIB from CMake needs ZLIB_LIBRARY and ZLIB_INCLUDE_DIR. + # Starting CMake 3.17+, The mark_as_advanced() command no longer creates a cache entry if one + # does not already exist. (See policy CMP0102) + # For that reasons, ZLIB_LIBRARY and ZLIB_INCLUDE_DIR are set in the CMake's Cache since ZLIB + # is needed by other OCIO dependencies. + set(ZLIB_LIBRARY ${ZLIB_LIBRARIES} CACHE STRING "ZLIB library file") + set(ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIRS} CACHE STRING "ZLIB includes directory") + if(OCIO_VERBOSE) message(STATUS "Installing ZLIB: ${ZLIB_LIBRARIES} (version \"${ZLIB_VERSION}\") ") endif() From 0e83d20cabd21be00f5dd0d524cededb79342751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Thu, 9 Mar 2023 13:43:22 -0500 Subject: [PATCH 16/18] Tentative fix for Linux CI failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- .../ocio_check_dependency_version.cmake | 38 ++++++++++++ .../macros/ocio_install_dependency.cmake | 16 ++++- share/cmake/modules/FindExtPackages.cmake | 59 ++++++++++++------- 3 files changed, 89 insertions(+), 24 deletions(-) create mode 100644 share/cmake/macros/ocio_check_dependency_version.cmake diff --git a/share/cmake/macros/ocio_check_dependency_version.cmake b/share/cmake/macros/ocio_check_dependency_version.cmake new file mode 100644 index 0000000000..2c2b741192 --- /dev/null +++ b/share/cmake/macros/ocio_check_dependency_version.cmake @@ -0,0 +1,38 @@ +# SPDX-License-Identifier: BSD-3-Clause +# Copyright Contributors to the OpenColorIO Project. + +################################################################################################### +# ocio_check_dependency_version try to find the specified dependency and validate the version. +# +# Note that a function is used here to scoped-in any variables set by find_package. We do not want +# those variables to be propagated to the caller of the function. +# +# Argument: +# dep_name is the name of the dependency (package). Please note that dep_name is case sensitive. +# +################################################################################################### + +function (ocio_check_dependency_version dep_name output) + cmake_parse_arguments( + # prefix - Must be different than the one used in ocio_handle_dependency.cmake. + ocio_cdv + # options + "" + # one value keywords + "MIN_VERSION" + # multi value keywords + "" + # args + ${ARGN}) + + if (dep_name) + find_package(${dep_name} ${ocio_cdv_UNPARSED_ARGUMENTS}) + if (ocio_cdv_MIN_VERSION AND ${dep_name}_VERSION) + if (${${dep_name}_VERSION} VERSION_GREATER_EQUAL ocio_cdv_MIN_VERSION) + set(${output} TRUE) + else() + set(${output} FALSE) + endif() + endif() + endif() +endfunction() \ No newline at end of file diff --git a/share/cmake/macros/ocio_install_dependency.cmake b/share/cmake/macros/ocio_install_dependency.cmake index 2923a2bcee..f5b6a4e893 100644 --- a/share/cmake/macros/ocio_install_dependency.cmake +++ b/share/cmake/macros/ocio_install_dependency.cmake @@ -18,17 +18,29 @@ macro (ocio_install_dependency dep_name) # options "" # one value keywords - "VERSION" + "VERSION;PROMOTE_TARGET" # multi value keywords "" # args ${ARGN}) + + if(NOT ${dep_name}_FOUND AND OCIO_INSTALL_EXT_PACKAGES AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE) set(OCIO_${dep_name}_RECOMMENDED_VERSION ${ocio_id_VERSION}) include(Install${dep_name}) + set(_${dep_name}_built_by_ocio TRUE) endif() if(${dep_name}_FOUND) - message(STATUS "${ColorSuccess}Installed ${dep_name} (version \"${ocio_id_VERSION}\")${ColorReset}") + if(${dep_name}_FOUND AND ocio_id_PROMOTE_TARGET) + foreach (_target_to_be_promoted_ ${ocio_id_PROMOTE_TARGET}) + set_target_properties(${_target_to_be_promoted_} PROPERTIES IMPORTED_GLOBAL TRUE) + endforeach() + endif() + + if (${_${dep_name}_built_by_ocio}) + message(STATUS "${ColorSuccess}Installed ${dep_name} (version \"${ocio_id_VERSION}\")${ColorReset}") + endif() endif() + unset(_${dep_name}_built_by_ocio) endmacro() \ No newline at end of file diff --git a/share/cmake/modules/FindExtPackages.cmake b/share/cmake/modules/FindExtPackages.cmake index 9ff569b532..2b3103c17d 100644 --- a/share/cmake/modules/FindExtPackages.cmake +++ b/share/cmake/modules/FindExtPackages.cmake @@ -184,6 +184,8 @@ if(OCIO_BUILD_PYTHON OR OCIO_BUILD_DOCS) endif() endif() +# Set OpenEXR Minimum version as a variable since it it used at multiple places. +set(OpenEXR_MININUM_VERSION "3.0.5") if((OCIO_BUILD_APPS AND OCIO_USE_OIIO_FOR_APPS) OR OCIO_BUILD_TESTS) # OpenImageIO is required for OSL unit test and optional for apps. @@ -195,26 +197,39 @@ if((OCIO_BUILD_APPS AND OCIO_USE_OIIO_FOR_APPS) OR OCIO_BUILD_TESTS) # Supported from OIIO 2.4+. Setting this for lower versions doesn't affect anything. set(OPENIMAGEIO_CONFIG_DO_NOT_FIND_IMATH 1) - ############################################################################### - # OpenImageIO (https://github.com/OpenImageIO/oiio) - # - # Variables defined by OpemImageIO CMake's configuration files: - # OpenImageIO_FOUND - Indicate whether the library was found or not - # OpenImageIO_LIB_DIR - Library's directory - # OpenImageIO_INCLUDE_DIR - Location of the header files - # OpenImageIO_VERSION - Library's version - # - # Imported targets defined by this module, if found: - # OpenImageIO::OpenImageIO - # OpenImageIO::OpenImageIO_Util - # - ############################################################################### - # Calling find_package in CONFIG mode using PREFER_CONFIG option as OIIO support - # config file since 2.1+ and OCIO minimum version is over that. - ocio_handle_dependency( OpenImageIO PREFER_CONFIG - MIN_VERSION ${OIIO_VERSION} - RECOMMENDED_VERSION ${OIIO_RECOMMENDED_VERSION} - PROMOTE_TARGET OpenImageIO::OpenImageIO) + include(ocio_check_dependency_version) + # Since OpenImageIO will try to find OpenEXR through its OpenImageIOConfig.cmake file, + # let's try to find OpenEXR first and if the version is too old, OCIO will not try to find + # OpenImageIO. + ocio_check_dependency_version( OpenEXR "is_OpenEXR_VERSION_valid" + MIN_VERSION ${OpenEXR_MININUM_VERSION} + CONFIG) + + # Do not try to find OpenImageIO if the version of OpenEXR is too old. + if (is_OpenEXR_VERSION_valid) + ############################################################################### + # OpenImageIO (https://github.com/OpenImageIO/oiio) + # + # Variables defined by OpenImageIO CMake's configuration files: + # OpenImageIO_FOUND - Indicate whether the library was found or not + # OpenImageIO_LIB_DIR - Library's directory + # OpenImageIO_INCLUDE_DIR - Location of the header files + # OpenImageIO_VERSION - Library's version + # + # Imported targets defined by this module, if found: + # OpenImageIO::OpenImageIO + # OpenImageIO::OpenImageIO_Util + # + ############################################################################### + # Calling find_package in CONFIG mode using PREFER_CONFIG option as OIIO support + # config file since 2.1+ and OCIO minimum version is over that. + ocio_handle_dependency( OpenImageIO PREFER_CONFIG + MIN_VERSION ${OIIO_VERSION} + RECOMMENDED_VERSION ${OIIO_RECOMMENDED_VERSION} + PROMOTE_TARGET OpenImageIO::OpenImageIO) + else() + message(WARNING "Skipping OpenImageIO because the OpenEXR found by OpenImageIO is too old (under ${OpenEXR_MININUM_VERSION})") + endif() endif() if(OCIO_BUILD_APPS) @@ -242,8 +257,8 @@ if(OCIO_BUILD_APPS) # ############################################################################### # Calling find_package in CONFIG mode using PREFER_CONFIG option. - ocio_handle_dependency( OpenEXR REQUIRED PREFER_CONFIG ALLOW_INSTALL - MIN_VERSION 3.0.4 + ocio_handle_dependency( OpenEXR PREFER_CONFIG ALLOW_INSTALL + MIN_VERSION ${OpenEXR_MININUM_VERSION} RECOMMENDED_VERSION 3.1.5 RECOMMENDED_VERSION_REASON "Latest version tested with OCIO" PROMOTE_TARGET OpenEXR::OpenEXR) From 707c896de0d1aa8dc44d0447716499e372230fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Fri, 17 Mar 2023 11:44:47 -0400 Subject: [PATCH 17/18] Ignoring specifics warnings on OpenImageIO target directly. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- share/cmake/modules/FindExtPackages.cmake | 7 +++++++ src/libutils/imageioapphelpers/CMakeLists.txt | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/share/cmake/modules/FindExtPackages.cmake b/share/cmake/modules/FindExtPackages.cmake index 2b3103c17d..870b039bfc 100644 --- a/share/cmake/modules/FindExtPackages.cmake +++ b/share/cmake/modules/FindExtPackages.cmake @@ -235,6 +235,13 @@ endif() if(OCIO_BUILD_APPS) if(OCIO_USE_OIIO_FOR_APPS AND OpenImageIO_FOUND AND TARGET OpenImageIO::OpenImageIO) + if (USE_MSVC AND OCIO_IMAGE_BACKEND STREQUAL "OpenImageIO") + # Temporary until fixed in OpenImageIO: Mute some warnings from OpenImageIO farmhash.h + # C4267 (level 3) 'var' : conversion from 'size_t' to 'type', possible loss of data + # C4244 (level 3 & 4) 'conversion' conversion from 'type1' to 'type2', possible loss of data + target_compile_options(OpenImageIO::OpenImageIO PRIVATE /wd4267 /wd4244) + endif() + add_library(OpenColorIO::ImageIOBackend ALIAS OpenImageIO::OpenImageIO) set(OCIO_IMAGE_BACKEND OpenImageIO) else() diff --git a/src/libutils/imageioapphelpers/CMakeLists.txt b/src/libutils/imageioapphelpers/CMakeLists.txt index bee81ecf5f..6b32f2824e 100644 --- a/src/libutils/imageioapphelpers/CMakeLists.txt +++ b/src/libutils/imageioapphelpers/CMakeLists.txt @@ -9,13 +9,6 @@ add_library(imageioapphelpers STATIC ${SOURCES}) set_target_properties(imageioapphelpers PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(imageioapphelpers PROPERTIES OUTPUT_NAME OpenColorIOimageioapphelpers) -if (USE_MSVC AND OCIO_IMAGE_BACKEND STREQUAL "OpenImageIO") - # Temporary until fixed in OpenImageIO: Mute some warnings from OpenImageIO farmhash.h - # C4267 (level 3) 'var' : conversion from 'size_t' to 'type', possible loss of data - # C4244 (level 3 & 4) 'conversion' conversion from 'type1' to 'type2', possible loss of data - target_compile_options(imageioapphelpers PRIVATE /wd4267 /wd4244) -endif() - if(NOT BUILD_SHARED_LIBS) target_compile_definitions(imageioapphelpers PUBLIC From 855a123410433954815faf3b005fb02927243550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9drik=20Fuoco?= Date: Tue, 21 Mar 2023 15:13:48 -0400 Subject: [PATCH 18/18] Removing OCIO_USE_OIIO_CMAKE_CONFIG as it is not needed anymore. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Cédrik Fuoco --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08d7cb9eb1..932874f81c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,7 +175,6 @@ endif() # Optimization / internal linking preferences option(OCIO_USE_SSE "Specify whether to enable SSE CPU performance optimizations" ON) -option(OCIO_USE_OIIO_CMAKE_CONFIG "Specify whether to look for OIIO using the generated CMake Config script instead of the custom FindOpenImageIO.cmake script" OFF) option(OCIO_USE_OIIO_FOR_APPS "Request OIIO to build apps (ociolutimage, ocioconvert and ociodisplay), the default uses OpenEXR." OFF)