-
Notifications
You must be signed in to change notification settings - Fork 1
/
conanfile.py
70 lines (61 loc) · 3.05 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
from conans import ConanFile, CMake, tools
import os
class SimpleAmqpClientConan(ConanFile):
name = "SimpleAmqpClient"
version = "2.4.0"
license = "MIT"
description = "SimpleAmqpClient is an easy-to-use C++ wrapper around the rabbitmq-c C library"
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = "shared=True", "fPIC=True"
requires = ("rabbitmq-c/0.6.0@dbely/testing", "boost/[>=1.66.0]@conan/stable")
generators = "cmake", "cmake_find_package"
@property
def src_dir(self):
return "%s-%s" % (self.name, self.version)
def config_options(self):
if self.settings.os == "Windows":
self.options.remove("shared")
self.options.remove("fPIC")
def configure(self):
if self.settings.os != "Windows" and self.options.shared:
self.options["boost"].fPIC = True
def source(self):
tools.get("https://codeload.github.com/alanxz/SimpleAmqpClient/zip/v%s" % self.version,
sha1="931e2aa78fc011f8d1ea312541df75b1d5edd559")
cmakelist_tst = os.path.join(self.src_dir, "CMakeLists.txt")
tools.replace_in_file(cmakelist_tst, "PROJECT(SimpleAmqpClient)",
"""PROJECT(SimpleAmqpClient)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()""")
os.unlink("%s/Modules/FindRabbitmqc.cmake" % self.src_dir)
tools.replace_in_file(cmakelist_tst,
"SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules)",
"list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Modules)")
tools.replace_in_file(cmakelist_tst, "${Rabbitmqc_SSL_ENABLED}", "ON")
tools.replace_in_file(cmakelist_tst, "Rabbitmqc_LIBRARY", "rabbitmq-c_LIBRARIES")
tools.replace_in_file(cmakelist_tst, "Rabbitmqc", "rabbitmq-c")
tools.replace_in_file(cmakelist_tst, "Boost", "boost")
def build(self):
cmake = CMake(self)
if self.settings.os != "Windows":
cmake.definitions["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.fPIC
else:
cmake.definitions['BUILD_SHARED_LIBS'] = True
cmake.definitions["CMAKE_INSTALL_PREFIX"] = "install"
cmake.configure(source_folder=self.src_dir)
cmake.build()
cmake.install()
def package(self):
self.copy("*.h", dst=".", src="install")
self.copy("*.lib", dst="lib", src="install", keep_path=False)
self.copy("*.dll", dst="bin", src="install", keep_path=False)
self.copy("*.pdb", dst="bin", src="install", keep_path=False)
self.copy("*.so*", dst="lib", src="install", keep_path=False, symlinks=True)
self.copy("*.dylib", dst="lib", src="install", keep_path=False, symlinks=True)
self.copy("*.a", dst="lib", src="install", keep_path=False)
def package_info(self):
if self.settings.os == "Windows":
self.cpp_info.libs = [self.name+".2"]
else:
self.cpp_info.libs = [self.name]