-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathconanfile.py
More file actions
120 lines (100 loc) · 3.7 KB
/
conanfile.py
File metadata and controls
120 lines (100 loc) · 3.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from conan import ConanFile
from conan.tools.files import get, copy, rmdir
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
from conan.tools.env import VirtualBuildEnv
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
import os
required_conan_version = ">=2.18.1"
class SQLGenConan(ConanFile):
name = "sqlgen"
description = "sqlgen is an ORM and SQL query generator for C++-20, similar to Python's SQLAlchemy/SQLModel or Rust's Diesel."
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/getml/sqlgen"
topics = ("duckdb", "mypy", "postgres", "sqlite", "orm")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_mysql": [True, False],
"with_postgres": [True, False],
"with_sqlite3": [True, False],
"with_duckdb": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_mysql": False,
"with_postgres": True,
"with_sqlite3": True,
"with_duckdb": False,
}
def config_options(self):
if self.settings.os == "Windows":
self.options.rm_safe("fPIC")
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def requirements(self):
self.requires("reflect-cpp/0.22.0", transitive_headers=True)
if self.options.with_mysql:
self.requires("mariadb-connector-c/3.4.3", transitive_headers=True)
if self.options.with_postgres:
self.requires("libpq/17.5", transitive_headers=True)
if self.options.with_sqlite3:
self.requires("sqlite3/3.49.1", transitive_headers=True)
if self.options.with_duckdb:
self.requires("duckdb/1.1.3", transitive_headers=True)
def build_requirements(self):
self.tool_requires("cmake/[>=3.23 <4]")
def validate(self):
if self.settings.get_safe("compiler.cppstd"):
check_min_cppstd(self, self._min_cppstd)
def layout(self):
cmake_layout(self, src_folder=".")
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
def generate(self):
env = VirtualBuildEnv(self)
env.generate()
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self)
tc.cache_variables["SQLGEN_BUILD_SHARED"] = self.options.shared
tc.cache_variables["SQLGEN_MYSQL"] = self.options.with_mysql
tc.cache_variables["SQLGEN_POSTGRES"] = self.options.with_postgres
tc.cache_variables["SQLGEN_SQLITE3"] = self.options.with_sqlite3
tc.cache_variables["SQLGEN_DUCKDB"] = self.options.with_duckdb
tc.cache_variables["SQLGEN_USE_VCPKG"] = False
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
copy(
self,
pattern="LICENSE",
dst=os.path.join(self.package_folder, "licenses"),
src=self.source_folder,
)
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
def package_info(self):
self.cpp_info.libs = ["sqlgen"]
@property
def _min_cppstd(self):
return 20
@property
def _compilers_minimum_version(self):
return {
"Visual Studio": "17",
"msvc": "1938",
"gcc": "11",
"clang": "13",
"apple-clang": "15",
}