forked from bincrafters/conan-libqrencode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
95 lines (72 loc) · 2.92 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake, tools
import os
class LibqrencodeConan(ConanFile):
name = "libqrencode"
version = "4.0.0"
url = "https://github.com/bitprim/conan-libqrencode"
description = "A fast and compact QR Code encoding library"
license = "LGPL-2.1, LGPL-3.0"
exports = ["LICENSE.md"]
exports_sources = ["CMakeLists.txt", "sources.patch"]
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False]
}
default_options = "shared=False", "fPIC=True"
build_policy = "missing"
requires = (
"libiconv/1.15@bitprim/stable",
"libpng/1.6.34@bitprim/stable"
)
@property
def msvc_mt_build(self):
return "MT" in str(self.settings.compiler.runtime)
@property
def fPIC_enabled(self):
if self.settings.compiler == "Visual Studio":
return False
else:
return self.options.fPIC
@property
def is_shared(self):
# if self.options.shared and self.msvc_mt_build:
if self.settings.compiler == "Visual Studio" and self.msvc_mt_build:
return False
else:
return self.options.shared
def configure(self):
del self.settings.compiler.libcxx #Pure-C
def config_options(self):
self.output.info('*-*-*-*-*-* def config_options(self):')
if self.settings.compiler == "Visual Studio":
self.options.remove("fPIC")
if self.options.shared and self.msvc_mt_build:
self.options.remove("shared")
def source(self):
source_url = "https://github.com/fukuchi/libqrencode"
tools.get("{0}/archive/v{1}.tar.gz".format(source_url, self.version))
extracted_dir = self.name + "-" + self.version
tools.patch(base_path=extracted_dir, patch_file="sources.patch")
#Rename to "sources" is a convention to simplify later steps
os.rename(extracted_dir, "sources")
def build(self):
cmake = CMake(self)
cmake.verbose = True
cmake.definitions["WITH_TOOLS"] = False
cmake.definitions["WITH_TESTS"] = False
cmake.definitions["CMAKE_POSITION_INDEPENDENT_CODE"] = self.fPIC_enabled
cmake.configure()
cmake.build()
def package(self):
self.copy(pattern="qrencode.h", dst="include", src="sources", keep_path=False)
self.copy(pattern="*.dll", dst="bin", src="bin", keep_path=False)
self.copy(pattern="*.lib", dst="lib", src="lib", keep_path=False)
self.copy(pattern="*.a", dst="lib", src="lib", keep_path=False)
self.copy(pattern="*.so*", dst="lib", src="lib", keep_path=False)
self.copy(pattern="*.dylib", dst="lib", src="lib", keep_path=False)
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)