Files
sonus/conanfile.py
khodowany 5600f03fc1
publish / publish (push) Successful in 13m13s
Cleanup
2026-09-24 19:44:00 -05:00

112 lines
2.7 KiB
Python

import conan
import conan.tools.build
import conan.tools.cmake
class sonus_conan(conan.ConanFile):
name = "sonus"
version = "latest"
description = "C++23 audio playback and metronome library"
license = "MIT"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [
True,
False,
],
"fPIC": [
True,
False,
],
"with_tests": [
True,
False,
],
}
default_options = {
"shared": False,
"fPIC": True,
"with_tests": False,
}
exports = "modulus.json", "!build", "!.git", "!test_package/build"
exports_sources = (
"!build",
"!.git",
"!test_package/build",
"CMakeLists.txt",
"cmake/*.in",
"include/*.hpp",
"include/sonus/*.hpp",
"include/sonus/detail/*.hpp",
"src/*.cpp",
"src/detail/*.cpp",
"src/detail/*.hpp",
"tests/CMakeLists.txt",
"tests/*.cpp",
"tests/*.hpp",
)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
del self.options.fPIC
def requirements(self):
self.requires(
"modulus/latest",
transitive_headers=True,
transitive_libs=True,
)
self.requires(
"miniaudio/0.11.22",
visible=False,
transitive_headers=False,
transitive_libs=False,
)
def generate(self):
dependencies = conan.tools.cmake.CMakeDeps(self)
dependencies.generate()
toolchain = conan.tools.cmake.CMakeToolchain(self)
if hasattr(toolchain, "user_presets_path"):
toolchain.user_presets_path = False
toolchain.variables["BUILD_SHARED_LIBS"] = bool(self.options.shared)
toolchain.variables["BUILD_TESTING"] = bool(self.options.with_tests)
toolchain.generate()
def build(self):
cmake = conan.tools.cmake.CMake(self)
cmake.configure()
cmake.build()
if self.options.with_tests and conan.tools.build.can_run(self):
cmake.test(target="check")
def package_id(self):
self.info.options.rm_safe("with_tests")
for requirement in (
"openssl",
"sqlite3",
"raylib",
):
if requirement in self.info.requires.pkg_names:
self.info.requires.remove(requirement)
def package(self):
cmake = conan.tools.cmake.CMake(self)
cmake.install()
def package_info(self):
self.cpp_info.set_property(
"cmake_file_name",
"sonus",
)
self.cpp_info.set_property(
"cmake_target_name",
"sonus::sonus",
)
self.cpp_info.libs = ["sonus"]
self.cpp_info.requires = [
"modulus::modulus",
]
if self.settings.os == "Linux":
self.cpp_info.system_libs = [
"dl",
"m",
"pthread",
]