|
| 1 | +from conan import ConanFile, tools |
| 2 | +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout |
| 3 | +from conan.tools.files import get |
| 4 | + |
| 5 | +required_conan_version = ">=2.0.0" |
| 6 | + |
| 7 | + |
| 8 | +class SecpConan(ConanFile): |
| 9 | + name = "secp256k1" |
| 10 | + description = "High-performance high-assurance C library for digital signatures and other cryptographic primitives on the secp256k1 elliptic curve." |
| 11 | + url = "https://github.com/bitcoin-core/secp256k1.git" |
| 12 | + package_type = "library" |
| 13 | + settings = "os", "arch", "compiler", "build_type" |
| 14 | + options = {"shared": [True, False], "fPIC": [True, False]} |
| 15 | + default_options = {"shared": False, "fPIC": True} |
| 16 | + |
| 17 | + def config_options(self): |
| 18 | + if self.settings.os == "Windows": |
| 19 | + del self.options.fPIC |
| 20 | + |
| 21 | + def layout(self): |
| 22 | + cmake_layout(self, src_folder="src") |
| 23 | + |
| 24 | + def source(self): |
| 25 | + get(self, **self.conan_data["sources"][self.version], strip_root=True) |
| 26 | + |
| 27 | + def generate(self): |
| 28 | + tc = CMakeToolchain(self) |
| 29 | + # Disable all tests and benchmarks. |
| 30 | + tc.variables["SECP256K1_INSTALL"] = True |
| 31 | + tc.variables["SECP256K1_BUILD_BENCHMARK"] = False |
| 32 | + tc.variables["SECP256K1_BUILD_TESTS"] = False |
| 33 | + tc.variables["SECP256K1_BUILD_EXHAUSTIVE_TESTS"] = False |
| 34 | + tc.variables["SECP256K1_BUILD_CTIME_TESTS"] = False |
| 35 | + tc.variables["SECP256K1_BUILD_EXAMPLES"] = False |
| 36 | + tc.generate() |
| 37 | + |
| 38 | + def build(self): |
| 39 | + cmake = CMake(self) |
| 40 | + cmake.verbose = True |
| 41 | + cmake.configure() |
| 42 | + cmake.build() |
| 43 | + |
| 44 | + def package(self): |
| 45 | + cmake = CMake(self) |
| 46 | + cmake.verbose = True |
| 47 | + cmake.install() |
| 48 | + |
| 49 | + def package_info(self): |
| 50 | + self.cpp_info.libs = ["secp256k1"] |
| 51 | + self.cpp_info.set_property("cmake_file_name", "secp256k1") |
| 52 | + self.cpp_info.set_property("cmake_target_name", "secp256k1::secp256k1") |
0 commit comments