|
| 1 | +import os |
| 2 | + |
| 3 | +from conans import ConanFile, CMake, tools |
| 4 | + |
| 5 | +class CerealConan(ConanFile): |
| 6 | + name = "cereal" |
| 7 | + description = "Serialization header-only library for C++11." |
| 8 | + license = "BSD-3-Clause" |
| 9 | + topics = ("conan", "cereal", "header-only", "serialization", "cpp11") |
| 10 | + homepage = "https://github.com/USCiLab/cereal" |
| 11 | + url = "https://github.com/conan-io/conan-center-index" |
| 12 | + exports_sources = "CMakeLists.txt" |
| 13 | + generators = "cmake" |
| 14 | + settings = "os" |
| 15 | + options = {"thread_safe": [True, False]} |
| 16 | + default_options = {"thread_safe": False} |
| 17 | + no_copy_source = True |
| 18 | + |
| 19 | + @property |
| 20 | + def _source_subfolder(self): |
| 21 | + return "source_subfolder" |
| 22 | + |
| 23 | + def source(self): |
| 24 | + tools.get(**self.conan_data["sources"][self.version]) |
| 25 | + os.rename(self.name + "-" + self.version, self._source_subfolder) |
| 26 | + |
| 27 | + def package(self): |
| 28 | + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) |
| 29 | + cmake = CMake(self) |
| 30 | + cmake.definitions["JUST_INSTALL_CEREAL"] = True |
| 31 | + cmake.configure() |
| 32 | + cmake.install() |
| 33 | + tools.rmdir(os.path.join(self.package_folder, "share")) |
| 34 | + |
| 35 | + def package_id(self): |
| 36 | + self.info.header_only() |
| 37 | + |
| 38 | + def package_info(self): |
| 39 | + if self.options.thread_safe: |
| 40 | + self.cpp_info.defines = ["CEREAL_THREAD_SAFE=1"] |
| 41 | + if self.settings.os == "Linux": |
| 42 | + self.cpp_info.system_libs.append("pthread") |
0 commit comments