conanfile.py 1.5 KB
Newer Older
Michaël Roynard's avatar
Michaël Roynard committed
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
from conans import ConanFile, CMake, tools


class Pybind11(ConanFile):
    name = "pybind11"
    version = "2.2.4"
    description = "Seamless operability between C++11 and Python"
    author = "Michaël Roynard <michael.roynard@lrde.epita.fr>"
    url = "https://gitlab.lrde.epita.fr/olena/conan-pybind11"
    homepage = "https://github.com/pybind/pybind11"
    license = "https://github.com/pybind/pybind11/blob/master/LICENSE"
    exports = ["LICENSE"]
    settings = "os", "compiler", "build_type", "arch"
    options = {"shared": [True, False], "fPIC": [
        True, False], "build_tests": [True, False]}
    default_options = "shared=False", "fPIC=True", "build_tests=True"
    generators = "cmake"

    def configure(self):
        if self.settings.os == "Windows":
            self.options.remove("fPIC")

    def source(self):
        git = tools.Git()
        git.clone("{}.git".format(self.homepage))
        git.checkout("v{}".format(self.version))

    def get_cmake_config(self):
        cmake = CMake(self)

        if not self.options.build_tests:
            cmake.definitions["BUILD_TESTING"] = "OFF"

        cmake.configure()
        return cmake

    def build(self):
        cmake = self.get_cmake_config()
        cmake.build()

        if self.options.build_tests:
            cmake.test()

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

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

    def package_info(self):
        self.cpp_info.includedirs = ["include"]