aboutsummaryrefslogtreecommitdiff
path: root/conanfile.py
blob: 51a159afb4360e80201015476c8695848e1341dd (plain)
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
import re

from conans import ConanFile, CMake
from conans.tools import load


def get_version():
    try:
        content = load("CMakeLists.txt")
        version = re.search("project\(\"newtype\"\s*VERSION \"(.*)\"", content).group(1)
        return version.strip()
    except:
        return None


class NewtypeConan(ConanFile):
    name = "newtype"
    scm = {
        "type": "git",
        "url": "https://github.com/fmorgner/newtype.git",
        "revision": "auto",
    }
    settings = ("compiler",)
    version = get_version()
    license = "BSD-3-Clause"
    url = "https://github.com/fmorgner/newtype"
    description = "A library of types and functions to create strong type aliases"
    generators = "cmake"
    build_requires = (
        "CUTE/2.2.6@fmorgner/stable",
        "lyra/1.2.0"
    )
    
    def _configure_cmake(self):
        cmake = CMake(self)
        cmake.definitions["BUILD_TESTING"] = True
        cmake.configure()
        return cmake

    def build(self):
        cmake = self._configure_cmake()
        cmake.build()
        cmake.test()

    def package(self):
        cmake = self._configure_cmake()
        cmake.install()

    def package_info(self):
        if self.settings.compiler in ["gcc", "clang"]:
            self.cpp_info.cxxflags = "-std=c++20"