Repository: conan-io/conan-center-index

Issue:
[request] pffft/cci.20201015
### Package Details
  * Package Name/Version: **pffft/cci.20201015**
  * Website: **https://bitbucket.org/jpommier/pffft/src/master/**
  * Source code: **https://bitbucket.org/jpommier/pffft/src/master/**


### Description Of The Library / Tool

It's a pretty good FFT library. The name is "Pretty Fast FFT". The license is very permissive.

It's very simple: `pffft.h` and `pffft.c`. That's it. The other files are for comparison against `fftpack`, and aren't part of the library.

No versioning that I can see.


Discussion:

Resolving patch:
diff --git a/recipes/pffft/all/conanfile.py b/recipes/pffft/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/pffft/all/conanfile.py
@@ -0,0 +1,65 @@
+import os
+from conans import ConanFile, CMake, tools
+
+required_conan_version = ">=1.28.0"
+
+
+class ConanPffft(ConanFile):
+    name = "pffft"
+    description = "PFFFT, a pretty fast Fourier Transform."
+    url = "https://github.com/conan-io/conan-center-index"
+    homepage = "https://bitbucket.org/jpommier/pffft/src/master/"
+    topics = ("fft", "pffft")
+    license = "BSD-like (FFTPACK license)"
+    generators = "cmake"
+    settings = "os", "compiler", "arch", "build_type"
+    exports_sources = ["CMakeLists.txt"]
+    options = {"disable_simd": [True, False], "fPIC": [True, False]}
+    default_options = {"disable_simd": False, "fPIC": True}
+
+    _cmake = None
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version])
+        url = self.conan_data["sources"][self.version]["url"]
+        archive_name = os.path.basename(url)
+        archive_name = "jpommier-pffft-" + os.path.splitext(archive_name)[0]
+        os.rename(archive_name, self._source_subfolder)
+
+    def _configure_cmake(self):
+        if self._cmake:
+            return self._cmake
+        self._cmake = CMake(self)
+        self._cmake.definitions["DISABLE_SIMD"] = self.options.disable_simd
+        self._cmake.configure()
+        return self._cmake
+
+    def config_options(self):
+        if self.settings.os == "Windows":
+            del self.options.fPIC
+
+    def configure(self):
+        del self.settings.compiler.cppstd
+        del self.settings.compiler.libcxx
+
+    def build(self):
+        cmake = self._configure_cmake()
+        cmake.build()
+
+    def package_info(self):
+        self.cpp_info.libs.extend(["pffft"])
+        if self.settings.os == "Linux":
+            self.cpp_info.system_libs.append("m")
+
+    def package(self):
+        header = tools.load(os.path.join(self._source_subfolder, "pffft.h"))
+        license_content = header[: header.find("*/", 1)]
+        tools.save(
+            os.path.join(self.package_folder, "licenses", "LICENSE"), license_content
+        )
+        cmake = self._configure_cmake()
+        cmake.install()


Test patch:
diff --git a/recipes/pffft/all/test_package/CMakeLists.txt b/recipes/pffft/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/pffft/all/test_package/CMakeLists.txt
@@ -0,0 +1,10 @@
+cmake_minimum_required(VERSION 3.1)
+project(test_package C)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup()
+
+find_package(pffft REQUIRED)
+
+add_executable(${PROJECT_NAME} test_package.c)
+target_link_libraries(${PROJECT_NAME} pffft::pffft)
diff --git a/recipes/pffft/all/test_package/conanfile.py b/recipes/pffft/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/pffft/all/test_package/conanfile.py
@@ -0,0 +1,17 @@
+from conans import ConanFile, CMake, tools
+import os
+
+
+class TestPackageConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake", "cmake_find_package"
+
+    def build(self):
+        cmake = CMake(self)
+        cmake.configure()
+        cmake.build()
+
+    def test(self):
+        if not tools.cross_building(self.settings):
+            bin_path = os.path.join("bin", "test_package")
+            self.run(bin_path, run_environment=True)
diff --git a/recipes/pffft/all/test_package/test_package.c b/recipes/pffft/all/test_package/test_package.c
new file mode 100644
--- /dev/null
+++ b/recipes/pffft/all/test_package/test_package.c
@@ -0,0 +1,9 @@
+#include <pffft.h>
+#include <stdio.h>
+
+int main() {
+
+    int s = pffft_simd_size();
+    printf("%d\n",s);
+    return 0;
+}