Skip to content

Commit

Permalink
(#19023) dsp-filters/20170309: Added dsp-filters recipe
Browse files Browse the repository at this point in the history
* dsp-filters: Added dsp-filters recipe

* Copying proper package files also on windows

* MAde recipe msvc compliant

* Added missing final endline

* Added "m" system lib

* Cleanup

* Update recipes/dsp-filters/all/conandata.yml

* Update recipes/dsp-filters/all/conandata.yml

* Update recipes/dsp-filters/config.yml

---------

Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>
Co-authored-by: Carlos Zoido <mrgalleta@gmail.com>
  • Loading branch information
3 people authored Sep 8, 2023
1 parent df0e278 commit b2f903b
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 0 deletions.
12 changes: 12 additions & 0 deletions recipes/dsp-filters/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -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"
74 changes: 74 additions & 0 deletions recipes/dsp-filters/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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"])
Original file line number Diff line number Diff line change
@@ -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)
-
14 changes: 14 additions & 0 deletions recipes/dsp-filters/all/patches/0002-remove-msvc-cmake-flags.patch
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions recipes/dsp-filters/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
29 changes: 29 additions & 0 deletions recipes/dsp-filters/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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")
11 changes: 11 additions & 0 deletions recipes/dsp-filters/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include <DspFilters/Dsp.h>

#include <stdio.h>

int main() {
Dsp::SimpleFilter<Dsp::Butterworth::HighPass<1>, 1> f;
f.setup(1, 100, 1000);
f.reset();

return 0;
}
3 changes: 3 additions & 0 deletions recipes/dsp-filters/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"cci.20170309":
folder: all

0 comments on commit b2f903b

Please sign in to comment.