mirror of
https://github.com/conan-io/conan-center-index.git
synced 2025-09-22 06:26:39 +00:00
(#11063) samarium: add recipe
* add library: samarium/1.0.0 * cleanup * add library: samarium/1.0.0 * fixes * conanfile.py: use defaults for SFML * all/conanfile.py: use defaults for SFML * remove upstream std::execution TBB dependency * check compiler versions * upstream: lower CMake min version to 3.15 * config.yml: remove extra newline * upstream changes * add cpp_info names * Update recipes/samarium/all/CMakeLists.txt Co-authored-by: Uilian Ries <uilianries@gmail.com> * conanfile.py: change topic to cpp20 Co-authored-by: Uilian Ries <uilianries@gmail.com> * conanfile.py: change cpp_info Co-authored-by: Uilian Ries <uilianries@gmail.com> * test_package/CMakeLists.txt: don't use CONAN_PKG Co-authored-by: Uilian Ries <uilianries@gmail.com> * fix package() * add dependency: range-v3 * upstream: removeconan.cmake usage, refactor cmake install * fix package_info * use old CONAN_PKG instead of find_package CONFIG * conanfile.py: bump range version to 0.12.0 * upstream changes * simplify package_info * lower CMake min version to 3.15 * cleanup * upstream fixes * upstream: CMake: enable WINDOWS_EXPORT_ALL_SYMBOLS * test_package: use cmake_find_package_multi * CMake: bump min req to 3.15 * Simplify compiler version checking Co-authored-by: Uilian Ries <uilianries@gmail.com> * upstream changes * remove unnecessary copy() Co-authored-by: Uilian Ries <uilianries@gmail.com>
This commit is contained in:
7
recipes/samarium/all/CMakeLists.txt
Normal file
7
recipes/samarium/all/CMakeLists.txt
Normal file
@@ -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)
|
4
recipes/samarium/all/conandata.yml
Normal file
4
recipes/samarium/all/conandata.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
sources:
|
||||
"1.0.0":
|
||||
sha256: 943de75803f492f78c5d55fe43be298fbb66156cc22946a3c6cc6b0634efc2e2
|
||||
url: https://github.com/strangeQuark1041/samarium/archive/refs/tags/v1.0.0.tar.gz
|
92
recipes/samarium/all/conanfile.py
Normal file
92
recipes/samarium/all/conanfile.py
Normal file
@@ -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")
|
10
recipes/samarium/all/test_package/CMakeLists.txt
Normal file
10
recipes/samarium/all/test_package/CMakeLists.txt
Normal file
@@ -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)
|
17
recipes/samarium/all/test_package/conanfile.py
Normal file
17
recipes/samarium/all/test_package/conanfile.py
Normal file
@@ -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)
|
8
recipes/samarium/all/test_package/test_package.cpp
Normal file
8
recipes/samarium/all/test_package/test_package.cpp
Normal file
@@ -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);
|
||||
}
|
3
recipes/samarium/config.yml
Normal file
3
recipes/samarium/config.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
versions:
|
||||
"1.0.0":
|
||||
folder: all
|
Reference in New Issue
Block a user