From 37117f6fa13d5214a14eb9c5284cfdace2f63ce3 Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Wed, 29 Jun 2022 20:00:06 +0200 Subject: [PATCH 01/16] opensubdiv: Add recipe --- recipes/opensubdiv/all/conandata.yml | 4 + recipes/opensubdiv/all/conanfile.py | 124 ++++++++++++++++++ .../all/test_package/CMakeLists.txt | 12 ++ .../opensubdiv/all/test_package/conanfile.py | 18 +++ .../opensubdiv/all/test_package/example.cpp | 41 ++++++ recipes/opensubdiv/config.yml | 3 + 6 files changed, 202 insertions(+) create mode 100644 recipes/opensubdiv/all/conandata.yml create mode 100644 recipes/opensubdiv/all/conanfile.py create mode 100644 recipes/opensubdiv/all/test_package/CMakeLists.txt create mode 100644 recipes/opensubdiv/all/test_package/conanfile.py create mode 100644 recipes/opensubdiv/all/test_package/example.cpp create mode 100644 recipes/opensubdiv/config.yml diff --git a/recipes/opensubdiv/all/conandata.yml b/recipes/opensubdiv/all/conandata.yml new file mode 100644 index 0000000000000..c9db5e6f5cfd4 --- /dev/null +++ b/recipes/opensubdiv/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.4.4": + url: "https://github.com/PixarAnimationStudios/OpenSubdiv/archive/v3_4_4.zip" + sha256: "04b52a67e90a56b18d9ddd0384630f43b5263a8fdee1afae081e32d7b23cd5ec" diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py new file mode 100644 index 0000000000000..1b8805dc12c57 --- /dev/null +++ b/recipes/opensubdiv/all/conanfile.py @@ -0,0 +1,124 @@ +import functools + +from conans import ConanFile, CMake, tools + + +class OpenSubdivConan(ConanFile): + name = "opensubdiv" + license = "Modified Apache 2.0 License" + 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, + } + + generators = "cmake" + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.shared + if self.settings.os != "Windows": + del self.options.with_dx + if self.settings.os != "Macos": + del self.options.with_metal + + 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) + + @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(source_folder=self._source_subfolder, build_folder=self._build_subfolder) + + return cmake + + def build(self): + 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") + + 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"] + + osd_gpu_enabled = 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"), + ] + ) + + if 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"] diff --git a/recipes/opensubdiv/all/test_package/CMakeLists.txt b/recipes/opensubdiv/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..3b93b3904aacc --- /dev/null +++ b/recipes/opensubdiv/all/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_executable(example example.cpp) +target_link_libraries(example osdCPU) diff --git a/recipes/opensubdiv/all/test_package/conanfile.py b/recipes/opensubdiv/all/test_package/conanfile.py new file mode 100644 index 0000000000000..2f77c3c4fd2ef --- /dev/null +++ b/recipes/opensubdiv/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +import os + +from conans import ConanFile, CMake, tools + + +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): + os.chdir("bin") + self.run(".%sexample" % os.sep) diff --git a/recipes/opensubdiv/all/test_package/example.cpp b/recipes/opensubdiv/all/test_package/example.cpp new file mode 100644 index 0000000000000..a28c785721070 --- /dev/null +++ b/recipes/opensubdiv/all/test_package/example.cpp @@ -0,0 +1,41 @@ +#include + +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::Create(desc, + Far::TopologyRefinerFactory::Options(type, + options)); + + refiner->RefineUniform(Far::TopologyRefiner::UniformOptions(2)); + + delete refiner; + return 0; +} diff --git a/recipes/opensubdiv/config.yml b/recipes/opensubdiv/config.yml new file mode 100644 index 0000000000000..bd356e3c6a168 --- /dev/null +++ b/recipes/opensubdiv/config.yml @@ -0,0 +1,3 @@ +versions: + "3.4.4": + folder: all From 42a07cec5db4c98b998dc330372457dd8c79babe Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Thu, 30 Jun 2022 15:07:01 +0200 Subject: [PATCH 02/16] delete "shared" option on Windows in configure step --- recipes/opensubdiv/all/conanfile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py index 1b8805dc12c57..175b88fc8dd2d 100644 --- a/recipes/opensubdiv/all/conanfile.py +++ b/recipes/opensubdiv/all/conanfile.py @@ -46,13 +46,15 @@ def _build_subfolder(self): return "build_subfolder" def config_options(self): - if self.settings.os == "Windows": - del self.options.shared 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") From 371c2b18e390bc0885ab2dd9ff0082587fce9aed Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Thu, 30 Jun 2022 17:34:56 +0200 Subject: [PATCH 03/16] fix undefined symbols errors when building on linux with clang and opensubdiv:shared=True and compiler.libcxx == "libc++" --- recipes/opensubdiv/all/conanfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py index 175b88fc8dd2d..41f9ab0d2a932 100644 --- a/recipes/opensubdiv/all/conanfile.py +++ b/recipes/opensubdiv/all/conanfile.py @@ -81,6 +81,8 @@ def _configure_cmake(self): cmake.definitions["NO_REGRESSION"] = True cmake.definitions["NO_TESTS"] = True cmake.definitions["NO_GLTESTS"] = True + if self.settings.os == "Linux" and self.settings.compiler == "clang" and not self.options.shared and self.settings.compiler.libcxx == "libc++": + cmake.definitions["CMAKE_CXX_FLAGS"] = "-stdlib=libc++" cmake.configure(source_folder=self._source_subfolder, build_folder=self._build_subfolder) From dc3e725d94939b026fa1440a1b72bcbd2f76f2f8 Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Thu, 30 Jun 2022 20:10:38 +0200 Subject: [PATCH 04/16] fix: work around an issue in OpenSubdiv that would still request osd_gpu, even if its disabled --- recipes/opensubdiv/all/conanfile.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py index 41f9ab0d2a932..f33ee6e61ce75 100644 --- a/recipes/opensubdiv/all/conanfile.py +++ b/recipes/opensubdiv/all/conanfile.py @@ -1,4 +1,5 @@ import functools +import os from conans import ConanFile, CMake, tools @@ -62,6 +63,18 @@ def requirements(self): def source(self): tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) + @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) @@ -89,6 +102,9 @@ def _configure_cmake(self): 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, "$", "") cmake = self._configure_cmake() cmake.build() @@ -110,17 +126,7 @@ def package_info(self): if self.options.with_tbb: self.cpp_info.components["osdcpu"].requires = ["onetbb::onetbb"] - osd_gpu_enabled = 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"), - ] - ) - - if osd_gpu_enabled: + 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 From ca1930ac272b56a2c850a80e249b23a7d12a461b Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Fri, 1 Jul 2022 16:31:51 +0200 Subject: [PATCH 05/16] fix: building with build_type=Release and shared=True was not working on Mac OS --- recipes/opensubdiv/all/test_package/CMakeLists.txt | 6 ++++-- recipes/opensubdiv/all/test_package/conanfile.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/recipes/opensubdiv/all/test_package/CMakeLists.txt b/recipes/opensubdiv/all/test_package/CMakeLists.txt index 3b93b3904aacc..a9f2f6bbea1d8 100644 --- a/recipes/opensubdiv/all/test_package/CMakeLists.txt +++ b/recipes/opensubdiv/all/test_package/CMakeLists.txt @@ -6,7 +6,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup(KEEP_RPATHS) +conan_basic_setup(TARGETS) + +find_package(OpenSubdiv REQUIRED) add_executable(example example.cpp) -target_link_libraries(example osdCPU) +target_link_libraries(example OpenSubdiv::OpenSubdiv) diff --git a/recipes/opensubdiv/all/test_package/conanfile.py b/recipes/opensubdiv/all/test_package/conanfile.py index 2f77c3c4fd2ef..d96fab88d5caf 100644 --- a/recipes/opensubdiv/all/test_package/conanfile.py +++ b/recipes/opensubdiv/all/test_package/conanfile.py @@ -14,5 +14,5 @@ def build(self): def test(self): if not tools.cross_building(self): - os.chdir("bin") - self.run(".%sexample" % os.sep) + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) From 26726971a1e2a14700b00489fe71a140f81ca08e Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Sat, 2 Jul 2022 15:27:14 +0200 Subject: [PATCH 06/16] fix: support /MT and /MTd for msvc --- recipes/opensubdiv/all/conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py index f33ee6e61ce75..a1b44743be0b7 100644 --- a/recipes/opensubdiv/all/conanfile.py +++ b/recipes/opensubdiv/all/conanfile.py @@ -1,6 +1,7 @@ import functools import os +from conan.tools.microsoft import is_msvc from conans import ConanFile, CMake, tools @@ -96,6 +97,8 @@ def _configure_cmake(self): cmake.definitions["NO_GLTESTS"] = True if self.settings.os == "Linux" and self.settings.compiler == "clang" and not self.options.shared and self.settings.compiler.libcxx == "libc++": cmake.definitions["CMAKE_CXX_FLAGS"] = "-stdlib=libc++" + if is_msvc(self) and self.settings.compiler.runtime in ["MT", "MTd"]: + cmake.definitions["MSVC_STATIC_CRT"] = True cmake.configure(source_folder=self._source_subfolder, build_folder=self._build_subfolder) From 78955e8c01e9b16128bcd050702fec05ddcda43a Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Tue, 5 Jul 2022 14:28:41 +0200 Subject: [PATCH 07/16] no spaces in license name --- recipes/opensubdiv/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py index a1b44743be0b7..8c50920792eaf 100644 --- a/recipes/opensubdiv/all/conanfile.py +++ b/recipes/opensubdiv/all/conanfile.py @@ -7,7 +7,7 @@ class OpenSubdivConan(ConanFile): name = "opensubdiv" - license = "Modified Apache 2.0 License" + license = "Modified-Apache-2.0" homepage = "https://github.com/PixarAnimationStudios/OpenSubdiv" url = "https://github.com/conan-io/conan-center-index" description = "An Open-Source subdivision surface library" From 8f3415ed4e3b86ba4fcf712da5047c91de2495b8 Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Tue, 5 Jul 2022 14:44:10 +0200 Subject: [PATCH 08/16] add missing cmake_wrapper --- recipes/opensubdiv/all/CMakeLists.txt | 7 +++++++ recipes/opensubdiv/all/conanfile.py | 10 ++++------ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 recipes/opensubdiv/all/CMakeLists.txt diff --git a/recipes/opensubdiv/all/CMakeLists.txt b/recipes/opensubdiv/all/CMakeLists.txt new file mode 100644 index 0000000000000..b71c882d9d33f --- /dev/null +++ b/recipes/opensubdiv/all/CMakeLists.txt @@ -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) diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py index 8c50920792eaf..e408bb2f8b18d 100644 --- a/recipes/opensubdiv/all/conanfile.py +++ b/recipes/opensubdiv/all/conanfile.py @@ -1,7 +1,6 @@ import functools import os -from conan.tools.microsoft import is_msvc from conans import ConanFile, CMake, tools @@ -47,6 +46,9 @@ def _source_subfolder(self): 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 @@ -95,12 +97,8 @@ def _configure_cmake(self): cmake.definitions["NO_REGRESSION"] = True cmake.definitions["NO_TESTS"] = True cmake.definitions["NO_GLTESTS"] = True - if self.settings.os == "Linux" and self.settings.compiler == "clang" and not self.options.shared and self.settings.compiler.libcxx == "libc++": - cmake.definitions["CMAKE_CXX_FLAGS"] = "-stdlib=libc++" - if is_msvc(self) and self.settings.compiler.runtime in ["MT", "MTd"]: - cmake.definitions["MSVC_STATIC_CRT"] = True - cmake.configure(source_folder=self._source_subfolder, build_folder=self._build_subfolder) + cmake.configure(build_folder=self._build_subfolder) return cmake From b56c6059c3396b1772c3bc06318b79f54090c15a Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Tue, 5 Jul 2022 18:44:53 +0200 Subject: [PATCH 09/16] fix: cmake wrapper broke build on Mac OS --- recipes/opensubdiv/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py index e408bb2f8b18d..fc1d8768a0ad6 100644 --- a/recipes/opensubdiv/all/conanfile.py +++ b/recipes/opensubdiv/all/conanfile.py @@ -106,6 +106,7 @@ 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, "$", "") + tools.replace_in_file(path, "${CMAKE_SOURCE_DIR}/opensubdiv", "${CMAKE_SOURCE_DIR}/source_subfolder/opensubdiv") cmake = self._configure_cmake() cmake.build() From aec2e1469613008de11a4f4d57638457cc1e4028 Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Wed, 6 Jul 2022 12:12:45 +0200 Subject: [PATCH 10/16] fix: use short paths to avoid too long paths --- recipes/opensubdiv/all/conanfile.py | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py index fc1d8768a0ad6..d93cd19d6f0a3 100644 --- a/recipes/opensubdiv/all/conanfile.py +++ b/recipes/opensubdiv/all/conanfile.py @@ -36,6 +36,7 @@ class OpenSubdivConan(ConanFile): "with_metal": False, } + short_paths = True generators = "cmake" @property From 650433f01d7095ad9b777ad5870accf83221d18f Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Wed, 20 Jul 2022 10:29:19 +0200 Subject: [PATCH 11/16] fix: follow instructions for a custom license --- recipes/opensubdiv/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py index d93cd19d6f0a3..fe503f0ad734a 100644 --- a/recipes/opensubdiv/all/conanfile.py +++ b/recipes/opensubdiv/all/conanfile.py @@ -6,7 +6,7 @@ class OpenSubdivConan(ConanFile): name = "opensubdiv" - license = "Modified-Apache-2.0" + 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" From 63fef38fcadb1861248c3cab90fe907331b64450 Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Fri, 12 Aug 2022 08:53:41 +0200 Subject: [PATCH 12/16] fix: remove misleading information --- recipes/opensubdiv/all/conanfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py index fe503f0ad734a..ebd8d2e66724b 100644 --- a/recipes/opensubdiv/all/conanfile.py +++ b/recipes/opensubdiv/all/conanfile.py @@ -118,7 +118,6 @@ def package(self): def package_info(self): self.cpp_info.set_property("cmake_file_name", "OpenSubdiv") - self.cpp_info.set_property("cmake_target_name", "OpenSubdiv::opensubdiv") self.cpp_info.names["cmake_find_package"] = "OpenSubdiv" self.cpp_info.names["cmake_find_package_multi"] = "OpenSubdiv" From e192ce8ae9844a7be9b463a0d13e2a7456f8d1eb Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Fri, 12 Aug 2022 08:58:14 +0200 Subject: [PATCH 13/16] fix: linter complains --- recipes/opensubdiv/all/test_package/conanfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/opensubdiv/all/test_package/conanfile.py b/recipes/opensubdiv/all/test_package/conanfile.py index d96fab88d5caf..c08cb9fda4903 100644 --- a/recipes/opensubdiv/all/test_package/conanfile.py +++ b/recipes/opensubdiv/all/test_package/conanfile.py @@ -1,6 +1,7 @@ import os -from conans import ConanFile, CMake, tools +from conans import ConanFile, CMake +from conan.tools.build import cross_building class USDTestConan(ConanFile): @@ -13,6 +14,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self): + if not cross_building(self): bin_path = os.path.join("bin", "example") self.run(bin_path, run_environment=True) From ad8aff81a724fea2b85381a0c17b54d249576959 Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Fri, 12 Aug 2022 09:36:22 +0200 Subject: [PATCH 14/16] address minimum compiler and C++ versions --- recipes/opensubdiv/all/conanfile.py | 28 +++++++++++++++++++ .../all/test_package/CMakeLists.txt | 1 - 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py index ebd8d2e66724b..d935efb639715 100644 --- a/recipes/opensubdiv/all/conanfile.py +++ b/recipes/opensubdiv/all/conanfile.py @@ -2,6 +2,7 @@ import os from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration class OpenSubdivConan(ConanFile): @@ -47,6 +48,21 @@ def _source_subfolder(self): def _build_subfolder(self): return "build_subfolder" + @property + def _minimum_cpp_standard(self): + if self.options.get_safe("with_metal"): + return 14 + return 11 + + @property + def _minimum_compilers_version(self): + return { + "Visual Studio": "15", + "gcc": "5", + "clang": "11", + "apple-clang": "11.0", + } + def export_sources(self): self.copy("CMakeLists.txt") @@ -64,6 +80,18 @@ def requirements(self): if self.options.with_tbb: self.requires("onetbb/2020.3") + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.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)) + else: + if tools.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) + ) + def source(self): tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) diff --git a/recipes/opensubdiv/all/test_package/CMakeLists.txt b/recipes/opensubdiv/all/test_package/CMakeLists.txt index a9f2f6bbea1d8..03f2ff1d46044 100644 --- a/recipes/opensubdiv/all/test_package/CMakeLists.txt +++ b/recipes/opensubdiv/all/test_package/CMakeLists.txt @@ -1,7 +1,6 @@ cmake_minimum_required(VERSION 3.1) project(PackageTest CXX) -set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) From 94e26913448a339d2cfaf687fe0b5ff23526bfc4 Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Fri, 12 Aug 2022 09:37:04 +0200 Subject: [PATCH 15/16] fix: issues with cmake wrapper on Mac OS --- recipes/opensubdiv/all/conanfile.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py index d935efb639715..f9fb9345374c4 100644 --- a/recipes/opensubdiv/all/conanfile.py +++ b/recipes/opensubdiv/all/conanfile.py @@ -132,10 +132,11 @@ def _configure_cmake(self): return cmake def build(self): - if not self._osd_gpu_enabled and self.settings.os == "Macos": + if self.settings.os == "Macos": path = os.path.join(self._source_subfolder, "opensubdiv", "CMakeLists.txt") - tools.replace_in_file(path, "$", "") tools.replace_in_file(path, "${CMAKE_SOURCE_DIR}/opensubdiv", "${CMAKE_SOURCE_DIR}/source_subfolder/opensubdiv") + if not self._osd_gpu_enabled: + tools.replace_in_file(path, "$", "") cmake = self._configure_cmake() cmake.build() From 25ca40a0d284f925eda09f8f53ac32da1d2431ab Mon Sep 17 00:00:00 2001 From: Jan Honsbrok Date: Fri, 12 Aug 2022 13:10:17 +0200 Subject: [PATCH 16/16] Prepare for Conan 2.x --- recipes/opensubdiv/all/conanfile.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/recipes/opensubdiv/all/conanfile.py b/recipes/opensubdiv/all/conanfile.py index f9fb9345374c4..297736ec83eef 100644 --- a/recipes/opensubdiv/all/conanfile.py +++ b/recipes/opensubdiv/all/conanfile.py @@ -1,8 +1,12 @@ import functools import os -from conans import ConanFile, CMake, tools -from conans.errors import ConanInvalidConfiguration +from conan import ConanFile +from conan.tools.files import get, replace_in_file +from conans import CMake, tools +from conan.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.48.0" class OpenSubdivConan(ConanFile): @@ -93,7 +97,7 @@ def validate(self): ) def source(self): - tools.get(**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): @@ -134,9 +138,9 @@ def _configure_cmake(self): def build(self): if self.settings.os == "Macos": path = os.path.join(self._source_subfolder, "opensubdiv", "CMakeLists.txt") - tools.replace_in_file(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: - tools.replace_in_file(path, "$", "") + replace_in_file(self, path, "$", "") cmake = self._configure_cmake() cmake.build()