diff --git a/recipes/tiny-dnn/all/CMakeLists.txt b/recipes/tiny-dnn/all/CMakeLists.txt new file mode 100644 index 0000000000000..b71c882d9d33f --- /dev/null +++ b/recipes/tiny-dnn/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory(source_subfolder) diff --git a/recipes/tiny-dnn/all/conandata.yml b/recipes/tiny-dnn/all/conandata.yml index d4bc0d96f6fbf..70d5405c3754a 100644 --- a/recipes/tiny-dnn/all/conandata.yml +++ b/recipes/tiny-dnn/all/conandata.yml @@ -1,4 +1,4 @@ sources: "cci.20201023": - sha256: 123dabe15b019938e04c7ccdd22c8423ceae091f4bd2fb878f972a2ea031d4b9 - url: https://github.com/tiny-dnn/tiny-dnn/archive/c0f576f5cb7b35893f62127cb7aec18f77a3bcc5.tar.gz + url: "https://github.com/tiny-dnn/tiny-dnn/archive/c0f576f5cb7b35893f62127cb7aec18f77a3bcc5.tar.gz" + sha256: "123dabe15b019938e04c7ccdd22c8423ceae091f4bd2fb878f972a2ea031d4b9" diff --git a/recipes/tiny-dnn/all/conanfile.py b/recipes/tiny-dnn/all/conanfile.py index e8b9f4b5fd498..b3a57165d52a3 100644 --- a/recipes/tiny-dnn/all/conanfile.py +++ b/recipes/tiny-dnn/all/conanfile.py @@ -1,7 +1,8 @@ -import os -import glob from conans import ConanFile, CMake, tools from conans.errors import ConanInvalidConfiguration +import os + +required_conan_version = ">=1.43.0" class TinyDnnConan(ConanFile): @@ -11,70 +12,96 @@ class TinyDnnConan(ConanFile): homepage = "https://github.com/tiny-dnn/tiny-dnn" description = "tiny-dnn is a C++14 implementation of deep learning." topics = ("header-only", "deep-learning", "embedded", "iot", "computational") - settings = "compiler", "os" - options = {"with_tbb": [True, False]} - default_options = {"with_tbb": False} + + settings = "os", "arch", "compiler", "build_type" + options = { + "with_tbb": [True, False], + } + default_options = { + "with_tbb": False, + } + + exports_sources = "CMakeLists.txt" + # TODO: if you move this recipe to CMakeDeps, be aware that tiny-dnn + # relies on CMake variables which are not defined in CMakeDeps, only + # in cmake_find_package. So patch it before. + generators = "cmake", "cmake_find_package" @property def _source_subfolder(self): return "source_subfolder" - def requirements(self): - self.requires("cereal/1.3.0") - self.requires("stb/20200203") - if self.options.with_tbb: - self.requires("tbb/2020.3") + @property + def _min_cppstd(self): + return "14" - def configure(self): - minimal_cpp_standard = "14" - if self.settings.compiler.cppstd: - tools.check_min_cppstd(self, minimal_cpp_standard) - minimal_version = { + @property + def _min_compilers_version(self): + return { "gcc": "5", "clang": "3.4", "apple-clang": "10", "Visual Studio": "14" } + + def requirements(self): + self.requires("cereal/1.3.1") + self.requires("stb/cci.20210713") + if self.options.with_tbb: + self.requires("onetbb/2020.3") + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._min_cppstd) + compiler = str(self.settings.compiler) - if compiler not in minimal_version: - self.output.warn( - "{} recipe lacks information about the {} compiler standard version support".format(self.name, compiler)) - self.output.warn( - "{} requires a compiler that supports at least C++{}".format(self.name, minimal_cpp_standard)) - return version = tools.Version(self.settings.compiler.version) - if version < minimal_version[compiler]: - raise ConanInvalidConfiguration("{} requires a compiler that supports at least C++{}".format(self.name, minimal_cpp_standard)) + if compiler in self._min_compilers_version and version < self._min_compilers_version[compiler]: + raise ConanInvalidConfiguration( + "{} requires a compiler that supports at least C++{}".format( + self.name, self._min_cppstd, + ) + ) def package_id(self): self.info.header_only() def source(self): - tools.get(**self.conan_data["sources"][self.version]) - os.rename(glob.glob("tiny-dnn-*")[0], self._source_subfolder) + tools.get(**self.conan_data["sources"][self.version], + destination=self._source_subfolder, strip_root=True) def build(self): - tools.replace_in_file(os.path.join(self._source_subfolder, "tiny_dnn", "util", "image.h"), "third_party/", "") + tools.replace_in_file( + os.path.join(self._source_subfolder, "tiny_dnn", "util", "image.h"), + "third_party/", "", + ) def package(self): self.copy("LICENSE", dst="licenses", src=self._source_subfolder) cmake = CMake(self) cmake.definitions["USE_TBB"] = self.options.with_tbb cmake.definitions["USE_GEMMLOWP"] = False - cmake.configure(source_folder=self._source_subfolder) + cmake.configure() cmake.install() tools.rmdir(os.path.join(self.package_folder, "share")) def package_info(self): + self.cpp_info.set_property("cmake_file_name", "tinydnn") + self.cpp_info.set_property("cmake_target_name", "TinyDNN::tiny_dnn") + # TODO: back to global scope in conan v2 once cmake_find_package* generators removed + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["tinydnn"].system_libs = ["pthread"] + if self.options.with_tbb: + self.cpp_info.components["tinydnn"].defines = ["CNN_USE_TBB=1"] + + # TODO: to remove in conan v2 once cmake_find_package* generators removed self.cpp_info.filenames["cmake_find_package"] = "tinydnn" self.cpp_info.filenames["cmake_find_package_multi"] = "tinydnn" self.cpp_info.names["cmake_find_package"] = "TinyDNN" self.cpp_info.names["cmake_find_package_multi"] = "TinyDNN" self.cpp_info.components["tinydnn"].names["cmake_find_package"] = "tiny_dnn" self.cpp_info.components["tinydnn"].names["cmake_find_package_multi"] = "tiny_dnn" + self.cpp_info.components["tinydnn"].set_property("cmake_target_name", "TinyDNN::tiny_dnn") self.cpp_info.components["tinydnn"].requires = ["cereal::cereal", "stb::stb"] - if self.settings.os == "Linux": - self.cpp_info.components["tinydnn"].system_libs = ["pthread"] if self.options.with_tbb: - self.cpp_info.components["tinydnn"].requires.append("tbb::tbb") - self.cpp_info.components["tinydnn"].defines = ["CNN_USE_TBB=1"] + self.cpp_info.components["tinydnn"].requires.append("onetbb::onetbb") diff --git a/recipes/tiny-dnn/all/test_package/conanfile.py b/recipes/tiny-dnn/all/test_package/conanfile.py index 5562d97f4d2bb..38f4483872d47 100644 --- a/recipes/tiny-dnn/all/test_package/conanfile.py +++ b/recipes/tiny-dnn/all/test_package/conanfile.py @@ -1,10 +1,9 @@ -import os.path - from conans import ConanFile, CMake, tools +import os class TestPackageConan(ConanFile): - settings = "os", "compiler", "build_type", "arch" + settings = "os", "arch", "compiler", "build_type" generators = "cmake", "cmake_find_package_multi" def build(self): @@ -13,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)