forked from memsharded/conan-zmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
196 lines (156 loc) · 7.88 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
from conans import ConanFile, CMake, tools
# import os
from ci_utils import BitprimCxx11ABIFixer
def option_on_off(option):
return "ON" if option else "OFF"
class ZMQConan(BitprimCxx11ABIFixer):
name = "libzmq"
version = "4.2.2"
version_flat = "4_2_2"
license = "LGPL"
url = "https://github.com/bitprim/bitprim-conan-zmq.git"
description = "ZMQ is a network, sockets on steroids library. Safe for use in commercial applications LGPL v3 with static linking exception"
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
"verbose": [True, False],
"glibcxx_supports_cxx11_abi": "ANY",
}
default_options = "shared=False", \
"fPIC=True", \
"verbose=True", \
"glibcxx_supports_cxx11_abi=_DUMMY_",
exports = "FindZeroMQ.cmake", "conan_*", "ci_utils/*"
generators = "cmake"
build_policy = "missing"
@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.settings.compiler == "Visual Studio" and self.msvc_mt_build:
return False
else:
return self.options.shared
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 configure(self):
BitprimCxx11ABIFixer.configure(self)
def package_id(self):
BitprimCxx11ABIFixer.package_id(self)
self.info.options.verbose = "ANY"
# #For Bitprim Packages libstdc++ and libstdc++11 are the same
# if self.settings.compiler == "gcc" or self.settings.compiler == "clang":
# if str(self.settings.compiler.libcxx) == "libstdc++" or str(self.settings.compiler.libcxx) == "libstdc++11":
# self.info.settings.compiler.libcxx = "ANY"
def source(self):
self.run("git -c http.sslVerify=false clone https://github.com/zeromq/libzmq.git")
# self.run("git clone https://github.com/zeromq/libzmq.git")
# self.run("git clone git@github.com:zeromq/libzmq.git")
self.run("cd libzmq && git checkout tags/v4.2.2 -b bitprim_4.2.2")
# tools.replace_in_file("libzmq/CMakeLists.txt", "project (ZeroMQ)", """project (ZeroMQ)
# include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
# conan_basic_setup()
# """)
tools.replace_in_file("libzmq/CMakeLists.txt", "project (ZeroMQ)", """project (ZeroMQ)
if(EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
remove_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
remove_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
if (NOT NOT_USE_CPP11_ABI)
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=1)
message( STATUS "Bitprim: Using _GLIBCXX_USE_CXX11_ABI=1")
else()
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
message( STATUS "Bitprim: Using _GLIBCXX_USE_CXX11_ABI=0")
endif()
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-macro-redefined")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-builtin-macro-redefined")
endif()
else()
message(WARNING "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first")
endif()
""")
def build(self):
# cmake = CMake(self.settings)
cmake = CMake(self)
verbose_str = '-DCMAKE_VERBOSE_MAKEFILE=%s' % (option_on_off(self.options.verbose),)
cxx11_abi_str = ''
if self.settings.compiler == "gcc":
if float(str(self.settings.compiler.version)) >= 5:
cxx11_abi_str = '-DNOT_USE_CPP11_ABI=OFF'
else:
cxx11_abi_str = '-DNOT_USE_CPP11_ABI=ON'
elif self.settings.compiler == "clang":
if str(self.settings.compiler.libcxx) == "libstdc++" or str(self.settings.compiler.libcxx) == "libstdc++11":
cxx11_abi_str = '-DNOT_USE_CPP11_ABI=OFF'
cmake_cmd_1 = 'cmake libzmq %s %s %s -DCMAKE_CXX_FLAGS="-std=c++11" -DCMAKE_SH="CMAKE_SH-NOTFOUND" -DZMQ_BUILD_TESTS=OFF -DZMQ_BUILD_FRAMEWORK=OFF' % (cmake.command_line, verbose_str, cxx11_abi_str)
cmake_cmd_2 = "cmake --build . %s" % cmake.build_config
self.output.info(self.settings.compiler)
self.output.info(self.settings.compiler.version)
self.output.info(cmake_cmd_1)
self.output.info(cmake_cmd_2)
self.run(cmake_cmd_1)
self.run(cmake_cmd_2)
# self.run('cmake libzmq %s -DZMQ_BUILD_TESTS=OFF -DZMQ_BUILD_FRAMEWORK=OFF' % cmake.command_line)
# self.run("cmake --build . %s" % cmake.build_config)
def package(self):
# self.copy_headers("*", "libzmq/include")
self.copy("*.h", dst="include", src="libzmq/include", keep_path=True)
self.copy("*.hpp", dst="include", src="libzmq/include", keep_path=True)
self.copy("FindZeroMQ.cmake")
if not self.options.shared:
self.copy("*libzmq*-mt-s*.lib", "lib", "lib", keep_path=False)
self.copy("*.a", "lib", "lib", keep_path=False) # Linux
else:
self.copy("*libzmq*-mt-%s.lib" % self.version_flat, "lib", "lib", keep_path=False)
self.copy("*libzmq*-mt-gd-%s.lib" % self.version_flat, "lib", "lib", keep_path=False)
self.copy("*.dll", "bin", "bin", keep_path=False)
self.copy("*.dylib", "lib", "lib", keep_path=False)
self.copy("libzmq.so*", "lib", "lib", keep_path=False) # Linux
def package_info(self):
if self.settings.os != "Windows":
# self.cpp_info.libs = ["zmq-static"] if not self.options.shared else ["zmq"]
self.cpp_info.libs = ["zmq"]
else:
if self.settings.compiler == "Visual Studio":
ver = ""
if str(self.settings.compiler.version) in ["11", "12", "14"]:
ver = "-v%s0" % self.settings.compiler.version
elif str(self.settings.compiler.version) == "15":
ver = "-v141"
else:
self.output.info(self.settings.compiler.version)
ver = "-"
# static, stat_fix = ("-static", "s") if not self.options.shared else ("", "")
stat_fix = "s" if not self.options.shared else ""
debug_fix = "gd" if self.settings.build_type == "Debug" else ""
fix = ("-%s%s" % (stat_fix, debug_fix)) if stat_fix or debug_fix else ""
# self.cpp_info.libs = ["libzmq%s%s-mt%s-%s" % (static, ver, fix, self.version_flat)]
# self.output.info("libzmq%s%s-mt%s-%s" % (static, ver, fix, self.version_flat))
self.cpp_info.libs = ["libzmq%s-mt%s-%s" % (ver, fix, self.version_flat)]
self.output.info("libzmq%s-mt%s-%s" % (ver, fix, self.version_flat))
else: # MinGW
self.cpp_info.libs = ["zmq"]
if not self.options.shared:
# if self.settings.compiler == "Visual Studio":
if self.settings.os == "Windows":
self.cpp_info.libs.extend(["ws2_32", "wsock32", "Iphlpapi"])
self.cpp_info.defines = ["ZMQ_STATIC"]
if not self.settings.os == "Windows":
self.cpp_info.cppflags = ["-pthread"]
if self.settings.os == "Linux":
self.cpp_info.libs.extend(["pthread", "dl", "rt"])