Skip to content

Commit

Permalink
(#10572) opencolorio: bump dependencies + modernize
Browse files Browse the repository at this point in the history
* modernize

* bump dependencies

* explicit cpp_info.libs

* minor change
  • Loading branch information
SpaceIm authored May 4, 2022
1 parent 85cdb49 commit 82fef0e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 49 deletions.
2 changes: 1 addition & 1 deletion recipes/opencolorio/all/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ cmake_minimum_required(VERSION 3.1)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()
conan_basic_setup(KEEP_RPATHS)

add_subdirectory("source_subfolder")
102 changes: 56 additions & 46 deletions recipes/opencolorio/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from conan.tools.microsoft import is_msvc
from conans import ConanFile, CMake, tools
import functools
import os

required_conan_version = ">=1.33.0"
required_conan_version = ">=1.45.0"


class OpenColorIOConan(ConanFile):
Expand All @@ -10,22 +12,21 @@ class OpenColorIOConan(ConanFile):
license = "BSD-3-Clause"
homepage = "https://opencolorio.org/"
url = "https://github.com/conan-io/conan-center-index"
settings = "os", "compiler", "build_type", "arch"
topics = ("colors", "visual", "effects", "animation")

settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"use_sse": [True, False]
"use_sse": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"use_sse": True
"use_sse": True,
}
generators = "cmake", "cmake_find_package"
exports_sources = ["CMakeLists.txt", "patches/*"]
topics = ("colors", "visual", "effects", "animation")

_cmake = None
generators = "cmake", "cmake_find_package"

@property
def _source_subfolder(self):
Expand All @@ -35,6 +36,11 @@ def _source_subfolder(self):
def _build_subfolder(self):
return "build_subfolder"

def export_sources(self):
self.copy("CMakeLists.txt")
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
Expand All @@ -45,62 +51,61 @@ def configure(self):
if self.options.shared:
del self.options.fPIC

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 11)

def requirements(self):
# TODO: add GLUT (needed for ociodisplay tool)
self.requires("lcms/2.12")
self.requires("expat/2.4.8")
self.requires("openexr/2.5.7")
self.requires("yaml-cpp/0.7.0")
if tools.Version(self.version) < "2.1.0":
if tools.Version(self.version) < "2.0.0":
self.requires("tinyxml/2.6.2")
if tools.Version(self.version) >= "2.1.0":
else:
self.requires("pystring/1.1.3")
self.requires("expat/2.4.1")
self.requires("openexr/2.5.7")
# for tools only
self.requires("lcms/2.13.1")
# TODO: add GLUT (needed for ociodisplay tool)

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 11)

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

@functools.lru_cache(1)
def _configure_cmake(self):
if self._cmake:
return self._cmake

self._cmake = CMake(self)
cmake = CMake(self)

if tools.Version(self.version) >= "2.1.0":
self._cmake.definitions["OCIO_BUILD_PYTHON"] = False
cmake.definitions["OCIO_BUILD_PYTHON"] = False
else:
self._cmake.definitions["OCIO_BUILD_SHARED"] = self.options.shared
self._cmake.definitions["OCIO_BUILD_STATIC"] = not self.options.shared
self._cmake.definitions["OCIO_BUILD_PYGLUE"] = False
cmake.definitions["OCIO_BUILD_SHARED"] = self.options.shared
cmake.definitions["OCIO_BUILD_STATIC"] = not self.options.shared
cmake.definitions["OCIO_BUILD_PYGLUE"] = False

self._cmake.definitions["USE_EXTERNAL_YAML"] = True
self._cmake.definitions["USE_EXTERNAL_TINYXML"] = True
self._cmake.definitions["USE_EXTERNAL_LCMS"] = True
cmake.definitions["USE_EXTERNAL_YAML"] = True
cmake.definitions["USE_EXTERNAL_TINYXML"] = True
cmake.definitions["USE_EXTERNAL_LCMS"] = True

self._cmake.definitions["OCIO_USE_SSE"] = self.options.get_safe("use_sse", False)
cmake.definitions["OCIO_USE_SSE"] = self.options.get_safe("use_sse", False)

# openexr 2.x provides Half library
self._cmake.definitions["OCIO_USE_OPENEXR_HALF"] = True
cmake.definitions["OCIO_USE_OPENEXR_HALF"] = True

self._cmake.definitions["OCIO_BUILD_APPS"] = True
self._cmake.definitions["OCIO_BUILD_DOCS"] = False
self._cmake.definitions["OCIO_BUILD_TESTS"] = False
self._cmake.definitions["OCIO_BUILD_GPU_TESTS"] = False
self._cmake.definitions["OCIO_USE_BOOST_PTR"] = False
cmake.definitions["OCIO_BUILD_APPS"] = True
cmake.definitions["OCIO_BUILD_DOCS"] = False
cmake.definitions["OCIO_BUILD_TESTS"] = False
cmake.definitions["OCIO_BUILD_GPU_TESTS"] = False
cmake.definitions["OCIO_USE_BOOST_PTR"] = False

# avoid downloading dependencies
self._cmake.definitions["OCIO_INSTALL_EXT_PACKAGE"] = "NONE"
cmake.definitions["OCIO_INSTALL_EXT_PACKAGE"] = "NONE"

if self.settings.compiler == "Visual Studio" and not self.options.shared:
if is_msvc(self) and not self.options.shared:
# define any value because ifndef is used
self._cmake.definitions["OpenColorIO_SKIP_IMPORTS"] = True
cmake.definitions["OpenColorIO_SKIP_IMPORTS"] = True

self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake
cmake.configure(build_folder=self._build_subfolder)
return cmake

def _patch_sources(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
Expand Down Expand Up @@ -136,11 +141,11 @@ def package(self):
self.copy("LICENSE", src=self._source_subfolder, dst="licenses")

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "OpenColorIO"
self.cpp_info.names["cmake_find_package_multi"] = "OpenColorIO"
self.cpp_info.names["pkg_config"] = "OpenColorIO"
self.cpp_info.set_property("cmake_file_name", "OpenColorIO")
self.cpp_info.set_property("cmake_target_name", "OpenColorIO::OpenColorIO")
self.cpp_info.set_property("pkg_config_name", "OpenColorIO")

self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.libs = ["OpenColorIO"]

if tools.Version(self.version) < "2.1.0":
if not self.options.shared:
Expand All @@ -149,9 +154,14 @@ def package_info(self):
if self.settings.os == "Macos":
self.cpp_info.frameworks.extend(["Foundation", "IOKit", "ColorSync", "CoreGraphics"])

if self.settings.compiler == "Visual Studio" and not self.options.shared:
if is_msvc(self) and not self.options.shared:
self.cpp_info.defines.append("OpenColorIO_SKIP_IMPORTS")

bin_path = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH env var with: {}".format(bin_path))
self.env_info.PATH.append(bin_path)

# TODO: to remove in conan v2 once cmake_find_package_* & pkg_config generators removed
self.cpp_info.names["cmake_find_package"] = "OpenColorIO"
self.cpp_info.names["cmake_find_package_multi"] = "OpenColorIO"
self.cpp_info.names["pkg_config"] = "OpenColorIO"
5 changes: 3 additions & 2 deletions recipes/opencolorio/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from conans import ConanFile, CMake, tools
import os

class DefaultNameConan(ConanFile):
settings = "os", "compiler", "arch", "build_type"

class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

def build(self):
Expand Down

0 comments on commit 82fef0e

Please sign in to comment.