Skip to content

Commit

Permalink
[onetbb] added hwloc / tbbbind support
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov committed Jun 15, 2023
1 parent b2d2b62 commit a91d644
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions recipes/onetbb/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,13 +27,15 @@ class OneTBBConan(ConanFile):
"fPIC": [True, False],
"tbbmalloc": [True, False],
"tbbproxy": [True, False],
"tbbbind": [True, False],
"interprocedural_optimization": [True, False],
}
default_options = {
"shared": True,
"fPIC": True,
"tbbmalloc": True,
"tbbproxy": True,
"tbbbind": True,
"interprocedural_optimization": True,
}

Expand All @@ -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":
Expand All @@ -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")
Expand All @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit a91d644

Please sign in to comment.