-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathconanfile.py
83 lines (71 loc) · 2.99 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake, tools
import os
class FmtConan(ConanFile):
name = "fmt"
homepage = "https://github.com/fmtlib/fmt"
description = "A safe and fast alternative to printf and IOStreams."
url = "https://github.com/conan-io/conan-center-index"
author = "Bincrafters <[email protected]>"
license = "MIT"
exports_sources = ['CMakeLists.txt']
generators = 'cmake'
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "header_only": [True, False], "fPIC": [True, False], "with_fmt_alias": [True, False]}
default_options = {"shared": False, "header_only": False, "fPIC": True, "with_fmt_alias": False}
@property
def _source_subfolder(self):
return "source_subfolder"
@property
def _build_subfolder(self):
return "build_subfolder"
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.header_only:
self.settings.clear()
del self.options.fPIC
del self.options.shared
def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["FMT_DOC"] = False
cmake.definitions["FMT_TEST"] = False
cmake.definitions["FMT_INSTALL"] = True
cmake.definitions["FMT_LIB_DIR"] = "lib"
cmake.configure(build_folder=self._build_subfolder)
return cmake
def build(self):
if not self.options.header_only:
cmake = self._configure_cmake()
cmake.build()
def package(self):
self.copy("LICENSE.rst", dst="licenses", src=self._source_subfolder)
if self.options.header_only:
src_dir = os.path.join(self._source_subfolder, "src")
header_dir = os.path.join(self._source_subfolder, "include")
dst_dir = os.path.join("include", "fmt")
self.copy("*.h", dst="include", src=header_dir)
self.copy("*.cc", dst=dst_dir, src=src_dir)
else:
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))
def package_info(self):
if self.options.with_fmt_alias:
self.cpp_info.defines.append("FMT_STRING_ALIAS=1")
if self.options.header_only:
self.info.header_only()
self.cpp_info.defines = ["FMT_HEADER_ONLY"]
else:
self.cpp_info.libs = tools.collect_libs(self)
if self.options.shared:
self.cpp_info.defines.append('FMT_SHARED')
self.cpp_info.bindirs.append("lib")