(#14519) soundtouch: add recipe

* soundtouch: add recipe

* add condition for SoundTouchDLL

* link mvec

* fix license name

Co-authored-by: Jordan Williams <jordan@jwillikers.com>

* fix pkg_config_name

Co-authored-by: Uilian Ries <uilianries@gmail.com>

Co-authored-by: Jordan Williams <jordan@jwillikers.com>
Co-authored-by: Uilian Ries <uilianries@gmail.com>
This commit is contained in:
toge
2022-12-13 17:25:41 +09:00
committed by GitHub
parent 45260cd66f
commit ec205f4e5d
8 changed files with 197 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
sources:
"2.3.2":
url: "https://www.surina.net/soundtouch/soundtouch-2.3.2.tar.gz"
sha256: "3bde8ddbbc3661f04e151f72cf21ca9d8f8c88e265833b65935b8962d12d6b08"

View File

@@ -0,0 +1,113 @@
from conan import ConanFile
from conan.tools.microsoft import is_msvc
from conan.tools.files import get, copy, rm, rmdir
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
import os
required_conan_version = ">=1.53.0"
class SoundTouchConan(ConanFile):
name = "soundtouch"
description = "an open-source audio processing library that allows changing the sound tempo, pitch and playback rate parameters independently"
license = "LGPL-2.1-or-later"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://codeberg.org/soundtouch/soundtouch"
topics = ("audio", "processing", "tempo", "pitch", "playback")
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"integer_samples": [True, False],
"with_openmp": [True, False],
"with_dll": [True, False],
"with_util": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"integer_samples": False,
"with_openmp": False,
"with_dll": False,
"with_util": False,
}
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
def layout(self):
cmake_layout(self, src_folder="src")
def source(self):
get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["INTEGER_SAMPLES"] = self.options.integer_samples
tc.variables["SOUNDTOUCH_DLL"] = self.options.with_dll
tc.variables["SOUNDSTRETCH"] = self.options.with_util
tc.variables["OPENMP"] = self.options.with_openmp
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
copy(self, pattern="COPYING.TXT", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "*.pdb", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "SoundTouch")
self.cpp_info.components["_soundtouch"].set_property("cmake_target_name", "SoundTouch::SoundTouch")
self.cpp_info.components["_soundtouch"].set_property("pkg_config_name", "soundtouch")
self.cpp_info.components["_soundtouch"].libs = ["SoundTouch"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["_soundtouch"].system_libs.append("m")
if not self.options.shared and self.options.with_openmp:
openmp_flags = []
if is_msvc(self):
openmp_flags = ["-openmp"]
elif self.settings.compiler in ("gcc", "clang"):
openmp_flags = ["-fopenmp"]
elif self.settings.compiler == "apple-clang":
openmp_flags = ["-Xpreprocessor", "-fopenmp"]
self.cpp_info.components["_soundtouch"].sharedlinkflags = openmp_flags
self.cpp_info.components["_soundtouch"].exelinkflags = openmp_flags
if self.options.with_dll:
self.cpp_info.components["SoundTouchDLL"].set_property("cmake_target_name", "SoundTouch::SoundTouchDLL")
self.cpp_info.components["SoundTouchDLL"].libs = ["SoundTouchDLL"]
self.cpp_info.components["SoundTouchDLL"].requires = ["_soundtouch"]
if self.options.with_util:
bin_path = os.path.join(self.package_folder, "bin")
self.output.info(f"Appending PATH environment variable: {bin_path}")
self.env_info.PATH.append(bin_path)
# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.names["cmake_find_package"] = "SoundTouch"
self.cpp_info.names["cmake_find_package_multi"] = "SoundTouch"
self.cpp_info.components["_soundtouch"].names["cmake_find_package"] = "SoundTouch"
self.cpp_info.components["_soundtouch"].names["cmake_find_package_multi"] = "SoundTouch"
self.cpp_info.names["pkg_config"] = "SoundTouch"
if self.options.with_dll:
self.cpp_info.components["SoundTouchDLL"].names["cmake_find_package"] = "SoundTouchDLL"
self.cpp_info.components["SoundTouchDLL"].names["cmake_find_package_multi"] = "SoundTouchDLL"
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("mvec")

View File

@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES CXX)
find_package(SoundTouch REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE SoundTouch::SoundTouch)

View File

@@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os
class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"
def requirements(self):
self.requires(self.tested_reference_str)
def layout(self):
cmake_layout(self)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")

View File

@@ -0,0 +1,17 @@
#include <iostream>
#include "soundtouch/SoundTouch.h"
int main(int argc, char* argv[]) {
std::cout << "SoundTouch: " << soundtouch::SoundTouch::getVersionString() << "\n";
soundtouch::SoundTouch soundTouch;
soundTouch.setRate(0.5);
soundTouch.setTempo(1.5);
soundTouch.setPitch(0.8);
soundTouch.setChannels(2);
soundTouch.flush();
return 0;
}

View File

@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)

View File

@@ -0,0 +1,18 @@
from conans import ConanFile, CMake
from conan.tools.build import cross_building
import os
class TestPackageV1Conan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def test(self):
if not cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)

View File

@@ -0,0 +1,3 @@
versions:
"2.3.2":
folder: all