diff --git a/recipes/tbb/all/conandata.yml b/recipes/tbb/all/conandata.yml index e52230cdf338e..de98a3aa2d71d 100644 --- a/recipes/tbb/all/conandata.yml +++ b/recipes/tbb/all/conandata.yml @@ -1,16 +1,16 @@ sources: - "2019_u9": - url: "https://github.com/oneapi-src/oneTBB/archive/2019_U9.tar.gz" - sha256: "3f5ea81b9caa195f1967a599036b473b2e7c347117330cda99b79cfcf5b77c84" - "2020.0": - url: "https://github.com/oneapi-src/oneTBB/archive/v2020.0.tar.gz" - sha256: "57714f2d2cf33935db33cee93af57eb3ecd5a7bef40c1fb7ca4a41d79684b118" - "2020.1": - url: "https://github.com/oneapi-src/oneTBB/archive/v2020.1.tar.gz" - sha256: "7c96a150ed22bc3c6628bc3fef9ed475c00887b26d37bca61518d76a56510971" - "2020.2": - url: "https://github.com/oneapi-src/oneTBB/archive/v2020.2.tar.gz" - sha256: "4804320e1e6cbe3a5421997b52199e3c1a3829b2ecb6489641da4b8e32faf500" "2020.3": url: "https://github.com/oneapi-src/oneTBB/archive/v2020.3.tar.gz" sha256: "ebc4f6aa47972daed1f7bf71d100ae5bf6931c2e3144cf299c8cc7d041dca2f3" + "2020.2": + url: "https://github.com/oneapi-src/oneTBB/archive/v2020.2.tar.gz" + sha256: "4804320e1e6cbe3a5421997b52199e3c1a3829b2ecb6489641da4b8e32faf500" + "2020.1": + url: "https://github.com/oneapi-src/oneTBB/archive/v2020.1.tar.gz" + sha256: "7c96a150ed22bc3c6628bc3fef9ed475c00887b26d37bca61518d76a56510971" + "2020.0": + url: "https://github.com/oneapi-src/oneTBB/archive/v2020.0.tar.gz" + sha256: "57714f2d2cf33935db33cee93af57eb3ecd5a7bef40c1fb7ca4a41d79684b118" + "2019_u9": + url: "https://github.com/oneapi-src/oneTBB/archive/2019_U9.tar.gz" + sha256: "3f5ea81b9caa195f1967a599036b473b2e7c347117330cda99b79cfcf5b77c84" diff --git a/recipes/tbb/all/conanfile.py b/recipes/tbb/all/conanfile.py index 283294c4a8a2c..12a63359ae427 100644 --- a/recipes/tbb/all/conanfile.py +++ b/recipes/tbb/all/conanfile.py @@ -1,29 +1,39 @@ -import os +from conan.tools.microsoft import msvc_runtime_flag from conans import ConanFile, tools -from conans.errors import ConanInvalidConfiguration +from conans.errors import ConanInvalidConfiguration, ConanException +import os +import textwrap + +required_conan_version = ">=1.43.0" class TBBConan(ConanFile): + deprecated = "onetbb" + name = "tbb" license = "Apache-2.0" url = "https://github.com/conan-io/conan-center-index" homepage = "https://github.com/oneapi-src/oneTBB" - description = """Intel Threading Building Blocks (Intel TBB) lets you easily write parallel C++ -programs that take full advantage of multicore performance, that are portable and composable, and -that have future-proof scalability""" - topics = ("conan", "tbb", "threading", "parallelism", "tbbmalloc") - settings = "os", "compiler", "build_type", "arch" + description = ( + "Intel Threading Building Blocks (Intel TBB) lets you easily write " + "parallel C++ programs that take full advantage of multicore " + "performance, that are portable and composable, and that have " + "future-proof scalability" + ) + topics = ("tbb", "threading", "parallelism", "tbbmalloc") + + settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], "tbbmalloc": [True, False], - "tbbproxy": [True, False] + "tbbproxy": [True, False], } default_options = { "shared": True, "fPIC": True, "tbbmalloc": False, - "tbbproxy": False + "tbbproxy": False, } @property @@ -34,6 +44,21 @@ def _source_subfolder(self): def _settings_build(self): return getattr(self, "settings_build", self.settings) + @property + def _is_msvc(self): + return str(self.settings.compiler) in ["Visual Studio", "msvc"] + + @property + def _is_clanglc(self): + return self.settings.os == "Windows" and self.settings.compiler == "clang" + + @property + def _base_compiler(self): + base = self.settings.get_safe("compiler.base") + if base: + return self.settings.compiler.base + return self.settings.compiler + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -65,21 +90,6 @@ def build_requirements(self): if "CONAN_MAKE_PROGRAM" not in os.environ and not tools.which("make"): self.build_requires("make/4.2.1") - @property - def _base_compiler(self): - base = self.settings.get_safe("compiler.base") - if base: - return self.settings.compiler.base - return self.settings.compiler - - @property - def _is_msvc(self): - return self.settings.compiler == "Visual Studio" - - @property - def _is_clanglc(self): - return self.settings.os == "Windows" and self.settings.compiler == "clang" - def source(self): tools.get(**self.conan_data["sources"][self.version], strip_root=True, destination=self._source_subfolder) @@ -99,32 +109,34 @@ def add_flag(name, value): if self.version != "2019_u9" and self.settings.build_type == "Debug": tools.replace_in_file(os.path.join(self._source_subfolder, "Makefile"), "release", "debug") - if self._base_compiler == "Visual Studio": - tools.save(os.path.join(self._source_subfolder, "build", "big_iron_msvc.inc"), - # copy of big_iron.inc adapted for MSVC - """ -LIB_LINK_CMD = {}.exe -LIB_OUTPUT_KEY = /OUT: -LIB_LINK_FLAGS = -LIB_LINK_LIBS = -DYLIB_KEY = -override CXXFLAGS += -D__TBB_DYNAMIC_LOAD_ENABLED=0 -D__TBB_SOURCE_DIRECTLY_INCLUDED=1 -ITT_NOTIFY = -DLL = lib -LIBEXT = lib -LIBPREF = -LIBDL = -TBB.DLL = $(LIBPREF)tbb$(DEBUG_SUFFIX).$(LIBEXT) -LINK_TBB.LIB = $(TBB.DLL) -TBB.DEF = -TBB_NO_VERSION.DLL = -MALLOC.DLL = $(LIBPREF)tbbmalloc$(DEBUG_SUFFIX).$(LIBEXT) -LINK_MALLOC.LIB = $(MALLOC.DLL) -MALLOC.DEF = -MALLOC_NO_VERSION.DLL = -MALLOCPROXY.DLL = -MALLOCPROXY.DEF = -""".format("xilib" if self.settings.compiler == "intel" else "lib")) + if str(self._base_compiler) in ["Visual Studio", "msvc"]: + tools.save( + os.path.join(self._source_subfolder, "build", "big_iron_msvc.inc"), + # copy of big_iron.inc adapted for MSVC + textwrap.dedent("""\ + LIB_LINK_CMD = {}.exe + LIB_OUTPUT_KEY = /OUT: + LIB_LINK_FLAGS = + LIB_LINK_LIBS = + DYLIB_KEY = + override CXXFLAGS += -D__TBB_DYNAMIC_LOAD_ENABLED=0 -D__TBB_SOURCE_DIRECTLY_INCLUDED=1 + ITT_NOTIFY = + DLL = lib + LIBEXT = lib + LIBPREF = + LIBDL = + TBB.DLL = $(LIBPREF)tbb$(DEBUG_SUFFIX).$(LIBEXT) + LINK_TBB.LIB = $(TBB.DLL) + TBB.DEF = + TBB_NO_VERSION.DLL = + MALLOC.DLL = $(LIBPREF)tbbmalloc$(DEBUG_SUFFIX).$(LIBEXT) + LINK_MALLOC.LIB = $(MALLOC.DLL) + MALLOC.DEF = + MALLOC_NO_VERSION.DLL = + MALLOCPROXY.DLL = + MALLOCPROXY.DEF = + """.format("xilib" if self.settings.compiler == "intel" else "lib")) + ) extra = "" if self.options.shared else "extra_inc=big_iron_msvc.inc" else: extra = "" if self.options.shared else "extra_inc=big_iron.inc" @@ -159,20 +171,27 @@ def add_flag(name, value): # don't necessarily want to require when building this recipe. # Setting it to a dummy value prevents TBB from calling gcc. extra += " runtime=gnu" - elif str(self._base_compiler) == "Visual Studio": - if str(self._base_compiler.runtime) in ("MT", "MTd"): + elif str(self._base_compiler) in ["Visual Studio", "msvc"]: + if "MT" in msvc_runtime_flag(self): runtime = "vc_mt" else: - runtime = { - "8": "vc8", - "9": "vc9", - "10": "vc10", - "11": "vc11", - "12": "vc12", - "14": "vc14", - "15": "vc14.1", - "16": "vc14.2" - }[str(self._base_compiler.version)] + if self.settings.compiler == "Visual Studio": + runtime = { + "8": "vc8", + "9": "vc9", + "10": "vc10", + "11": "vc11", + "12": "vc12", + "14": "vc14", + "15": "vc14.1", + "16": "vc14.2" + }.get(str(self._base_compiler.version), "vc14.2") + else: + runtime = { + "190": "vc14", + "191": "vc14.1", + "192": "vc14.2" + }.get(str(self._base_compiler.version), "vc14.2") extra += " runtime=%s" % runtime if self.settings.compiler == "intel": @@ -182,7 +201,7 @@ def add_flag(name, value): make = tools.get_env("CONAN_MAKE_PROGRAM", tools.which("make") or tools.which("mingw32-make")) if not make: - raise ConanInvalidConfiguration("This package needs 'make' in the path to build") + raise ConanException("This package needs 'make' in the path to build") with tools.chdir(self._source_subfolder): # intentionally not using AutoToolsBuildEnvironment for now - it's broken for clang-cl @@ -226,29 +245,31 @@ def package(self): (fpath, fpath[0:fpath.rfind("." + extension) + len(extension) + 1])) def package_info(self): - self.cpp_info.names["cmake_find_package"] = "TBB" - self.cpp_info.names["cmake_find_package_multi"] = "TBB" + self.cpp_info.set_property("cmake_file_name", "TBB") + + suffix = "_debug" if self.settings.build_type == "Debug" else "" + # tbb - self.cpp_info.components["libtbb"].names["cmake_find_package"] = "tbb" - self.cpp_info.components["libtbb"].names["cmake_find_package_multi"] = "tbb" - self.cpp_info.components["libtbb"].libs = [self._lib_name("tbb")] - if self.settings.os == "Linux": + self.cpp_info.components["libtbb"].set_property("cmake_target_name", "TBB::tbb") + self.cpp_info.components["libtbb"].libs = ["tbb{}".format(suffix)] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["libtbb"].system_libs = ["dl", "rt", "pthread"] + # tbbmalloc if self.options.tbbmalloc: - self.cpp_info.components["tbbmalloc"].names["cmake_find_package"] = "tbbmalloc" - self.cpp_info.components["tbbmalloc"].names["cmake_find_package_multi"] = "tbbmalloc" - self.cpp_info.components["tbbmalloc"].libs = [self._lib_name("tbbmalloc")] - if self.settings.os == "Linux": + self.cpp_info.components["tbbmalloc"].set_property("cmake_target_name", "TBB::tbbmalloc") + self.cpp_info.components["tbbmalloc"].libs = ["tbbmalloc{}".format(suffix)] + if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.components["tbbmalloc"].system_libs = ["dl", "pthread"] + # tbbmalloc_proxy if self.options.tbbproxy: - self.cpp_info.components["tbbmalloc_proxy"].names["cmake_find_package"] = "tbbmalloc_proxy" - self.cpp_info.components["tbbmalloc_proxy"].names["cmake_find_package_multi"] = "tbbmalloc_proxy" - self.cpp_info.components["tbbmalloc_proxy"].libs = [self._lib_name("tbbmalloc_proxy")] + self.cpp_info.components["tbbmalloc_proxy"].set_property("cmake_target_name", "TBB::tbbmalloc_proxy") + self.cpp_info.components["tbbmalloc_proxy"].libs = ["tbbmalloc_proxy{}".format(suffix)] self.cpp_info.components["tbbmalloc_proxy"].requires = ["tbbmalloc"] - def _lib_name(self, name): - if self.settings.build_type == "Debug": - return name + "_debug" - return name + # TODO: to remove in conan v2 once cmake_find_package* generators removed + self.cpp_info.names["cmake_find_package"] = "TBB" + self.cpp_info.names["cmake_find_package_multi"] = "TBB" + self.cpp_info.components["libtbb"].names["cmake_find_package"] = "tbb" + self.cpp_info.components["libtbb"].names["cmake_find_package_multi"] = "tbb" diff --git a/recipes/tbb/all/test_package/CMakeLists.txt b/recipes/tbb/all/test_package/CMakeLists.txt index 85dbb31b4baef..d5a40167452f4 100644 --- a/recipes/tbb/all/test_package/CMakeLists.txt +++ b/recipes/tbb/all/test_package/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1) project(test_package CXX) include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) -conan_basic_setup() +conan_basic_setup(TARGETS) find_package(TBB REQUIRED CONFIG) diff --git a/recipes/tbb/all/test_package/conanfile.py b/recipes/tbb/all/test_package/conanfile.py index 7e2dfe859bb27..38f4483872d47 100644 --- a/recipes/tbb/all/test_package/conanfile.py +++ b/recipes/tbb/all/test_package/conanfile.py @@ -3,7 +3,7 @@ class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): @@ -12,6 +12,6 @@ def build(self): cmake.build() def test(self): - if not tools.cross_building(self.settings): + if not tools.cross_building(self): bin_path = os.path.join("bin", "test_package") self.run(bin_path, run_environment=True) diff --git a/recipes/tbb/config.yml b/recipes/tbb/config.yml index da9c8f2823030..3252e0ec85d9e 100644 --- a/recipes/tbb/config.yml +++ b/recipes/tbb/config.yml @@ -1,11 +1,11 @@ versions: - "2019_u9": + "2020.3": folder: all - "2020.0": + "2020.2": folder: all "2020.1": folder: all - "2020.2": + "2020.0": folder: all - "2020.3": + "2019_u9": folder: all