diff --git a/recipes/dsp-filters/all/conandata.yml b/recipes/dsp-filters/all/conandata.yml new file mode 100644 index 0000000000000..17f324a8e1446 --- /dev/null +++ b/recipes/dsp-filters/all/conandata.yml @@ -0,0 +1,12 @@ +sources: + "cci.20170309": + url: "https://github.com/vinniefalco/DSPFilters/archive/acc49170e79a94fcb9c04b8a2116e9f8dffd1c7d.tar.gz" + sha256: "330c3960e55b8cdbf041d8ec4790a21a326dc331e43bf14c144ae5d88a47d53d" +patches: + "cci.20170309": + - patch_file: "patches/0001-remove-explicit-cmake-options.patch" + patch_description: "Remove explicit STATIC and FPIC options in CMakeLists.txt" + patch_type: "conan" + - patch_file: "patches/0002-remove-msvc-cmake-flags.patch" + patch_description: "Remove MY_FLAGS options in CMakeLists.txt" + patch_type: "conan" diff --git a/recipes/dsp-filters/all/conanfile.py b/recipes/dsp-filters/all/conanfile.py new file mode 100644 index 0000000000000..d4ef17870d051 --- /dev/null +++ b/recipes/dsp-filters/all/conanfile.py @@ -0,0 +1,74 @@ +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout +from conan.tools.files import copy, get, apply_conandata_patches, export_conandata_patches, rename +from conan.tools.microsoft import is_msvc +import os + +required_conan_version = ">=1.53.0" + +class DSPFiltersConan(ConanFile): + name = "dsp-filters" + description = "Set of DSP filters" + topics = ("dsp", "filters") + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/vinniefalco/DSPFilters" + license = "MIT" + settings = "os", "arch", "compiler", "build_type" + package_type = "library" + + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } + + def validate(self): + # in case it does not work in another configuration, it should validated here too + if is_msvc(self) and self.options.shared: + raise ConanInvalidConfiguration(f"{self.ref} can not be built as shared on Visual Studio and msvc.") + + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + cmake_layout(self, src_folder="src") + + 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 source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + apply_conandata_patches(self) + + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, "shared")) + cmake.build() + + def package(self): + copy(self, "lib*", src=os.path.join(self.build_folder, "DSPFilters"), dst=os.path.join(self.package_folder, "lib"), keep_path=False) + copy(self, "DSPFilters.lib", src=os.path.join(self.build_folder, "DSPFilters", f"{self.settings.build_type}"), dst=os.path.join(self.package_folder, "lib"), keep_path=False) + + copy(self, "*.h", src=os.path.join(self.source_folder, "shared", "DSPFilters", "include"), dst=os.path.join(self.package_folder, "include")) + copy(self, "README.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses")) + rename(self, src=os.path.join(self.package_folder, "licenses", "README.md"), dst=os.path.join(self.package_folder, "licenses", "license")) + + def package_info(self): + self.cpp_info.libs = ["DSPFilters"] + + if self.settings.os in ["Linux", "FreeBSD", "Neutrino"]: + self.cpp_info.system_libs.extend(["m"]) diff --git a/recipes/dsp-filters/all/patches/0001-remove-explicit-cmake-options.patch b/recipes/dsp-filters/all/patches/0001-remove-explicit-cmake-options.patch new file mode 100644 index 0000000000000..cece818ce0db2 --- /dev/null +++ b/recipes/dsp-filters/all/patches/0001-remove-explicit-cmake-options.patch @@ -0,0 +1,14 @@ +--- shared/DSPFilters/CMakeLists.txt 2017-03-09 13:40:27.000000000 +0100 ++++ shared/DSPFilters/CMakeLists.txt 2023-08-03 09:10:56.248123716 +0200 +@@ -4,10 +4,8 @@ + + aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/source SOURCE_LIB) + +-add_library(${PROJECT_NAME} STATIC ${SOURCE_LIB}) ++add_library(${PROJECT_NAME} ${SOURCE_LIB}) + + target_include_directories(${PROJECT_NAME} + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) + +-set_property(TARGET ${PROJECT_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON) +- diff --git a/recipes/dsp-filters/all/patches/0002-remove-msvc-cmake-flags.patch b/recipes/dsp-filters/all/patches/0002-remove-msvc-cmake-flags.patch new file mode 100644 index 0000000000000..e16d647a99e9c --- /dev/null +++ b/recipes/dsp-filters/all/patches/0002-remove-msvc-cmake-flags.patch @@ -0,0 +1,14 @@ +--- shared/CMakeLists.txt 2023-08-28 13:14:13.868202500 +0200 ++++ shared/CMakeLists.txt 2023-08-28 13:14:42.827596800 +0200 +@@ -8,11 +8,6 @@ + set(CMAKE_BUILD_TYPE Release) + + if((${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)) +- set(MYFLAGS "/O2 /WX- /MT") +- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MYFLAGS}") +- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MYFLAGS}") +- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MYFLAGS}") +- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${MYFLAGS}") + include(CheckSymbolExists) + check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF) + if(NOT HAVE_SNPRINTF) diff --git a/recipes/dsp-filters/all/test_package/CMakeLists.txt b/recipes/dsp-filters/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..f823007a47a74 --- /dev/null +++ b/recipes/dsp-filters/all/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.14.0) +project(test_package LANGUAGES CXX) + +find_package(dsp-filters REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE dsp-filters::dsp-filters) diff --git a/recipes/dsp-filters/all/test_package/conanfile.py b/recipes/dsp-filters/all/test_package/conanfile.py new file mode 100644 index 0000000000000..922d35b61f37a --- /dev/null +++ b/recipes/dsp-filters/all/test_package/conanfile.py @@ -0,0 +1,29 @@ +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 not can_run(self): + return + + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/dsp-filters/all/test_package/test_package.cpp b/recipes/dsp-filters/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..10690f2821e16 --- /dev/null +++ b/recipes/dsp-filters/all/test_package/test_package.cpp @@ -0,0 +1,11 @@ +#include + +#include + +int main() { + Dsp::SimpleFilter, 1> f; + f.setup(1, 100, 1000); + f.reset(); + + return 0; +} diff --git a/recipes/dsp-filters/config.yml b/recipes/dsp-filters/config.yml new file mode 100644 index 0000000000000..d7e185cf9c964 --- /dev/null +++ b/recipes/dsp-filters/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20170309": + folder: all