Skip to content

Commit

Permalink
(#15444) amgcl: conan v2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceIm committed Jan 31, 2023
1 parent 2f53dec commit e627e54
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 32 deletions.
2 changes: 1 addition & 1 deletion recipes/amgcl/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ sources:
sha256: "db0de6b75e6c205f44542c3ac8d9935c8357a58072963228d0bb11a54181aea8"
"1.4.0":
url: "https://github.com/ddemidov/amgcl/archive/refs/tags/1.4.0.tar.gz"
sha256: 018b824396494c8958faa6337cebcaba48a2584d828f279eef0bbf9e05f900a7
sha256: "018b824396494c8958faa6337cebcaba48a2584d828f279eef0bbf9e05f900a7"
52 changes: 35 additions & 17 deletions recipes/amgcl/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,52 @@
from conans import ConanFile, CMake, tools
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.files import copy, get
from conan.tools.layout import basic_layout
import os

required_conan_version = ">=1.51.1"

class UncrustifyConan(ConanFile):

class AmgclConan(ConanFile):
name = "amgcl"
description = (
"AMGCL is a header-only C++ library for solving large sparse linear "
"systems with algebraic multigrid (AMG) method."
)
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/ddemidov/amgcl"
topics = ("mathematics", "opencl", "openmp", "cuda", "amg")
license = "MIT"
description = "AMGCL is a header-only C++ library for solving large sparse linear systems with algebraic multigrid (AMG) method."
settings = "compiler"
package_type = "header-library"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True
requires = [("boost/1.76.0")]

@property
def _source_subfolder(self):
return "source_subfolder"
def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("boost/1.81.0")

def package_id(self):
self.info.clear()

def validate(self):
if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, 11)
if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, 11)

def source(self):
tools.get(**self.conan_data["sources"][self.version], destination=self._source_subfolder, strip_root=True)
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def build(self):
pass

def package(self):
self.copy("LICENSE.md", src=self._source_subfolder, dst="licenses")
self.copy("*",
dst=os.path.join("include", "amgcl"),
src=(os.path.join(self._source_subfolder, "amgcl")))
copy(self, "LICENSE.md", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, "*", src=os.path.join(self.source_folder, "amgcl"),
dst=os.path.join(self.package_folder, "include", "amgcl"))

def package_id(self):
self.info.header_only()
def package_info(self):
self.cpp_info.set_property("cmake_file_name", "amgcl")
self.cpp_info.set_property("cmake_target_name", "amgcl::amgcl")
self.cpp_info.bindirs = []
self.cpp_info.libdirs = []
13 changes: 6 additions & 7 deletions recipes/amgcl/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(PackageTest)
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
find_package(amgcl REQUIRED CONFIG)

add_executable(solver solver.cpp)
target_link_libraries(solver ${CONAN_LIBS})
set_property(TARGET solver PROPERTY CXX_STANDARD 11)
add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE amgcl::amgcl)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
22 changes: 15 additions & 7 deletions recipes/amgcl/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"
test_type = "explicit"

class AmgclTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

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", "solver")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
File renamed without changes.
8 changes: 8 additions & 0 deletions recipes/amgcl/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package
${CMAKE_CURRENT_BINARY_DIR}/test_package)
17 changes: 17 additions & 0 deletions recipes/amgcl/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
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)

0 comments on commit e627e54

Please sign in to comment.