This repository has been archived by the owner on Sep 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconanfile.py
72 lines (59 loc) · 2.87 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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake, tools
import os
class GflagsConan(ConanFile):
name = "gflags"
version = "2.2.2"
description = "The gflags package contains a C++ library that implements commandline flags processing"
topics = ("conan", "gflags", "cli", "flags")
url = "https://github.com/bincrafters/conan-gflags"
homepage = "https://github.com/gflags/gflags"
license = 'BSD-3-Clause'
author = "Bincrafters <bincrafters@gmail.com>"
exports = ["LICENSE.md"]
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False], "nothreads": [True, False], "namespace": "ANY"}
default_options = {'shared': False, 'fPIC': True, 'nothreads': True, 'namespace': 'gflags'}
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"
def configure(self):
if self.settings.os == "Windows":
self.options.remove("fPIC")
def source(self):
sha256 = "34af2f15cf7367513b352bdcd2493ab14ce43692d2dcd9dfc499492966c64dcf"
tools.get("{0}/archive/v{1}.tar.gz".format(self.homepage, self.version), sha256=sha256)
os.rename("%s-%s" % (self.name, self.version), self._source_subfolder)
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared
cmake.definitions["BUILD_STATIC_LIBS"] = not self.options.shared
cmake.definitions["BUILD_gflags_LIB"] = not self.options.nothreads
cmake.definitions["BUILD_gflags_nothreads_LIB"] = self.options.nothreads
cmake.definitions["BUILD_PACKAGING"] = False
cmake.definitions["BUILD_TESTING"] = False
cmake.definitions["INSTALL_HEADERS"] = True
cmake.definitions["INSTALL_SHARED_LIBS"] = self.options.shared
cmake.definitions["INSTALL_STATIC_LIBS"] = not self.options.shared
cmake.definitions["REGISTER_BUILD_DIR"] = False
cmake.definitions["REGISTER_INSTALL_PREFIX"] = False
cmake.definitions["GFLAGS_NAMESPACE"] = self.options.namespace
cmake.configure(build_folder=self._build_subfolder)
return cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
def package(self):
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
self.copy("Findgflags.cmake", ".", ".")
self.copy("COPYING.txt", dst="licenses", src=self._source_subfolder)
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
if self.settings.os == "Windows":
self.cpp_info.libs.extend(['shlwapi'])
elif self.settings.os != "Android":
self.cpp_info.libs.extend(["pthread", "m"])