-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathconanfile.py
106 lines (88 loc) · 3.8 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
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, get, rmdir, export_conandata_patches
import os
required_conan_version = ">=1.52.0"
class Atomic_opsConan(ConanFile):
name = "libatomic_ops"
homepage = "https://github.com/ivmai/libatomic_ops"
description = "The atomic_ops project (Atomic memory update operations portable implementation)"
topics = ("conan", "fmt", "format", "iostream", "printf")
url = "https://github.com/conan-io/conan-center-index"
license = "GPL-2.0-or-later"
settings = "os", "compiler", "build_type", "arch"
_cmake_options_defaults = (
("assertions", False,),
("atomic_intrinsics", True,),
)
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
for option, default in _cmake_options_defaults:
options[option] = [True, False]
default_options[option] = default
def export_sources(self):
export_conandata_patches(self)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
try:
del self.settings.compiler.libcxx
except Exception:
pass
try:
del self.settings.compiler.cppstd
except Exception:
pass
if self.options.shared:
try:
del self.options.fPIC
except Exception:
pass
def layout(self):
cmake_layout(self, src_folder="src")
def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)
def generate(self):
tc = CMakeToolchain(self)
for option, _ in self._cmake_options_defaults:
tc.variables["enable_{}".format(option)] = self.options.get_safe(option)
tc.variables["install_headers"] = True
tc.variables["build_tests"] = False
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
tc.generate()
tc = CMakeDeps(self)
tc.generate()
def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "Atomic_ops")
self.cpp_info.set_property("cmake_target_name", "Atomic_ops::atomic_ops_gpl") # workaround to not define an unofficial target
# TODO: Remove on Conan 2.0
self.cpp_info.names["cmake_find_package"] = "Atomic_ops"
self.cpp_info.names["cmake_find_package_multi"] = "Atomic_ops"
self.cpp_info.components["atomic_ops"].set_property("cmake_target_name", "Atomic_ops::atomic_ops")
self.cpp_info.components["atomic_ops"].set_property("pkg_config_name", "atomic_ops")
self.cpp_info.components["atomic_ops"].libs = ["atomic_ops"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["atomic_ops"].system_libs = ["pthread"]
self.cpp_info.components["atomic_ops_gpl"].set_property("cmake_target_name", "Atomic_ops::atomic_ops_gpl")
self.cpp_info.components["atomic_ops_gpl"].libs = ["atomic_ops_gpl"]
self.cpp_info.components["atomic_ops_gpl"].requires = ["atomic_ops"]