-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconanfile.py
64 lines (53 loc) · 2.51 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
#!/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], "use_boost": [True, False]}
default_options = {"use_17_standard": True, "use_boost": False}
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"
else:
cmake.definitions["CMAKE_CXX_STANDARD"] = "11"
if self.options.use_boost or not self.options.use_17_standard:
cmake.definitions["BSONCXX_POLY_USE_BOOST"] = True
cmake.definitions["BSONCXX_POLY_USE_STD"] = False
cmake.definitions["BSONCXX_POLY_USE_MNMLSTC"] = False
if self.settings.os == "Windows":
cmake.definitions["_ENABLE_EXTENDED_ALIGNED_STORAGE"] = True
else:
cmake.definitions["BSONCXX_POLY_USE_STD"] = True
if self.settings.os != "Windows":
cmake.definitions["CMAKE_POSITION_INDEPENDENT_CODE"] = True
cmake.configure(build_folder=self.build_subfolder)
cmake.build()
cmake.install()
def requirements(self):
if self.options.use_boost or not self.options.use_17_standard:
self.requires("boost/[>=1.64.0]@conan/stable")
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")