Skip to content

Commit

Permalink
(#13386) onetbb: add version 2021.6.0
Browse files Browse the repository at this point in the history
* check compiler version for all Apple platforms

* add version 2021.6.0

* don't skip linter in v1 test package

* add required system libs for Linux/FreeBSD

Co-authored-by: Christian Günther <christian.guenther@authentic.network>

* raise ConanInvalidConfiguration when attempting to make static build

Co-authored-by: Christian Günther <christian.guenther@authentic.network>
  • Loading branch information
kambala-decapitator and cguentherTUChemnitz authored Oct 17, 2022
1 parent 64732d6 commit 0f355ca
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
3 changes: 3 additions & 0 deletions recipes/onetbb/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"2021.6.0":
url: "https://github.com/oneapi-src/oneTBB/archive/v2021.6.0.tar.gz"
sha256: "4897dd106d573e9dacda8509ca5af1a0e008755bf9c383ef6777ac490223031f"
"2021.3.0":
url: "https://github.com/oneapi-src/oneTBB/archive/v2021.3.0.tar.gz"
sha256: "8f616561603695bbb83871875d2c6051ea28f8187dbe59299961369904d1d49e"
28 changes: 23 additions & 5 deletions recipes/onetbb/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import is_apple_os
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, load, rmdir
from conan.tools.scm import Version
import os
import re

required_conan_version = ">=1.47.0"
required_conan_version = ">=1.51.3"


class OneTBBConan(ConanFile):
Expand All @@ -26,17 +27,21 @@ class OneTBBConan(ConanFile):
"fPIC": [True, False],
"tbbmalloc": [True, False],
"tbbproxy": [True, False],
"interprocedural_optimization": [True, False],
}
default_options = {
"shared": True,
"fPIC": True,
"tbbmalloc": False,
"tbbproxy": False,
"interprocedural_optimization": True,
}

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if not (Version(self.version) >= "2021.6.0" and self.options.shared and self.settings.os != "Android"):
del self.options.interprocedural_optimization
if Version(self.version) < "2021.2.0":
del self.options.shared
del self.options.fPIC
Expand All @@ -46,11 +51,12 @@ def configure(self):
del self.options.fPIC

def package_id(self):
del self.info.options.tbbmalloc
del self.info.options.tbbproxy
if Version(self.version) < "2021.6.0":
del self.info.options.tbbmalloc
del self.info.options.tbbproxy

def validate(self):
if (self.settings.os == "Macos"
if (is_apple_os(self)
and self.settings.compiler == "apple-clang"
and Version(self.settings.compiler.version) < "11.0"):
raise ConanInvalidConfiguration(
Expand All @@ -59,6 +65,12 @@ def validate(self):
self.version,
))
if not self.options.get_safe("shared", True):
if Version(self.version) >= "2021.6.0":
raise ConanInvalidConfiguration(
"Building oneTBB as a static library is highly discouraged and not supported "
"to avoid unforeseen issues like https://github.com/oneapi-src/oneTBB/issues/920. "
"Please consider fixing at least the aforementioned issue in upstream."
)
self.output.warn(
"oneTBB strongly discourages usage of static linkage")
if (self.options.tbbproxy
Expand All @@ -78,6 +90,10 @@ def generate(self):
toolchain = CMakeToolchain(self)
toolchain.variables["TBB_TEST"] = False
toolchain.variables["TBB_STRICT"] = False
if Version(self.version) >= "2021.6.0":
toolchain.variables["TBBMALLOC_BUILD"] = self.options.tbbmalloc
toolchain.variables["TBBMALLOC_PROXY_BUILD"] = self.options.tbbproxy
toolchain.variables["TBB_ENABLE_IPO"] = self.options.get_safe("interprocedural_optimization", False)
toolchain.generate()

def build(self):
Expand Down Expand Up @@ -120,7 +136,7 @@ def lib_name(name):
)
tbb.libs.append(lib_name("tbb{}".format(binary_version)))
if self.settings.os in ["Linux", "FreeBSD"]:
tbb.system_libs = ["dl", "rt", "pthread"]
tbb.system_libs = ["m", "dl", "rt", "pthread"]

# tbbmalloc
if self.options.tbbmalloc:
Expand All @@ -138,6 +154,8 @@ def lib_name(name):
tbbproxy.set_property("cmake_target_name", "TBB::tbbmalloc_proxy")
tbbproxy.libs = [lib_name("tbbmalloc_proxy")]
tbbproxy.requires = ["tbbmalloc"]
if self.settings.os in ["Linux", "FreeBSD"]:
tbbproxy.system_libs = ["m", "dl", "pthread"]

# TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed
self.cpp_info.names["cmake_find_package"] = "TBB"
Expand Down
1 change: 0 additions & 1 deletion recipes/onetbb/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# pylint: skip-file
from conans import ConanFile, CMake, tools
import os

Expand Down
2 changes: 2 additions & 0 deletions recipes/onetbb/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"2021.6.0":
folder: all
"2021.3.0":
folder: all
"2020.3":
Expand Down

0 comments on commit 0f355ca

Please sign in to comment.