Skip to content

Commit f8d25e6

Browse files
committed
Add conanfile
1 parent 1841ef1 commit f8d25e6

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

conanfile.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
from conan import ConanFile
2+
from conan.errors import ConanInvalidConfiguration
3+
from conan.tools.build.cppstd import check_min_cppstd
4+
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
5+
from conan.tools.files import copy
6+
from conan.tools.scm import Version
7+
import os
8+
9+
required_conan_version = ">=2.0"
10+
11+
class SparrowIPCRecipe(ConanFile):
12+
name = "sparrow-ipc"
13+
description = "C++20 library for memory-mapped serialization of Apache Arrow data."
14+
license = "BSD-3-Clause"
15+
author = "QuantStack"
16+
url = "https://github.com/QuantStack/sparrow-ipc"
17+
homepage = "https://github.com/QuantStack/sparrow-ipc"
18+
topics = ("arrow", "apache arrow", "columnar format", "dataframe", "ipc", "serialization", "deserialization", "flatbuffers")
19+
package_type = "library"
20+
settings = "os", "arch", "compiler", "build_type"
21+
generators = "CMakeDeps"
22+
exports_sources = "include/*", "src/*", "cmake/*", "CMakeLists.txt", "LICENSE"
23+
options = {
24+
"shared": [True, False],
25+
"fPIC": [True, False],
26+
"build_tests": [True, False],
27+
}
28+
default_options = {
29+
"shared": False,
30+
"fPIC": True,
31+
"build_tests": False,
32+
}
33+
34+
def config_options(self):
35+
if self.settings.os == "Windows":
36+
del self.options.fPIC
37+
38+
def configure(self):
39+
if self.options.shared:
40+
self.options.rm_safe("fPIC")
41+
42+
def requirements(self):
43+
self.requires("sparrow/1.0.0")
44+
self.requires("flatbuffers/25.2.10")
45+
if self.options.get_safe("build_tests"):
46+
self.test_requires("doctest/2.4.12")
47+
48+
@property
49+
def _min_cppstd(self):
50+
return 20
51+
52+
@property
53+
def _compilers_minimum_version(self):
54+
return {
55+
"apple-clang": "16",
56+
"clang": "18",
57+
"gcc": "12",
58+
"msvc": "194"
59+
}
60+
61+
def validate(self):
62+
if self.settings.compiler.get_safe("cppstd"):
63+
check_min_cppstd(self, self._min_cppstd)
64+
65+
minimum_version = self._compilers_minimum_version.get(
66+
str(self.settings.compiler), False)
67+
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
68+
raise ConanInvalidConfiguration(
69+
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
70+
)
71+
72+
def layout(self):
73+
cmake_layout(self, src_folder=".")
74+
75+
def generate(self):
76+
tc = CMakeToolchain(self)
77+
tc.variables["SPARROW_IPC_BUILD_TESTS"] = self.options.build_tests
78+
tc.generate()
79+
80+
def build(self):
81+
cmake = CMake(self)
82+
cmake.configure()
83+
cmake.build()
84+
85+
def package(self):
86+
copy(self, "LICENSE",
87+
dst=os.path.join(self.package_folder, "licenses"),
88+
src=self.source_folder)
89+
cmake = CMake(self)
90+
cmake.install()
91+
92+
def package_info(self):
93+
self.cpp_info.libs = ["sparrow-ipc"]
94+
self.cpp_info.set_property("cmake_file_name", "sparrow-ipc")
95+
self.cpp_info.set_property("cmake_target_name", "sparrow-ipc::sparrow-ipc")

0 commit comments

Comments
 (0)