forked from bincrafters/conan-spdlog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
58 lines (48 loc) · 1.83 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake, tools
import os
class SpdlogConan(ConanFile):
name = "spdlog"
version = "1.1.0"
description = "Fast C++ logging library"
url = "https://github.com/bincrafters/conan-spdlog"
homepage = "https://github.com/gabime/spdlog"
author = "Bincrafters <[email protected]>"
license = "MIT"
exports = ["LICENSE.md"]
exports_sources = ["CMakeLists.txt"]
source_subfolder = "source_subfolder"
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
options = {"fmt_external": [True, False]}
default_options = "fmt_external=True"
def requirements(self):
if self.options.fmt_external:
self.requires("fmt/5.1.0@bincrafters/stable")
def source(self):
source_url = "https://github.com/gabime/spdlog"
tools.get("{0}/archive/v{1}.tar.gz".format(source_url, self.version))
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self.source_subfolder)
def configure_cmake(self):
cmake = CMake(self)
cmake.definitions["SPDLOG_BUILD_EXAMPLES"] = False
cmake.definitions["SPDLOG_BUILD_TESTING"] = False
cmake.definitions["SPDLOG_BUILD_BENCH"] = False
cmake.configure()
return cmake
def build(self):
cmake = self.configure_cmake()
cmake.build()
def package(self):
cmake = self.configure_cmake()
cmake.install()
self.copy(pattern="LICENSE", dst='licenses', src=self.source_subfolder)
def package_info(self):
if self.options.fmt_external:
self.cpp_info.defines.append("SPDLOG_FMT_EXTERNAL")
if self.settings.os == "Linux":
self.cpp_info.libs.append("pthread")
def package_id(self):
self.info.header_only()