-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconanfile.py
More file actions
147 lines (129 loc) · 5.67 KB
/
conanfile.py
File metadata and controls
147 lines (129 loc) · 5.67 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import os
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import cmake_layout, CMakeToolchain, CMake
from conan import ConanFile
class EvgetRecipe(ConanFile):
name = "evget"
description = "record input device events"
url = "https://github.com/mmalenic/evget"
license = "MIT"
author = "Marko Malenic (mmalenic1@gmail.com)"
# x-release-please-start-version
version = "0.1.0"
# x-release-please-end
requires = (
"boost/[^1]",
"spdlog/[^1]",
"nlohmann_json/[^3]",
"sqlitecpp/[^3]",
"cli11/[^2]",
"openssl/[^3]",
)
test_requires = "gtest/[^1]"
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeDeps"
options = {
# Build the binary CLI.
"build_bin": [True, False],
# Whether to build test executables.
"build_testing": [True, False],
# Whether to run clang tidy.
"run_clang_tidy": [True, False],
# An optional clang tidy executable.
"clang_tidy_executable": [None, "ANY"],
# Fix clang tidy errors by passing "--fix-errors" to clang-tidy.
"clang_tidy_fix_errors": [True, False],
# Specifies a compiler launcher, such as sccache, which sets CMAKE_<LANG>_COMPILER_LAUNCHER.
"compiler_launcher": [None, "ANY"],
# Add a cmake install command after for the binary target if `build_binary` is also true:
# https://cmake.org/cmake/help/latest/command/install.html
"install_bin": [True, False],
# Add a cmake install command after for the library target:
# https://cmake.org/cmake/help/latest/command/install.html
"install_lib": [True, False],
# Export a compilation database using CMAKE_EXPORT_COMPILE_COMMANDS:
# https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html
"export_compilation_database": [True, False],
# Verify headers by setting CMAKE_VERIFY_INTERFACE_HEADER_SETS:
# https://cmake.org/cmake/help/latest/variable/CMAKE_VERIFY_INTERFACE_HEADER_SETS.html#variable:CMAKE_VERIFY_INTERFACE_HEADER_SETS
"verify_headers": [True, False],
# Whether system packages like X11 or libinput are installed as well as regular dependencies.
"require_system_packages": [True, False],
# Whether to build the evgetx11 library.
"build_evgetx11": [True, False],
# Whether to build the evgetlibinput library.
"build_evgetlibinput": [True, False],
}
default_options = {
"build_bin": True,
"build_testing": False,
"run_clang_tidy": False,
"clang_tidy_executable": None,
"clang_tidy_fix_errors": False,
"compiler_launcher": None,
"install_bin": True,
"install_lib": True,
"export_compilation_database": True,
"verify_headers": False,
"require_system_packages": True,
}
def config_options(self):
is_wayland = os.getenv("WAYLAND_DISPLAY") is not None
is_linux = self.settings.os == "Linux" or self.settings.os.subsystem == "wsl"
# Must compare with ==
# https://github.com/conan-io/conan/issues/3524
if self.options.build_evgetx11 == None: # noqa: E711
self.options.build_evgetx11 = not is_wayland and is_linux
if self.options.build_evgetlibinput == None: # noqa: E711
self.options.build_evgetlibinput = is_wayland and is_linux
def configure(self):
self.options["spdlog"].use_std_fmt = True
def requirements(self):
if self.options.build_evgetx11:
if self.options.require_system_packages:
self.requires("xorg/system")
if self.options.build_evgetlibinput:
if self.options.require_system_packages:
self.requires("libudev/system")
self.requires("libinput/[^1]")
self.requires("xkbcommon/[^1]")
self.requires("wayland/[^1]")
self.requires("libdrm/[^2]")
def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, 23)
def generate(self):
tc = CMakeToolchain(self)
tc.variables["EVGET_BUILD_BIN"] = self.options.build_bin
tc.variables["BUILD_TESTING"] = self.options.build_testing
tc.variables["EVGET_RUN_CLANG_TIDY"] = self.options.run_clang_tidy
tc.variables["EVGET_CLANG_TIDY_FIX_ERRORS"] = self.options.clang_tidy_fix_errors
tc.variables["EVGET_INSTALL_BIN"] = self.options.install_bin
tc.variables["EVGET_INSTALL_LIB"] = self.options.install_lib
tc.variables["EVGET_BUILD_EVGETX11"] = self.options.build_evgetx11
tc.variables["EVGET_BUILD_EVGETLIBINPUT"] = self.options.build_evgetlibinput
if self.options.clang_tidy_executable:
tc.variables["EVGET_CLANG_TIDY_EXECUTABLE"] = (
self.options.clang_tidy_executable
)
if self.options.compiler_launcher:
tc.variables["CMAKE_C_COMPILER_LAUNCHER"] = self.options.compiler_launcher
tc.variables["CMAKE_CXX_COMPILER_LAUNCHER"] = self.options.compiler_launcher
if self.options.export_compilation_database:
tc.variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
if self.options.verify_headers:
tc.variables["CMAKE_VERIFY_INTERFACE_HEADER_SETS"] = True
tc.generate()
def package_info(self):
self.cpp_info.requires = [
"boost::algorithm",
"boost::asio",
"boost::uuid",
"boost::numeric-conversion",
]
def layout(self):
cmake_layout(self)
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()