| 1 |
import os |
| 2 |
|
| 3 |
from conan import ConanFile |
| 4 |
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout |
| 5 |
|
| 6 |
|
| 7 |
class CppGirConan(ConanFile): |
| 8 |
version = "2.0.0" |
| 9 |
name = "cppgir" |
| 10 |
description = "gobject-introspection C++ binding generator" |
| 11 |
license = "MIT Software License" |
| 12 |
url = "https://gitlab.com/mnauw/cppgir.git" |
| 13 |
exports_sources = "data/*", "docs/*", "expected-lite/*", \ |
| 14 |
"gi/*", "override/*", "tools/*", "test/*", \ |
| 15 |
"examples/*", "!examples/external/*", \ |
| 16 |
"CMakeLists.txt", "cmake/*", "LICENSE", "README.md" |
| 17 |
|
| 18 |
settings = "os", "compiler", "build_type", "arch" |
| 19 |
build_policy = "missing" |
| 20 |
author = "Mark Nauwelaerts" |
| 21 |
test_package_folder = "examples/external" |
| 22 |
|
| 23 |
options = {"header_only": [True, False]} |
| 24 |
|
| 25 |
|
| 26 |
default_options = {"header_only": True} |
| 27 |
|
| 28 |
def requirements(self): |
| 29 |
if not self.options.header_only: |
| 30 |
self.requires("boost/[>=1.58]", options={'header_only': True}) |
| 31 |
self.requires("fmt/[>=8.1.1]") |
| 32 |
|
| 33 |
def layout(self): |
| 34 |
cmake_layout(self, build_folder="build.conan") |
| 35 |
|
| 36 |
self.cpp.source.includedirs = ["."] |
| 37 |
|
| 38 |
|
| 39 |
def generate(self): |
| 40 |
tc = CMakeToolchain(self) |
| 41 |
tc.variables["BUILD_EXAMPLES"] = False |
| 42 |
tc.variables["BUILD_DOC"] = False |
| 43 |
|
| 44 |
|
| 45 |
tc.variables["BUILD_EMBED_IGNORE"] = True |
| 46 |
tc.variables["BUILD_TOOLS"] = not self.options.header_only |
| 47 |
tc.generate() |
| 48 |
|
| 49 |
def build(self): |
| 50 |
cmake = CMake(self) |
| 51 |
cmake.configure() |
| 52 |
cmake.build() |
| 53 |
if not self.conf.get("tools.build:skip_test", default=False): |
| 54 |
test_folder = os.path.join(".") |
| 55 |
|
| 56 |
for t in ["gi-test", "gi-test-17"]: |
| 57 |
test = os.path.join(test_folder, t) |
| 58 |
if os.path.exists(test): |
| 59 |
self.run(test) |
| 60 |
|
| 61 |
def package(self): |
| 62 |
"""Run CMake install""" |
| 63 |
cmake = CMake(self) |
| 64 |
cmake.install() |
| 65 |
|
| 66 |
def package_info(self): |
| 67 |
self.cpp_info.includedirs = ["include/cppgir"] |
| 68 |
|
| 69 |
def package_id(self): |
| 70 |
|
| 71 |
if False and self.options.header_only: |
| 72 |
self.info.clear() |