Skip to content

Commit

Permalink
(conan-io#15498) opensubdiv: add version 3.5.0
Browse files Browse the repository at this point in the history
* add OpenSubdiv 3.5.0

* require minimum GCC 6 if 3.5.0

* fix: remove generated cmake config files from package

* fix: explicitly set CMAKE_CXX_STANDARD to prevent build issues

For example, building without Metal support breaks otherwise on Mac OS, see PixarAnimationStudios/OpenSubdiv#1276

* fix: address linter issues

* fix: remove duplicated static lib when building as shared library

* remove gcc version constraint

This should be fixed by settings CMAKE_CXX_STANDARD
  • Loading branch information
Latios96 authored and sabelka committed Feb 12, 2023
1 parent 675810e commit d32b103
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 10 deletions.
3 changes: 3 additions & 0 deletions recipes/opensubdiv/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ sources:
"3.4.4":
url: "https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v3_4_4.zip"
sha256: "04b52a67e90a56b18d9ddd0384630f43b5263a8fdee1afae081e32d7b23cd5ec"
"3.5.0":
url: "https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v3_5_0.zip"
sha256: "1b2916d57173ac523acd334fb6e25623ddfed3c342f3c2aadfe4d1d0be6e7657"
52 changes: 42 additions & 10 deletions recipes/opensubdiv/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

from conan import ConanFile
from conan.tools.files import get, replace_in_file
from conans import CMake, tools
from conan.tools.build import check_min_cppstd
import conan.tools.scm as tools_scm
from conan.errors import ConanInvalidConfiguration
from conans import CMake, tools

required_conan_version = ">=1.48.0"

Expand Down Expand Up @@ -86,18 +88,25 @@ def requirements(self):

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, self._minimum_cpp_standard)
check_min_cppstd(self, self._minimum_cpp_standard)
min_version = self._minimum_compilers_version.get(str(self.settings.compiler))
if not min_version:
self.output.warn("{} recipe lacks information about the {} compiler support.".format(self.name, self.settings.compiler))
self.output.warn(
f"{self.name} recipe lacks information about the {self.settings.compiler} compiler support."
)
else:
if tools.Version(self.settings.compiler.version) < min_version:
if tools_scm.Version(self.settings.compiler.version) < min_version:
raise ConanInvalidConfiguration(
"{} requires C++{} support. The current compiler {} {} does not support it.".format(self.name, self._minimum_cpp_standard, self.settings.compiler, self.settings.compiler.version)
f"{self.name} requires C++{self._minimum_cpp_standard} support. The current compiler {self.settings.compiler} {self.settings.compiler.version} does not support it."
)

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

@property
def _osd_gpu_enabled(self):
Expand All @@ -114,6 +123,7 @@ def _osd_gpu_enabled(self):
@functools.lru_cache(1)
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["CMAKE_CXX_STANDARD"] = self._minimum_cpp_standard
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")
Expand All @@ -123,7 +133,9 @@ def _configure_cmake(self):
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_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
Expand All @@ -138,7 +150,12 @@ def _configure_cmake(self):
def build(self):
if self.settings.os == "Macos":
path = os.path.join(self._source_subfolder, "opensubdiv", "CMakeLists.txt")
replace_in_file(self, path, "${CMAKE_SOURCE_DIR}/opensubdiv", "${CMAKE_SOURCE_DIR}/source_subfolder/opensubdiv")
replace_in_file(
self,
path,
"${CMAKE_SOURCE_DIR}/opensubdiv",
"${CMAKE_SOURCE_DIR}/source_subfolder/opensubdiv",
)
if not self._osd_gpu_enabled:
replace_in_file(self, path, "$<TARGET_OBJECTS:osd_gpu_obj>", "")
cmake = self._configure_cmake()
Expand All @@ -149,21 +166,36 @@ def package(self):
cmake = self._configure_cmake()
cmake.install()

for mask in [
"Find*.cmake",
"*Config*.cmake",
"*-config.cmake",
"*Targets*.cmake",
]:
tools.remove_files_by_mask(self.package_folder, mask)

if self.options.get_safe("shared") == True:
tools.remove_files_by_mask(os.path.join(self.package_folder, "lib"), "*.a")

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "OpenSubdiv")

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")
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")
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"]
2 changes: 2 additions & 0 deletions recipes/opensubdiv/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"3.4.4":
folder: all
"3.5.0":
folder: all

0 comments on commit d32b103

Please sign in to comment.