-
Notifications
You must be signed in to change notification settings - Fork 370
/
conanfile.py
70 lines (62 loc) · 3.43 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
69
70
from conans import ConanFile, CMake, tools
import os
import re
import textwrap
class LibconfigConan(ConanFile):
name = "libconfig"
license = "GNU LESSER GENERAL PUBLIC LICENSE"
author = """Mark Lindner - Lead developer & maintainer.
Daniel Marjamäki - Enhancements & bugfixes.
Andrew Tytula - Windows port.
Glenn Herteg - Enhancements, bugfixes, documentation corrections.s
Matt Renaud - Enhancements & bugfixes.
JoseLuis Tallon - Enhancements & bugfixes"""
url = "hyperrealm.github.io/libconfig/"
description = "Libconfig is a simple library for processing structured configuration files. " \
"This file format is more compact and more readable than XML. And unlike XML, it is type-aware, " \
"so it is not necessary to do string parsing in application code."
topics = ("libconfig", "structured", "configuration", "xml", "type")
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": False}
generators = "cmake"
exports_sources = "*"
no_copy_source = True
def set_version(self):
configure_ac = tools.load(os.path.join(self.recipe_folder, "configure.ac"))
self.version = next(re.finditer(r"AC_INIT\(\[libconfig\],[ \t]*\[([0-9.]+)\],.*", configure_ac)).group(1)
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
del self.options.fPIC
def build(self):
tools.save(os.path.join(self.build_folder, "CMakeLists.txt"), textwrap.dedent("""\
cmake_minimum_required(VERSION 2.8.12)
project(cmake_wrapper)
include("{}/conanbuildinfo.cmake")
conan_basic_setup()
add_subdirectory("{}" libconfig)
""").format(self.install_folder.replace("\\","/"), self.source_folder.replace("\\","/")))
cmake = CMake(self)
cmake.configure(source_folder=self.build_folder)
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()
def package_info(self):
# FIXME: `libconfig` is `libconfig::libconfig` in `libconfigConfig.cmake`
# FIXME: `libconfig++` is `libconfig::libconfig++` in `libconfig++Config.cmake`
self.cpp_info.components["libconfig_c"].libs = ["libconfig" if self.settings.compiler == "Visual Studio" else "config"]
if not self.options.shared:
self.cpp_info.components["libconfig_c"].defines = ["LIBCONFIG_STATIC"]
self.cpp_info.components["libconfig_c"].names["cmake_find_package"] = ["libconfig"]
self.cpp_info.components["libconfig_c"].names["cmake_find_package_multi"] = ["libconfig"]
self.cpp_info.components["libconfig_c"].names["pkg_config"] = "libconfig"
self.cpp_info.components["libconfig_cpp"].libs = ["libconfig++" if self.settings.compiler == "Visual Studio" else "config++"]
if not self.options.shared:
self.cpp_info.components["libconfig_cpp"].defines = ["LIBCONFIGXX_STATIC"]
self.cpp_info.components["libconfig_cpp"].names["cmake_find_package"] = ["libconfig++"]
self.cpp_info.components["libconfig_cpp"].names["cmake_find_package_multi"] = ["libconfig++"]
self.cpp_info.components["libconfig_cpp"].names["pg_config"] = "libconfig++"