Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opensubdiv: Add recipe #11450

Merged
merged 16 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions recipes/opensubdiv/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup(KEEP_RPATHS)

add_subdirectory(source_subfolder)
4 changes: 4 additions & 0 deletions recipes/opensubdiv/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"3.4.4":
url: "https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v3_4_4.zip"
sha256: "04b52a67e90a56b18d9ddd0384630f43b5263a8fdee1afae081e32d7b23cd5ec"
137 changes: 137 additions & 0 deletions recipes/opensubdiv/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import functools
import os

from conans import ConanFile, CMake, tools


class OpenSubdivConan(ConanFile):
name = "opensubdiv"
license = "LicenseRef-LICENSE.txt"
homepage = "https://github.com/PixarAnimationStudios/OpenSubdiv"
url = "https://github.com/conan-io/conan-center-index"
description = "An Open-Source subdivision surface library"
topics = ("cgi", "vfx", "animation", "subdivision surface")

settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"with_tbb": [True, False],
"with_opengl": [True, False],
"with_omp": [True, False],
"with_cuda": [True, False],
"with_clew": [True, False],
"with_opencl": [True, False],
"with_dx": [True, False],
"with_metal": [True, False],
}
default_options = {
"shared": False,
"with_tbb": False,
"with_opengl": False,
"with_omp": False,
"with_cuda": False,
"with_clew": False,
"with_opencl": False,
"with_dx": False,
"with_metal": False,
}

short_paths = True
generators = "cmake"

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def export_sources(self):
self.copy("CMakeLists.txt")

def config_options(self):
if self.settings.os != "Windows":
del self.options.with_dx
if self.settings.os != "Macos":
del self.options.with_metal

def configure(self):
if self.settings.os == "Windows":
del self.options.shared

def requirements(self):
if self.options.with_tbb:
self.requires("onetbb/2020.3")

def source(self):
tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder)
Latios96 marked this conversation as resolved.
Show resolved Hide resolved

@property
def _osd_gpu_enabled(self):
return any(
[
self.options.with_opengl,
self.options.with_opencl,
self.options.with_cuda,
self.options.get_safe("with_dx"),
self.options.get_safe("with_metal"),
]
)

@functools.lru_cache(1)
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["NO_TBB"] = not self.options.with_tbb
cmake.definitions["NO_OPENGL"] = not self.options.with_opengl
cmake.definitions["BUILD_SHARED_LIBS"] = self.options.get_safe("shared")
cmake.definitions["NO_OMP"] = not self.options.with_omp
cmake.definitions["NO_CUDA"] = not self.options.with_cuda
cmake.definitions["NO_DX"] = not self.options.get_safe("with_dx")
cmake.definitions["NO_METAL"] = not self.options.get_safe("with_metal")
cmake.definitions["NO_CLEW"] = not self.options.with_clew
cmake.definitions["NO_OPENCL"] = not self.options.with_opencl
cmake.definitions["NO_PTEX"] = True # Note: PTEX is for examples only, but we skip them..
cmake.definitions["NO_DOC"] = True
cmake.definitions["NO_EXAMPLES"] = True
cmake.definitions["NO_TUTORIALS"] = True
cmake.definitions["NO_REGRESSION"] = True
cmake.definitions["NO_TESTS"] = True
cmake.definitions["NO_GLTESTS"] = True

cmake.configure(build_folder=self._build_subfolder)

return cmake

def build(self):
if not self._osd_gpu_enabled and self.settings.os == "Macos":
path = os.path.join(self._source_subfolder, "opensubdiv", "CMakeLists.txt")
tools.replace_in_file(path, "$<TARGET_OBJECTS:osd_gpu_obj>", "")
tools.replace_in_file(path, "${CMAKE_SOURCE_DIR}/opensubdiv", "${CMAKE_SOURCE_DIR}/source_subfolder/opensubdiv")
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("LICENSE.txt", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "OpenSubdiv")
self.cpp_info.set_property("cmake_target_name", "OpenSubdiv::opensubdiv")
Latios96 marked this conversation as resolved.
Show resolved Hide resolved

self.cpp_info.names["cmake_find_package"] = "OpenSubdiv"
self.cpp_info.names["cmake_find_package_multi"] = "OpenSubdiv"

self.cpp_info.components["osdcpu"].libs = ["osdCPU"]
self.cpp_info.components["osdcpu"].set_property("cmake_target_name", "OpenSubdiv::osdcpu")

if self.options.with_tbb:
self.cpp_info.components["osdcpu"].requires = ["onetbb::onetbb"]

if self._osd_gpu_enabled:
self.cpp_info.components["osdgpu"].libs = ["osdGPU"]
self.cpp_info.components["osdgpu"].set_property("cmake_target_name", "OpenSubdiv::osdgpu")
dl_required = self.options.with_opengl or self.options.with_opencl
if self.settings.os in ["Linux", "FreeBSD"] and dl_required:
self.cpp_info.components["osdgpu"].system_libs = ["dl"]
14 changes: 14 additions & 0 deletions recipes/opensubdiv/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.1)
project(PackageTest CXX)

set(CMAKE_CXX_STANDARD 14)
Latios96 marked this conversation as resolved.
Show resolved Hide resolved
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(OpenSubdiv REQUIRED)

add_executable(example example.cpp)
target_link_libraries(example OpenSubdiv::OpenSubdiv)
18 changes: 18 additions & 0 deletions recipes/opensubdiv/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

from conans import ConanFile, CMake, tools
Latios96 marked this conversation as resolved.
Show resolved Hide resolved


class USDTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
Latios96 marked this conversation as resolved.
Show resolved Hide resolved
bin_path = os.path.join("bin", "example")
self.run(bin_path, run_environment=True)
41 changes: 41 additions & 0 deletions recipes/opensubdiv/all/test_package/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include <opensubdiv/far/topologyDescriptor.h>

static int g_nverts = 8,
g_nfaces = 6;

static int g_vertsperface[6] = {4, 4, 4, 4, 4, 4};

static int g_vertIndices[24] = {0, 1, 3, 2,
2, 3, 5, 4,
4, 5, 7, 6,
6, 7, 1, 0,
1, 7, 5, 3,
6, 0, 2, 4};

using namespace OpenSubdiv;

//------------------------------------------------------------------------------
int main(int, char **) {
typedef Far::TopologyDescriptor Descriptor;

Sdc::SchemeType type = OpenSubdiv::Sdc::SCHEME_CATMARK;

Sdc::Options options;
options.SetVtxBoundaryInterpolation(Sdc::Options::VTX_BOUNDARY_EDGE_ONLY);

Descriptor desc;
desc.numVertices = g_nverts;
desc.numFaces = g_nfaces;
desc.numVertsPerFace = g_vertsperface;
desc.vertIndicesPerFace = g_vertIndices;

Far::TopologyRefiner *refiner =
Far::TopologyRefinerFactory<Descriptor>::Create(desc,
Far::TopologyRefinerFactory<Descriptor>::Options(type,
options));

refiner->RefineUniform(Far::TopologyRefiner::UniformOptions(2));

delete refiner;
return 0;
}
3 changes: 3 additions & 0 deletions recipes/opensubdiv/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"3.4.4":
folder: all