forked from bincrafters/conan-kfr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconanfile.py
87 lines (73 loc) · 3.5 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
import os
from conans import ConanFile, tools, CMake
from conans.tools import Version
from conan.errors import ConanInvalidConfiguration
class KFRConan(ConanFile):
name = "kfr"
description = "Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters"
topics = ("conan", "kfr", "avx", "fft", "audio", "dsp")
url = "https://github.com/bincrafters/conan-kfr"
homepage = "https://github.com/kfrlib/kfr"
license = "GPL-2.0-or-later"
settings = "build_type", "os", "compiler", "arch"
options = {"dft": [True, False], "header_only": [True, False], "shared": [True, False], "fPIC": [True, False]}
default_options = {"dft": False, "header_only": True, "shared": False, "fPIC": True}
exports_sources = ["CMakeLists.txt", "0001-lib.patch"]
generators = "cmake"
@property
def _source_subfolder(self):
return "source_subfolder"
@property
def _build_subfolder(self):
return "build_subfolder"
def configure(self):
if (self.settings.compiler == "gcc" and Version(self.settings.compiler.version) < "5") or (self.settings.compiler == "clang" and Version(self.settings.compiler.version) < "5"):
raise ConanInvalidConfiguration(
"kfr can't be build with {} {}".format(self.settings.compiler, self.settings.compiler.version))
if self.options.dft and self.options.header_only:
raise ConanInvalidConfiguration("DFT can not be built with header-only")
if self.options.dft and (self.settings.compiler != "clang" and self.settings.compiler != "apple-clang"):
raise ConanInvalidConfiguration("DFT option is only compatible with Clang")
if self.options.header_only:
self.settings.clear()
del self.options.shared
del self.options.fPIC
del self.options.dft
elif not self.options.header_only and self.settings.os == "Windows":
del self.options.fPIC
def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = self.name + "-" + self.version
os.rename(extracted_dir, self._source_subfolder)
def _configure_cmake(self):
cmake = CMake(self)
if not self.options.header_only:
cmake.definitions["ENABLE_DFT"] = self.options.dft
cmake.configure(build_folder=self._build_subfolder)
return cmake
def build(self):
if not self.options.header_only:
tools.patch(base_path=self._source_subfolder, patch_file="0001-lib.patch")
cmake = self._configure_cmake()
cmake.build()
def package(self):
self.copy(pattern="LICENSE.txt", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()
os.remove(os.path.join(self.package_folder, "include", "kfr", "io", "dr", "README.txt"))
if self.options.header_only:
tools.rmdir(os.path.join(self.package_folder, "lib"))
def package_id(self):
if self.options.header_only:
self.info.header_only()
def package_info(self):
if not self.options.header_only:
self.cpp_info.libs = tools.collect_libs(self)
if self.options.dft:
self.cpp_info.defines.append("KFR_ENABLE_FLAC=1")
else:
self.cpp_info.defines.append("KFR_NO_DFT")
else:
self.cpp_info.defines.append("KFR_NO_DFT")
if tools.os_info.is_linux:
self.cpp_info.libs.extend(["pthread", "m"])