Skip to content

Commit

Permalink
Updates libsndfile to use conan-provided libsndio (#23150)
Browse files Browse the repository at this point in the history
Co-authored-by: danimtb <danimanzaneque@gmail.com>
  • Loading branch information
spiderkeys and danimtb authored Nov 22, 2024
1 parent 1c36535 commit a860a99
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions recipes/libsndfile/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
Expand Down Expand Up @@ -34,7 +35,7 @@ class LibsndfileConan(ConanFile):
"fPIC": True,
"programs": True,
"experimental": False,
"with_alsa": False,
"with_alsa": True,
"with_external_libs": True,
"with_mpeg": True,
}
Expand All @@ -55,10 +56,16 @@ def configure(self):
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

def validate(self):
if self.dependencies["libsndio"].options.get_safe("with_alsa") and not self.options.get_safe("with_alsa"):
raise ConanInvalidConfiguration(f"{self.ref} 'with_alsa' option should be True when the libsndio 'with_alsa' one is True")

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("libsndio/1.9.0",
options={"with_alsa": self.options.get_safe("with_alsa")})
if self.options.get_safe("with_alsa"):
self.requires("libalsa/1.2.10")
if self.options.with_external_libs:
Expand All @@ -75,8 +82,7 @@ def source(self):

def generate(self):
tc = CMakeToolchain(self)
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Sndio"] = True # FIXME: missing sndio cci recipe (check whether it is really required)
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Speex"] = True # FIXME: missing sndio cci recipe (check whether it is really required)
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_Speex"] = True # FIXME: missing speex cci recipe (check whether it is really required)
tc.variables["CMAKE_DISABLE_FIND_PACKAGE_SQLite3"] = True # only used for regtest
tc.variables["ENABLE_EXTERNAL_LIBS"] = self.options.with_external_libs
if not self.options.with_external_libs:
Expand Down Expand Up @@ -124,6 +130,7 @@ def package_info(self):
self.cpp_info.set_property("pkg_config_name", "sndfile")
# TODO: back to global scope in conan v2 once cmake_find_package_* generators removed
self.cpp_info.components["sndfile"].libs = ["sndfile"]
self.cpp_info.components["sndfile"].requires.append("libsndio::libsndio")
if self.options.with_external_libs:
self.cpp_info.components["sndfile"].requires.extend([
"ogg::ogg", "vorbis::vorbismain", "vorbis::vorbisenc",
Expand Down

0 comments on commit a860a99

Please sign in to comment.