This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
executable file
·89 lines (75 loc) · 3.31 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake, tools
import os
class PlibsysConan(ConanFile):
name = "plibsys"
version = "0.0.4"
url = "https://github.com/saprykin/conan-plibsys"
homepage = "https://github.com/saprykin/plibsys"
description = "Highly portable C system library"
license = "MIT"
exports = ["LICENSE.md"]
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
options = {"shared": [True, False]}
default_options = "shared=False"
source_subfolder = "source_subfolder"
def source(self):
source_url = "https://github.com/saprykin/plibsys"
tools.get("{0}/archive/{1}.tar.gz".format(source_url, self.version))
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self.source_subfolder)
def configure(self):
del self.settings.compiler.libcxx
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["PLIBSYS_TESTS"] = False
cmake.definitions["PLIBSYS_BUILD_STATIC"] = not self.options.shared
cmake.definitions["PLIBSYS_COVERAGE"] = False
cmake.configure()
return cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
def package(self):
# Copy license
self.copy(pattern="COPYING", dst="licenses", src=self.source_subfolder)
# Copy libraries
if self.settings.os == "Windows":
if self.options.shared:
if self.settings.compiler == 'Visual Studio':
self.copy(pattern="*.dll", dst="bin", src="bin", keep_path=False)
self.copy(pattern="*plibsys.lib", dst="lib", src="lib", keep_path=False)
else:
self.copy(pattern="*plibsys.lib", dst="lib", src=".", keep_path=False)
self.copy(pattern="*plibsys.dll.a", dst="lib", src=".", keep_path=False)
else:
if self.settings.compiler == 'Visual Studio':
self.copy(pattern="plibsysstatic.lib", dst="lib", src="lib", keep_path=False)
else:
self.copy(pattern="libplibsysstatic.a", dst="lib", src=".", keep_path=False)
else:
if self.options.shared:
if self.settings.os == "Macos":
self.copy(pattern="*.dylib", dst="lib", src=".", keep_path=False)
else:
self.copy(pattern="*.so*", dst="lib", src=".", keep_path=False)
else:
self.copy(pattern="*.a", dst="lib", src=".", keep_path=False)
# Copy headers
self.copy(pattern="*.h", dst="include", src=self.source_subfolder, keep_path=False)
self.copy(pattern="*.h", dst="include", src=".", keep_path=False)
def package_info(self):
if self.options.shared:
self.cpp_info.libs = ['plibsys']
else:
self.cpp_info.libs = ['plibsysstatic']
if self.settings.os == "Linux":
self.cpp_info.libs.append("pthread")
self.cpp_info.libs.append("rt")
self.cpp_info.libs.append("dl")
elif self.settings.os == "Windows":
self.cpp_info.libs.append("ws2_32")
self.cpp_info.includedirs.append("include")