-
Notifications
You must be signed in to change notification settings - Fork 4
/
conanfile.py
87 lines (71 loc) · 2.28 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import os
from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout
from conan.tools.env import VirtualRunEnv
from conan.tools.files import load
class LibCosimCConan(ConanFile):
# Basic package info
name = "libcosimc"
def set_version(self):
self.version = load(self, os.path.join(self.recipe_folder, "version.txt")).strip()
# Metadata
license = "MPL-2.0"
author = "osp"
description = "A C wrapper for libcosim, a co-simulation library for C++"
# Binary configuration
package_type = "library"
settings = "os", "compiler", "build_type", "arch"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": True,
"fPIC": True,
}
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.options["*"].shared = self.options.shared
# Dependencies/requirements
tool_requires = (
"cmake/[>=3.15]",
"doxygen/1.9.1",
)
requires = (
"libcosim/0.10.4@osp/stable",
)
# Exports
exports = "version.txt"
exports_sources = "*"
# Build steps
generators = "CMakeDeps", "CMakeToolchain"
def layout(self):
cmake_layout(self)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
cmake.build(target="doc")
if self._is_tests_enabled():
env = VirtualRunEnv(self).environment()
env.define("CTEST_OUTPUT_ON_FAILURE", "ON")
with env.vars(self).apply():
cmake.test()
# Packaging
def package(self):
cmake = CMake(self)
cmake.install()
cmake.build(target="install-doc")
def package_info(self):
self.cpp_info.libs = [ "cosimc" ]
# Ensure that consumers use our CMake package configuration files
# rather than ones generated by Conan.
self.cpp_info.set_property("cmake_find_mode", "none")
self.cpp_info.builddirs.append(".")
# Helper functions
def _is_tests_enabled(self):
return os.getenv("LIBCOSIMC_RUN_TESTS_ON_CONAN_BUILD", "False").lower() in ("true", "1")