Repository: conan-io/conan-center-index

Issue:
[request] S03/1.3.3
### Package Details
  * Package Name/Version: **so3/1.3.3**
  * Website: **http://astro-informatics.github.io/so3/**
  * Source code: **https://github.com/astro-informatics/so3**


### Description Of The Library / Tool

The SO3 code provides functionality to perform fast and exact Wigner transforms using the spherical transforms provided by [SSHT](https://conan.io/center/ssht) and the Fourier Transforms of [FFTW](https://conan.io/center/fftw).



Discussion:

Resolving patch:
diff --git a/recipes/astro-informatics-so3/all/conanfile.py b/recipes/astro-informatics-so3/all/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/astro-informatics-so3/all/conanfile.py
@@ -0,0 +1,62 @@
+from conans import CMake, ConanFile, tools
+from conans.errors import ConanInvalidConfiguration
+from glob import glob
+import os
+
+
+class AstroInformaticsSO3(ConanFile):
+    name = "astro-informatics-so3"
+    license = "GPL-3.0-or-later"
+    url = "https://github.com/conan-io/conan-center-index"
+    homepage = "https://github.com/astro-informatics/so3"
+    description = "Fast and accurate Wigner transforms"
+    settings = "os", "arch", "compiler", "build_type"
+    topics = ("physics", "astrophysics", "radio interferometry")
+    options = {"fPIC": [True, False]}
+    default_options = {"fPIC": True}
+    requires = "fftw/3.3.9", "ssht/1.3.7"
+    generators = "cmake", "cmake_find_package"
+    exports_sources = ["CMakeLists.txt"]
+
+    @property
+    def _source_subfolder(self):
+        return "source_subfolder"
+
+    @property
+    def _build_subfolder(self):
+        return "build_subfolder"
+
+    def configure(self):
+        del self.settings.compiler.cppstd
+        del self.settings.compiler.libcxx
+
+    def config_options(self):
+        if self.settings.compiler == "Visual Studio":
+            raise ConanInvalidConfiguration(
+                "SO3 requires C99 support for complex numbers."
+            )
+
+    def source(self):
+        tools.get(**self.conan_data["sources"][self.version])
+        extracted_dir = glob("so3-*/")[0]
+        os.rename(extracted_dir, self._source_subfolder)
+
+    @property
+    def cmake(self):
+        if not hasattr(self, "_cmake"):
+            self._cmake = CMake(self)
+            self._cmake.definitions["BUILD_TESTING"] = False
+            self._cmake.configure(build_folder=self._build_subfolder)
+        return self._cmake
+
+    def build(self):
+        self.cmake.build()
+
+    def package(self):
+        self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
+        self.cmake.install()
+
+    def package_info(self):
+        self.cpp_info.libs = ["astro-informatics-so3"]
+        if self.settings.os == "Linux":
+            self.cpp_info.system_libs = ["m"]


Test patch:
diff --git a/recipes/astro-informatics-so3/all/test_package/CMakeLists.txt b/recipes/astro-informatics-so3/all/test_package/CMakeLists.txt
new file mode 100644
--- /dev/null
+++ b/recipes/astro-informatics-so3/all/test_package/CMakeLists.txt
@@ -0,0 +1,12 @@
+cmake_minimum_required(VERSION 3.1)
+project(test_package C)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup()
+
+find_package(astro-informatics-so3 REQUIRED NO_MODULE)
+
+add_executable(${PROJECT_NAME} example.c)
+target_compile_features(${PROJECT_NAME} PUBLIC c_std_99)
+target_link_libraries(${PROJECT_NAME}
+                      astro-informatics-so3::astro-informatics-so3)
diff --git a/recipes/astro-informatics-so3/all/test_package/conanfile.py b/recipes/astro-informatics-so3/all/test_package/conanfile.py
new file mode 100644
--- /dev/null
+++ b/recipes/astro-informatics-so3/all/test_package/conanfile.py
@@ -0,0 +1,17 @@
+import os
+from conans import ConanFile, CMake, tools
+
+
+class TestPackageConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake", "cmake_find_package_multi"
+
+    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/astro-informatics-so3/all/test_package/example.c b/recipes/astro-informatics-so3/all/test_package/example.c
new file mode 100644
--- /dev/null
+++ b/recipes/astro-informatics-so3/all/test_package/example.c
@@ -0,0 +1,10 @@
+#include <so3/so3_sampling.h>
+#include <so3/so3_types.h>
+
+int main(int argc, char *argv[])
+{
+  so3_parameters_t params;
+  params.sampling_scheme = SO3_SAMPLING_MW;
+  so3_sampling_weight(&params, 2);
+  return 0;
+}