-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
103 lines (89 loc) · 4.23 KB
/
conanfile.py
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from conans import ConanFile, tools, AutoToolsBuildEnvironment, CMake
from conans.model.version import Version
from conans.errors import ConanInvalidConfiguration
class LibpqxxRecipe(ConanFile):
name = "libpqxx"
version = "6.4.4"
settings = "os", "compiler", "build_type", "arch"
description = "The official C++ client API for PostgreSQL"
url = "https://github.com/zinnion/conan-libpqxx"
homepage = "https://github.com/jtv/libpqxx"
author = "Zinnion <[email protected]>"
license = "BSD-3-Clause"
topics = ("conan", "libpqxx", "postgres", "postgresql", "data-base")
generators = "cmake"
exports = "LICENSE.md"
exports_sources = "CMakeLists.txt"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
requires = "libpq/10.4@zinnion/stable"
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"
_autotools = None
def config_options(self):
if self.settings.os == "Windows":
self.options.remove("fPIC")
def configure(self):
compiler_version = Version(self.settings.compiler.version.value)
if self.settings.os == "Windows" and \
self.settings.compiler == "Visual Studio" and \
compiler_version < "14":
raise ConanInvalidConfiguration("Your MSVC version is too old, libpqxx requires C++14")
if self.settings.os == "Macos" and \
self.settings.compiler == "apple-clang" and \
compiler_version < "8.0":
raise ConanInvalidConfiguration(("libpqxx requires thread-local storage features,"
" could not be built by apple-clang < 8.0"))
def source(self):
sha256 = "6ae3a0113a242db6bb9d998943b7cc23699652d843dab702aa06a8b9330c171a"
tools.get("{0}/archive/{1}.tar.gz".format(self.homepage, self.version), sha256=sha256)
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)
def _configure_autotools(self):
if not self._autotools:
args = [
"--disable-documentation",
"--with-postgres-include={}".format(os.path.join(self.deps_cpp_info["libpq"].rootpath, "include")),
"--with-postgres-lib={}".format(os.path.join(self.deps_cpp_info["libpq"].rootpath, "lib")),
"--enable-static={}".format("no" if self.options.shared else "yes"),
"--enable-shared={}".format("yes" if self.options.shared else "no")
]
self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
env_vars = self._autotools.vars
env_vars["PG_CONFIG"] = os.path.join(self.deps_cpp_info["libpq"].rootpath, "bin", "pg_config")
self._autotools.configure(args=args, vars=env_vars)
return self._autotools
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["SKIP_BUILD_TEST"] = True
cmake.definitions["SKIP_PQXX_STATIC"] = True if self.options.shared else False
cmake.definitions["SKIP_PQXX_SHARED"] = False if self.options.shared else True
cmake.configure(build_folder=self._build_subfolder)
return cmake
def build(self):
if self.settings.os == "Windows":
cmake = self._configure_cmake()
cmake.build()
else:
with tools.chdir(self._source_subfolder):
autotools = self._configure_autotools()
autotools.make()
def package(self):
self.copy("COPYING", dst="licenses", src=self._source_subfolder)
if self.settings.os == "Windows":
cmake = self._configure_cmake()
cmake.install()
else:
with tools.chdir(self._source_subfolder):
autotools = self._configure_autotools()
autotools.install()
def package_info(self):
self.cpp_info.libs = ["pqxx", "pq"]
#self.cpp_info.libs = tools.collect_libs(self)
if self.settings.os == "Windows":
self.cpp_info.libs.append("Ws2_32")
elif self.settings.os == "Linux":
self.cpp_info.libs.append("pthread")