This repository has been archived by the owner on Dec 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
/
conanfile.py
54 lines (45 loc) · 1.71 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
from conans import CMake, ConanFile, tools
from conans.errors import ConanException
import os
class PprintConan(ConanFile):
name = "pprint"
description = "Pretty Printer for Modern C++"
topics = ("pprint", "pretty", "printer", "single-header", "c++17")
homepage = "https://github.com/p-ranav/pprint"
url = "https://github.com/p-ranav/pprint"
license = "MIT"
exports_sources = "include/**", "test/**", "CMakeLists.txt", "LICENSE", "pprint.pc.in"
exports = "LICENSE"
no_copy_source = True
requires = "catch2/2.11.0"
settings = "os", "arch", "compiler", "build_type"
generators = "cmake_find_package"
def set_version(self):
import re
m = re.search(r"project\(.*VERSION ([0-9a-zA-Z.-]+)[ )]",
open(os.path.join(self.recipe_folder, "CMakeLists.txt")).read())
if not m:
raise ConanException("Could not extract version from CMakeLists.txt")
self.version = m.group(1)
_cmake = None
def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
if tools.get_env("CONAN_RUN_TESTS"):
self._cmake.definitions["PPRINT_BUILD_TESTS"] = True
self._cmake.configure()
return self._cmake
def build(self):
cmake = self._configure_cmake()
cmake.build()
if tools.get_env("CONAN_RUN_TESTS"):
self._cmake.test()
def package(self):
self.copy("LICENSE", dst="licenses")
cmake = self._configure_cmake()
cmake.install()
def package_id(self):
self.info.header_only()
def package_info(self):
self.cpp_info.includedirs.append(os.path.join("include", "pprint"))