diff --git a/recipes/samarium/all/CMakeLists.txt b/recipes/samarium/all/CMakeLists.txt new file mode 100644 index 0000000000..f3a784a246 --- /dev/null +++ b/recipes/samarium/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(KEEP_RPATHS) + +add_subdirectory(source_subfolder/src) diff --git a/recipes/samarium/all/conandata.yml b/recipes/samarium/all/conandata.yml new file mode 100644 index 0000000000..ba7cb183fb --- /dev/null +++ b/recipes/samarium/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.0.0": + sha256: 943de75803f492f78c5d55fe43be298fbb66156cc22946a3c6cc6b0634efc2e2 + url: https://github.com/strangeQuark1041/samarium/archive/refs/tags/v1.0.0.tar.gz diff --git a/recipes/samarium/all/conanfile.py b/recipes/samarium/all/conanfile.py new file mode 100644 index 0000000000..d199c49320 --- /dev/null +++ b/recipes/samarium/all/conanfile.py @@ -0,0 +1,92 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import functools + +required_conan_version = ">=1.43.0" + + +class SamariumConan(ConanFile): + name = "samarium" + description = "2-D physics simulation library" + homepage = "https://strangequark1041.github.io/samarium/" + url = "https://github.com/conan-io/conan-center-index/" + license = "MIT" + topics = ("cpp20", "physics", "2d", "simulation") + + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": False, "fPIC": True} + + generators = "cmake", "cmake_find_package_multi" + requires = "fmt/8.1.1", "sfml/2.5.1", "range-v3/0.12.0" + + @property + def _min_cppstd(self): + return "20" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "11.0", + "Visual Studio": "16.9", + "clang": "13", + "apple-clang": "13", + } + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + del self.options.fPIC + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + tools.check_min_cppstd(self, self._min_cppstd) + + compiler = str(self.settings.compiler) + if compiler not in self._compilers_minimum_version: + self.output.warn("Unknown compiler, assuming it supports at least C++20") + return + + version = tools.Version(self.settings.compiler.version) + if version < self._compilers_minimum_version[compiler]: + raise ConanInvalidConfiguration(f"{self.name} requires a compiler that supports at least C++20") + + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + + def source(self): + tools.get(**self.conan_data["sources"][self.version], + strip_root=True, destination=self._source_subfolder) + + @functools.lru_cache(1) + def _configure_cmake(self): + cmake = CMake(self) + cmake.configure(build_folder=self._build_subfolder) + return cmake + + def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE.md", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + self.cpp_info.libs.append("samarium") diff --git a/recipes/samarium/all/test_package/CMakeLists.txt b/recipes/samarium/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000..028691a3d0 --- /dev/null +++ b/recipes/samarium/all/test_package/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup(TARGETS) +find_package(samarium REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} samarium::samarium) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 20) diff --git a/recipes/samarium/all/test_package/conanfile.py b/recipes/samarium/all/test_package/conanfile.py new file mode 100644 index 0000000000..49a3a66ea5 --- /dev/null +++ b/recipes/samarium/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_multi" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/samarium/all/test_package/test_package.cpp b/recipes/samarium/all/test_package/test_package.cpp new file mode 100644 index 0000000000..6f22a55609 --- /dev/null +++ b/recipes/samarium/all/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include "samarium/samarium.hpp" + +int main() +{ + const auto im = sm::Image{}; + fmt::print(fmt::emphasis::bold, "\nSuccessful installation!\n"); + fmt::print(fmt::emphasis::bold, "Welcome to {}\n", sm::version); +} diff --git a/recipes/samarium/config.yml b/recipes/samarium/config.yml new file mode 100644 index 0000000000..40341aa3db --- /dev/null +++ b/recipes/samarium/config.yml @@ -0,0 +1,3 @@ +versions: + "1.0.0": + folder: all