forked from edwardstock/toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
86 lines (70 loc) · 2.26 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
import os
from conan import ConanFile
from conan.tools.cmake import cmake_layout, CMakeToolchain, CMakeDeps, CMake
def get_version():
with open(os.path.join(os.path.dirname(__file__), 'version.info'), 'r') as f:
content = f.read()
try:
content = content.decode()
except AttributeError:
pass
return content.strip()
class ToolboxConan(ConanFile):
name = "toolbox"
version = get_version()
license = "MIT"
author = "Eduard Maximovich [email protected]"
url = "https://github.com/edwardstock/toolbox"
description = "Lightweight everyday C++ helpers"
topics = ("cpp-helpers", "helpers")
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False]}
default_options = {
"shared": False
}
exports = "version.info"
exports_sources = (
"cfg/*",
"modules/*",
"options.cmake",
"include/*",
"tests/*",
"src/*",
"CMakeLists.txt",
"conanfile.py",
"LICENSE",
"README.md"
)
def layout(self):
cmake_layout(self)
def generate(self):
# This generates "conan_toolchain.cmake" in self.generators_folder
tc = CMakeToolchain(self)
tc.generate()
# # This generates "foo-config.cmake" and "bar-config.cmake" in self.generators_folder
deps = CMakeDeps(self)
deps.generate()
def build_requirements(self):
self.test_requires("gtest/1.13.0")
def build(self):
cmake = CMake(self)
opts = {
'toolbox_BUILD_SHARED_LIBS': "Off",
}
if self.options.shared:
opts['toolbox_BUILD_SHARED_LIBS'] = "On"
cmake.configure(variables=opts)
cmake.build(target="toolbox")
def package(self):
cmake = CMake(self)
cmake.install()
def package_info(self):
self.cpp_info.includedirs = ['include']
self.cpp_info.bindirs = ["bin"]
self.cpp_info.libsdirs = ["lib", "lib/Debug", "lib/Release"]
self.cpp_info.libs = ["toolbox"]
def test(self):
cmake = CMake(self)
cmake.configure([], {'toolbox_BUILD_TESTS': 'On'})
cmake.build(target="toolbox-test")
self.run("bin/toolbox-test")