Skip to content

Commit

Permalink
(#3634) libsndfile: ogg/flac/opus/vorbus are recommended dependencies…
Browse files Browse the repository at this point in the history
… (not required) + remove sqlite dependency

* libsndfile: sqlite3 is only used by regtest (which is a test and is not built)

* libsndfile: ogg/flac/opus/vorbus are recommended dependencies, not required

* libsndfile: only pas CMAKE_DISABLE_FIND_PACKAGE_ALSA when alsa is disabled

* libsndfile: use option 'with_external_libs'

* libsndfile: warnabout use of deprecated with_sqlite option instead of fail hard

* libsndfile: don't import ConanInvalidConfiguration

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>

Co-authored-by: SpaceIm <30052553+SpaceIm@users.noreply.github.com>
  • Loading branch information
madebr and SpaceIm authored Dec 3, 2020
1 parent 27b9625 commit 8fa0843
Showing 1 changed file with 26 additions and 12 deletions.
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],
}
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

0 comments on commit 8fa0843

Please sign in to comment.