Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libsndfile: ogg/flac/opus/vorbus are recommended dependencies (not required) + remove sqlite dependency #3634

Merged
merged 6 commits into from
Dec 3, 2020
38 changes: 26 additions & 12 deletions recipes/libsndfile/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ class LibsndfileConan(ConanFile):
"programs": [True, False],
"experimental": [True, False],
"with_alsa": [True, False],
"with_sqlite": [True, False],
"with_sqlite": ["deprecated", True, False],
"with_external_libs": [True, False],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these be controlled individually?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
default_options = {
"shared": False,
"fPIC": True,
"programs": True,
"experimental": False,
"with_alsa": False,
"with_sqlite": True,
"with_sqlite": "deprecated",
"with_external_libs": True,

}
exports_sources = ["CMakeLists.txt", "patches/**"]
generators = "cmake", "cmake_find_package"
Expand All @@ -38,12 +41,11 @@ def _source_subfolder(self):
def requirements(self):
if self.options.get_safe("with_alsa"):
self.requires("libalsa/1.2.2")
if self.options.with_sqlite:
self.requires("sqlite3/3.32.3")
self.requires("flac/1.3.3")
self.requires("ogg/1.3.4")
self.requires("opus/1.3.1")
self.requires("vorbis/1.3.7")
if self.options.with_external_libs:
self.requires("ogg/1.3.4")
self.requires("vorbis/1.3.7")
self.requires("flac/1.3.3")
self.requires("opus/1.3.1")

def config_options(self):
if self.settings.os == "Windows":
Expand All @@ -53,6 +55,9 @@ def config_options(self):
def configure(self):
if self.options.shared:
del self.options.fPIC
if self.options.with_sqlite != "deprecated":
self.output.warn("with_sqlite is a deprecated option. Do not use.")
del self.options.with_sqlite

def source(self):
tools.get(**self.conan_data["sources"][self.version])
Expand All @@ -62,6 +67,17 @@ def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Sndio"] = True # FIXME: missing sndio cci recipe (check whether it is really required)
self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Speex"] = True # FIXME: missing sndio cci recipe (check whether it is really required)
self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_SQLite3"] = True # only used for regtest
self._cmake.definitions["ENABLE_EXTERNAL_LIBS"] = self.options.with_external_libs
if not self.options.with_external_libs:
self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Ogg"] = True
self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Vorbis"] = True
self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_FLAC"] = True
self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_Opus"] = True
if not self.options.get_safe("with_alsa", False):
self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_ALSA"] = True
self._cmake.definitions["BUILD_PROGRAMS"] = self.options.programs
self._cmake.definitions["BUILD_EXAMPLES"] = False
self._cmake.definitions["BUILD_TESTING"] = False
Expand All @@ -70,7 +86,6 @@ def _configure_cmake(self):
if self.settings.compiler == "Visual Studio":
self._cmake.definitions["ENABLE_STATIC_RUNTIME"] = "MT" in str(self.settings.compiler.runtime)
self._cmake.definitions["BUILD_REGTEST"] = False
self._cmake.definitions["ENABLE_EXTERNAL_LIBS"] = True
self._cmake.configure()
return self._cmake

Expand All @@ -95,16 +110,15 @@ def package_info(self):
self.cpp_info.names["cmake_find_package"] = "SndFile"
self.cpp_info.names["pkg_config"] = "sndfile"
self.cpp_info.components["sndfile"].libs = ["sndfile"]
self.cpp_info.components["sndfile"].requires = ["flac::flac", "ogg::ogg", "opus::opus", "vorbis::vorbis"]
if self.options.with_external_libs:
self.cpp_info.components["sndfile"].requires.extend(["ogg::ogg", "vorbis::vorbis", "flac::flac", "opus::opus"])
if not self.options.shared:
if self.settings.os == "Linux":
self.cpp_info.components["sndfile"].system_libs = ["m", "dl", "pthread", "rt"]
elif self.settings.os == "Windows":
self.cpp_info.components["sndfile"].system_libs.append("winmm")
if self.options.get_safe("with_alsa"):
self.cpp_info.components["sndfile"].requires.append("libalsa::libalsa")
if self.options.with_sqlite:
self.cpp_info.components["sndfile"].requires.append("sqlite3::sqlite3")

bin_path = os.path.join(self.package_folder, "bin")
self.output.info("Appending PATH environment variable: {}".format(bin_path))
Expand Down