diff --git a/recipes/s2let/all/CMakeLists.txt b/recipes/s2let/all/CMakeLists.txt new file mode 100644 index 0000000000000..0496b29838549 --- /dev/null +++ b/recipes/s2let/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.0) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/s2let/all/conandata.yml b/recipes/s2let/all/conandata.yml new file mode 100644 index 0000000000000..93e1e80ecc199 --- /dev/null +++ b/recipes/s2let/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "2.2.3": + url: "https://github.com/astro-informatics/s2let/archive/refs/tags/v2.2.3.tar.gz" + sha256: "1321e1bc96ba200e4cd4056843cd4075de1c05be20e64185f065f48b9cefe3f8" diff --git a/recipes/s2let/all/conanfile.py b/recipes/s2let/all/conanfile.py new file mode 100644 index 0000000000000..1fc2aa8dc0cd5 --- /dev/null +++ b/recipes/s2let/all/conanfile.py @@ -0,0 +1,81 @@ +from conans import CMake, ConanFile, tools +from conans.errors import ConanInvalidConfiguration + +required_conan_version = ">=1.33.0" + + +class S2let(ConanFile): + name = "s2let" + license = "GPL-3.0-or-later" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/astro-informatics/s2let" + description = "Fast wavelets on the sphere" + settings = "os", "arch", "compiler", "build_type" + topics = ("physics", "astrophysics", "radio interferometry") + options = { + "fPIC": [True, False], + "with_cfitsio": [True, False], + } + default_options = { + "fPIC": True, + "with_cfitsio": False, + } + 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 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 requirements(self): + self.requires("astro-informatics-so3/1.3.4") + if self.options.with_cfitsio: + self.requires("cfitsio/3.490") + + def validate(self): + if self.settings.compiler == "Visual Studio": + raise ConanInvalidConfiguration( + "S2LET requires C99 support for complex numbers." + ) + + def source(self): + tools.get( + **self.conan_data["sources"][self.version], + strip_root=True, + destination=self._source_subfolder + ) + + @property + def _cmake(self): + if not hasattr(self, "_cmake_instance"): + self._cmake_instance = CMake(self) + self._cmake_instance.definitions["BUILD_TESTING"] = False + self._cmake_instance.definitions["cfitsio"] = self.options.with_cfitsio + self._cmake_instance.configure(build_folder=self._build_subfolder) + return self._cmake_instance + + 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.names["cmake_find_package"] = "s2let" + self.cpp_info.names["cmake_find_package_multi"] = "s2let" + self.cpp_info.libs = ["s2let"] + if self.settings.os == "Linux": + self.cpp_info.system_libs = ["m"] diff --git a/recipes/s2let/all/test_package/CMakeLists.txt b/recipes/s2let/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..87839a22ea4e7 --- /dev/null +++ b/recipes/s2let/all/test_package/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.8) +project(test_package C) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +find_package(s2let REQUIRED NO_MODULE) + +add_executable(${PROJECT_NAME} example.c) +target_compile_features(${PROJECT_NAME} PUBLIC c_std_99) +target_link_libraries(${PROJECT_NAME} s2let::s2let) diff --git a/recipes/s2let/all/test_package/conanfile.py b/recipes/s2let/all/test_package/conanfile.py new file mode 100644 index 0000000000000..abcaeed3f89b6 --- /dev/null +++ b/recipes/s2let/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/s2let/all/test_package/example.c b/recipes/s2let/all/test_package/example.c new file mode 100644 index 0000000000000..727c8b1d866f7 --- /dev/null +++ b/recipes/s2let/all/test_package/example.c @@ -0,0 +1,9 @@ +#include + +int main(int argc, char *argv[]) +{ + complex double *buffer; + s2let_allocate_lm(&buffer, 5); + free(buffer); + return 0; +} diff --git a/recipes/s2let/config.yml b/recipes/s2let/config.yml new file mode 100644 index 0000000000000..a0d8538280848 --- /dev/null +++ b/recipes/s2let/config.yml @@ -0,0 +1,3 @@ +versions: + "2.2.3": + folder: all