forked from bisect-pt/conan-mongo-cxx-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
53 lines (43 loc) · 1.94 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake, tools
import os
class MongoCDriverConan(ConanFile):
name = "mongo-cxx-driver"
version = "3.3.0"
description = "C++ Driver for MongoDB"
url = "https://github.com/mongodb/mongo-cxx-driver"
license = "https://github.com/mongodb/mongo-cxx-driver/blob/r{0}/LICENSE".format(version)
settings = "os", "compiler", "arch", "build_type"
options = {"use_17_standard": [True, False]}
default_options = "use_17_standard=True"
requires = 'mongo-c-driver/[~=1.11]@bisect/stable'
exports_sources = ["CMakeLists.txt", "diff.patch"]
source_subfolder = "source_subfolder"
build_subfolder = "build_subfolder"
generators = "cmake"
def source(self):
tools.get("https://github.com/mongodb/mongo-cxx-driver/archive/r{0}.tar.gz".format(self.version))
extracted_dir = "mongo-cxx-driver-r{0}".format(self.version)
os.rename(extracted_dir, self.source_subfolder)
tools.patch(base_path=self.source_subfolder, patch_file="diff.patch")
def build(self):
cmake = CMake(self)
cmake.definitions["BUILD_SHARED_LIBS"] = True # todo: Support static
if self.options.use_17_standard:
cmake.definitions["CMAKE_CXX_STANDARD"] = "17"
cmake.definitions["BSONCXX_POLY_USE_STD"] = True
else:
self.output.fatal("Only C++17 supported for now. Support boost dependency?")
if self.settings.os != 'Windows':
cmake.definitions['CMAKE_POSITION_INDEPENDENT_CODE'] = True
cmake.configure(build_folder=self.build_subfolder)
cmake.build()
cmake.install()
def package(self):
self.copy(pattern="LICENSE*", src=self.source_subfolder)
# cmake installs all the files
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
if tools.os_info.is_linux:
self.cpp_info.libs.append("resolv")