Skip to content

Commit

Permalink
(conan-io#16392) Wg21 linear algebra conan 2
Browse files Browse the repository at this point in the history
* Begin porting to Conan 2.0

* Update wg21-linear_algebra to Conan 2.0

* Linter fixes

* Support Conan 1 & 2 during migration period

* Move to test_v1_package

* test_v1_package mirrors test_package

* Explicit test required during mirgration

* Code review feedback

* Update to version 0.7.3

* Whitespace

* Linter fix

* More linter fixes

* Less is more :)

* Whitespace

* Add msvc version

* Simplify validate exception message

* Update recipes/wg21-linear_algebra/all/test_v1_package/CMakeLists.txt

Co-authored-by: Chris Mc <prince.chrismc@gmail.com>

* fix: do not remove legacy target information

* Update supported compilers

* chore: dont pass lang twice to cmake and drop extra call to find package

* chore: c3i clang-11 image has a bug that blocks c++17 and up

---------

Co-authored-by: Rubén Rincón Blanco <rubenrb@jfrog.com>
Co-authored-by: Chris Mc <prince.chrismc@gmail.com>
  • Loading branch information
3 people authored and MartinDelille committed Apr 12, 2023
1 parent 094a768 commit 5eb5c0d
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 44 deletions.
6 changes: 3 additions & 3 deletions recipes/wg21-linear_algebra/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sources:
"0.7.2":
url: https://github.com/BobSteagall/wg21/archive/refs/tags/v0.7.2.tar.gz
sha256: 4a192d279491264be2d687f89c15432fcb4f2e2d113599152bd3df2df42ce9e1
"0.7.3":
url: https://github.com/BobSteagall/wg21/archive/refs/tags/v0.7.3.tar.gz
sha256: ff4bc5788793e3c5f65d98f50029b4f762ffa38572867701053dacb572b85098
55 changes: 26 additions & 29 deletions recipes/wg21-linear_algebra/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from conans import ConanFile, tools
from conans.errors import ConanInvalidConfiguration
import os
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import cmake_layout
from conan.tools.files import copy, get
from conan.tools.scm import Version

required_conan_version = ">=1.43.0"

required_conan_version = ">=1.59.0"

class LAConan(ConanFile):
name = "wg21-linear_algebra"
Expand All @@ -13,14 +16,11 @@ class LAConan(ConanFile):
license = "NCSA"
url = "https://github.com/conan-io/conan-center-index"
settings = "os", "arch", "compiler", "build_type"
package_type = "header-library"
no_copy_source = True

@property
def _source_subfolder(self):
return "source_subfolder"

def requirements(self):
self.requires("mdspan/0.1.0")
self.requires("mdspan/0.5.0")

@property
def _minimum_cpp_standard(self):
Expand All @@ -30,40 +30,37 @@ def _minimum_cpp_standard(self):
def _minimum_compilers_version(self):
return {
"Visual Studio": "16",
"gcc": "8",
"clang": "8",
"msvc": "192",
"gcc": "10",
"clang": "12", # Should be 11 but https://github.com/conan-io/conan-docker-tools/issues/251
"apple-clang": "11"
}

def validate(self):
compiler = self.settings.compiler
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, self._minimum_cpp_standard)
min_version = self._minimum_compilers_version.get(
str(self.settings.compiler))
check_min_cppstd(self, self._minimum_cpp_standard)
min_version = self._minimum_compilers_version.get(str(compiler))
if not min_version:
self.output.warn("{} recipe lacks information about the {} "
"compiler support.".format(
self.name, self.settings.compiler))
self.output.warn(f"{self.name} recipe lacks information about the "
f"{compiler} compiler support.")
else:
if tools.Version(self.settings.compiler.version) < min_version:
if Version(self.settings.compiler.version) < min_version:
raise ConanInvalidConfiguration(
"{} requires C++{} support. "
"The current compiler {} {} does not support it.".format(
self.name, self._minimum_cpp_standard,
self.settings.compiler,
self.settings.compiler.version))
f"{self.ref} requires at least {compiler} {min_version}")

def layout(self):
cmake_layout(self, src_folder="src")

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

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

def package(self):
self.copy(pattern="*", dst="include",
src=os.path.join(self._source_subfolder, "include"))
self.copy("*LICENSE*", dst="licenses", keep_path=False)
copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses"))
copy(self, "*", os.path.join(self.source_folder, "include"), os.path.join(self.package_folder, "include"))

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "wg21_linear_algebra")
Expand Down
3 changes: 0 additions & 3 deletions recipes/wg21-linear_algebra/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.12)
project(test_package CXX)

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

find_package(wg21_linear_algebra REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
Expand Down
19 changes: 14 additions & 5 deletions recipes/wg21-linear_algebra/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
from conans import ConanFile, CMake, tools
import os

from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout

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

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

def layout(self):
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
self.run(os.path.join("bin", "test_package"), 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")
6 changes: 3 additions & 3 deletions recipes/wg21-linear_algebra/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <linear_algebra.hpp>
#include <matrix>

using namespace STD_LA;

int main()
{
STD_LA::vector<fs_vector_engine<double, 4>> v;
STD_LA::matrix<fs_matrix_engine<double, 4, 4>> m;
STD_LA::fixed_size_matrix<double, 1, 4> v;
STD_LA::fixed_size_matrix<double, 4, 4> m;
v*m;

return EXIT_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.12)
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/)
18 changes: 18 additions & 0 deletions recipes/wg21-linear_algebra/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from conans import ConanFile, CMake
from conan.tools.build import cross_building
import os

# legacy validation with Conan 1.x
class TestPackageV1Conan(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 cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
2 changes: 1 addition & 1 deletion recipes/wg21-linear_algebra/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
versions:
"0.7.2":
"0.7.3":
folder: all

0 comments on commit 5eb5c0d

Please sign in to comment.