forked from BobSteagall/wg21
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
68 lines (58 loc) · 2.66 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from conans import ConanFile, CMake, tools
from conans.tools import load
from conans.model.version import Version
import re, os.path
class LinearAlgebraConan(ConanFile):
name = "linear_algebra"
license = "MIT"
url = "https://github.com/BobSteagall/wg21"
homepage = "https://github.com/BobSteagall/wg21"
description = "A linear algebra proposal for the C++ standard library"
topics = ("conan", "linear algebra", "header-only", "std", "math", "wg21")
exports_sources = "*.txt", "*.hpp", "*.cpp", "*.cmake", "*.cmake.in"
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"
requires = ("mdspan/0.1.0")
def set_version(self):
content = load(os.path.join(os.path.dirname(__file__), "CMakeLists.txt"))
version = re.search(r'project\(wg21_linear_algebra VERSION (\d+\.\d+\.\d+)\)', content).group(1)
self.version = version.strip()
def build_requirements(self):
# Ensure the package is build against a version of CMake from 3.16 onwards.
if CMake.get_version() < Version("3.16"):
self.build_requires("cmake/3.16.4")
_cmake = None
@property
def cmake(self):
if self._cmake is None:
self._cmake = CMake(self)
self._cmake.definitions.update({
"LA_BUILD_PACKAGE": True,
"LA_ENABLE_TESTS": self.run_tests
})
self._cmake.configure()
return self._cmake
@property
def run_tests(self):
""" By default tests should not be built and run during package creation. It can optionally be enabled,
for example for on CI by enabling setting the environment variable CONAN_RUN_TESTS=1. """
return tools.get_env("CONAN_RUN_TESTS", False)
def build(self):
self.cmake.build()
if tools.cross_building(self.settings):
return
if self.run_tests:
self.cmake.test()
def package(self):
self.copy(pattern="*", dst="include", src="include")
self.copy("LICENSE.txt", dst="licenses", src=".")
def package_id(self):
self.info.header_only()
def package_info(self):
self.cpp_info.names["cmake_find_package"] = "wg21_linear_algebra"
self.cpp_info.names["cmake_find_package_multi"] = "wg21_linear_algebra"
self.cpp_info.components["_wg21_linear_algebra"].names["cmake_find_package"] = "wg21_linear_algebra"
self.cpp_info.components["_wg21_linear_algebra"].names["cmake_find_package_multi"] = "wg21_linear_algebra"
self.cpp_info.components["_wg21_linear_algebra"].requires = ["mdspan::mdspan"]