From b2d2b624f83bf24564048eddf342d80d5955e661 Mon Sep 17 00:00:00 2001 From: Ilya Lavrenov Date: Thu, 15 Jun 2023 12:22:37 +0400 Subject: [PATCH] (#17812) [hwloc] new recipe --- recipes/hwloc/all/conandata.yml | 13 ++ recipes/hwloc/all/conanfile.py | 114 ++++++++++++++++++ recipes/hwloc/all/test_package/CMakeLists.txt | 7 ++ recipes/hwloc/all/test_package/conanfile.py | 26 ++++ recipes/hwloc/all/test_package/test_package.c | 10 ++ recipes/hwloc/config.yml | 9 ++ 6 files changed, 179 insertions(+) create mode 100644 recipes/hwloc/all/conandata.yml create mode 100644 recipes/hwloc/all/conanfile.py create mode 100644 recipes/hwloc/all/test_package/CMakeLists.txt create mode 100644 recipes/hwloc/all/test_package/conanfile.py create mode 100644 recipes/hwloc/all/test_package/test_package.c create mode 100644 recipes/hwloc/config.yml diff --git a/recipes/hwloc/all/conandata.yml b/recipes/hwloc/all/conandata.yml new file mode 100644 index 0000000000000..bfdda23bd429a --- /dev/null +++ b/recipes/hwloc/all/conandata.yml @@ -0,0 +1,13 @@ +sources: + "2.9.1": + sha256: "a440e2299f7451dc10a57ddbfa3f116c2a6c4be1bb97c663edd3b9c7b3b3b4cf" + url: https://download.open-mpi.org/release/hwloc/v2.9/hwloc-2.9.1.tar.gz + "2.9.0": + sha256: "9d7d3450e0a5fea4cb80ca07dc8db939abb7ab62e2a7bb27f9376447658738ec" + url: https://download.open-mpi.org/release/hwloc/v2.9/hwloc-2.9.0.tar.gz + "2.8.0": + sha256: "20b2bd4df436827d8e50f7afeafb6f967259f2fb374ce7330244f8d0ed2dde6f" + url: https://download.open-mpi.org/release/hwloc/v2.8/hwloc-2.8.0.tar.gz + "2.7.2": + sha256: "407d2712b1c9026787461ddb62044fa9b5c6007755ca37652b360d837a75344f" + url: https://download.open-mpi.org/release/hwloc/v2.7/hwloc-2.7.2.tar.gz diff --git a/recipes/hwloc/all/conanfile.py b/recipes/hwloc/all/conanfile.py new file mode 100644 index 0000000000000..ac1264a7b4049 --- /dev/null +++ b/recipes/hwloc/all/conanfile.py @@ -0,0 +1,114 @@ +from conan import ConanFile +from conan.tools.apple import is_apple_os, fix_apple_shared_install_name +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, rm, rmdir +from conan.tools.gnu import Autotools, AutotoolsToolchain, PkgConfigDeps +from conan.tools.layout import basic_layout +import os + +required_conan_version = ">=1.53.0" + + +class HwlocConan(ConanFile): + name = "hwloc" + description = "Portable Hardware Locality (hwloc)" + topics = ("hardware", "topology") + license = "BSD-3-Clause" + homepage = "https://www.open-mpi.org/projects/hwloc/" + url = "https://github.com/conan-io/conan-center-index" + package_type = "library" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_libxml2": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "with_libxml2": False + } + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + self.settings.rm_safe("compiler.cppstd") + self.settings.rm_safe("compiler.libcxx") + + def requirements(self): + if self.options.with_libxml2: + self.requires("libxml2/2.9.12") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def layout(self): + if self.settings.os == "Windows": + cmake_layout(self, src_folder="src") + else: + basic_layout(self, src_folder="src") + + def generate(self): + if self.settings.os == "Windows": + deps = CMakeDeps(self) + deps.generate() + tc = CMakeToolchain(self) + tc.cache_variables["HWLOC_ENABLE_TESTING"] = 'OFF' + tc.cache_variables["HWLOC_SKIP_LSTOPO"] = 'ON' + tc.cache_variables["HWLOC_SKIP_TOOLS"] = 'ON' + tc.cache_variables["HWLOC_SKIP_INCLUDES"] = 'OFF' + tc.cache_variables["HWLOC_WITH_OPENCL"] = 'OFF' + tc.cache_variables["HWLOC_WITH_CUDA"] = 'OFF' + tc.cache_variables["HWLOC_BUILD_SHARED_LIBS"] = self.options.shared + tc.cache_variables["HWLOC_WITH_LIBXML2"] = self.options.with_libxml2 + tc.generate() + else: + deps = PkgConfigDeps(self) + deps.generate() + tc = AutotoolsToolchain(self) + if not self.options.with_libxml2: + tc.configure_args.extend(["--disable-libxml2"]) + tc.configure_args.extend(["--disable-io", "--disable-cairo"]) + tc.generate() + + def build(self): + if self.settings.os == "Windows": + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join("contrib", "windows-cmake")) + cmake.build() + else: + autotools = Autotools(self) + autotools.configure() + autotools.make() + + def package(self): + copy(self, "COPYING", self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + if self.settings.os == "Windows": + cmake = CMake(self) + cmake.install() + # remove PDB files + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + else: + autotools = Autotools(self) + autotools.install() + fix_apple_shared_install_name(self) + # remove tools + rmdir(self, os.path.join(self.package_folder, "bin")) + + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + rm(self, "*.la", os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.set_property("pkg_config_name", "hwloc") + self.cpp_info.libs = ["hwloc"] + + if not self.options.shared: + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.system_libs = ["m"] + if is_apple_os(self): + self.cpp_info.frameworks = ['IOKit', 'Foundation', 'CoreFoundation'] diff --git a/recipes/hwloc/all/test_package/CMakeLists.txt b/recipes/hwloc/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..ea8c4a4511afc --- /dev/null +++ b/recipes/hwloc/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES C) + +find_package(hwloc REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.c) +target_link_libraries(${PROJECT_NAME} PRIVATE hwloc::hwloc) diff --git a/recipes/hwloc/all/test_package/conanfile.py b/recipes/hwloc/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0a6bc68712d90 --- /dev/null +++ b/recipes/hwloc/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import CMake, cmake_layout +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/hwloc/all/test_package/test_package.c b/recipes/hwloc/all/test_package/test_package.c new file mode 100644 index 0000000000000..a8a04af2fe797 --- /dev/null +++ b/recipes/hwloc/all/test_package/test_package.c @@ -0,0 +1,10 @@ +#include + +int main(void) { + hwloc_topology_t topology; + + hwloc_topology_init(&topology); + hwloc_topology_destroy(topology); + + return 0; +} diff --git a/recipes/hwloc/config.yml b/recipes/hwloc/config.yml new file mode 100644 index 0000000000000..724950afba073 --- /dev/null +++ b/recipes/hwloc/config.yml @@ -0,0 +1,9 @@ +versions: + "2.9.1": + folder: all + "2.9.0": + folder: all + "2.8.0": + folder: all + "2.7.2": + folder: all