diff --git a/recipes/onetbb/all/conanfile.py b/recipes/onetbb/all/conanfile.py index 57b1bd6404c1ee..0f5df681c32a4a 100644 --- a/recipes/onetbb/all/conanfile.py +++ b/recipes/onetbb/all/conanfile.py @@ -2,6 +2,7 @@ from conan.errors import ConanInvalidConfiguration from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout from conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get, load, rmdir +from conan.tools.gnu import PkgConfigDeps from conan.tools.scm import Version import os import re @@ -26,6 +27,7 @@ class OneTBBConan(ConanFile): "fPIC": [True, False], "tbbmalloc": [True, False], "tbbproxy": [True, False], + "tbbbind": [True, False], "interprocedural_optimization": [True, False], } default_options = { @@ -33,6 +35,7 @@ class OneTBBConan(ConanFile): "fPIC": True, "tbbmalloc": True, "tbbproxy": True, + "tbbbind": True, "interprocedural_optimization": True, } @@ -42,6 +45,8 @@ def export_sources(self): def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self.settings.os == "Macos": + del self.options.tbbbind if Version(self.version) < "2021.6.0" or self.settings.os == "Android": del self.options.interprocedural_optimization if Version(self.version) < "2021.2.0": @@ -53,8 +58,15 @@ def configure(self): self.options.rm_safe("fPIC") else: del self.options.tbbproxy + del self.options.tbbbind if not self.options.tbbmalloc: self.options.rm_safe("tbbproxy") + if self.options.get_safe("tbbbind"): + self.options["hwloc"].shared = False + + def requirements(self): + if self.options.get_safe("tbbbind"): + self.requires("hwloc/2.9.0") def layout(self): cmake_layout(self, src_folder="src") @@ -81,6 +93,8 @@ def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): + pkg_config_deps = PkgConfigDeps(self) + pkg_config_deps.generate() toolchain = CMakeToolchain(self) toolchain.variables["TBB_TEST"] = False toolchain.variables["TBB_STRICT"] = False @@ -90,6 +104,8 @@ def generate(self): toolchain.variables["TBB_ENABLE_IPO"] = self.options.interprocedural_optimization if Version(self.version) >= "2021.6.0" and self.options.get_safe("tbbproxy"): toolchain.variables["TBBMALLOC_PROXY_BUILD"] = self.options.tbbproxy + if Version(self.version) >= "2021.4.0": + toolchain.variables["TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH"] = not self.options.get_safe("tbbbind", False) toolchain.generate() def build(self): @@ -154,6 +170,13 @@ def lib_name(name): if self.settings.os in ["Linux", "FreeBSD"]: tbbproxy.system_libs = ["m", "dl", "pthread"] + # tbbbind + if self.options.get_safe("tbbbind", False): + tbbtbind = self.cpp_info.components["tbbtbind"] + + tbbtbind.set_property("cmake_target_name", "TBB::tbbbind") + tbbtbind.libs = [lib_name("tbbmalloc")] + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed self.cpp_info.names["cmake_find_package"] = "TBB" self.cpp_info.names["cmake_find_package_multi"] = "TBB"