-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconanfile.py
207 lines (176 loc) · 7.35 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# -*- coding: utf-8 -*-
#
# SPDX-FileCopyrightText: 2013-2021 Jürgen Mülbert <juergen.muelbert@gmail.com>
#
# SPDX-License-Identifier: GPL-3.0-or-later
#
import os
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain
from conan.tools.files import copy, rm, rmdir
from conan.tools.scm import Version
required_conan_version = ">=2.0"
class jmbdeReceipe(ConanFile):
name = "jmbde"
description = "A BDE Tool"
license = "EUPL-1.2"
url = "https://github.com/jmuelbert/jmbde-QT"
homepage = "https://github.com/jmuelbert/jmbde-QT"
author = "Jürgen Mülbert"
topics = ("bde", "collect-data", "database", "qt", "qt6", "conan", "cmake", "c++")
package_type = "application"
settings = "os", "arch", "compiler", "build_type"
version = "0.7.0"
options = {
"shared": [True, False],
"fPIC": [True, False],
"build_docs": [True, False],
"build_translations": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"build_docs": True,
"build_translations": True,
}
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
if self.options.shared:
self.options["qt"].shared = True
self.options.rm_safe("qt:fPIC")
self.options.rm_safe("fPIC")
def layout(self):
# We make the assumption that if the compiler is msvc the
# CMake generator is multi-config
multi = True if self.settings.get_safe("compiler") == "msvc" else False
if multi:
self.folders.generators = os.path.join("build", "generators")
self.folders.build = "build"
else:
self.folders.generators = os.path.join(
"build", str(self.settings.build_type), "generators"
)
self.folders.build = os.path.join("build", str(self.settings.build_type))
def requirements(self):
platform_qt = os.getenv("CMAKE_PREFIX_PATH")
if not platform_qt:
self.output.info("CMAKE_PREFIX_PATH not set")
self.output.info(
"To use the Qt from your system, set the CMAKE_PREFIX_PATH env var"
)
# self.output.info("Trying to get Qt from Qt")
# self.requires("qtbase/6.2.3@qt/everywhere")
# self.requires("qtbuildprofiles/6.2.3@qt/everywhere")
# self.requires("qtdeclarative/6.2.3@qt/everywhere")
# self.requires("qtdoc/6.2.3@qt/everywhere")
# self.requires("qtimageformats/6.2.3@qt/everywhere")
# self.requires("qtsvg/6.2.3@qt/everywhere")
# if self.options.build_translations:
# self.requires("qttranslations/6.2.3@qt/everywhere")
self.requires("qt/6.7.2")
self.options["qt"].shared = self.options.shared
self.options["qt"].qtsvg = True
self.options["qt"].qtdeclarative = True
self.options["qt"].qttools = True
if self.options.build_translations:
self.options["qt"].qttranslations = True
self.options["qt"].qtimageformats = True
self.options["qt"].qtdoc = True
self.options["qt"].qtimageformats = True
self.options["qt"].shared = self.options.shared
self.options["qt"].qtimageformats = True
else:
self.output.info(
"Getting Qt from the system. CMAKE_PREFIX_PATH = " + platform_qt
)
self.requires("extra-cmake-modules/5.113.0")
# if self.settings.os != "Windows":
# self.requires("libiconv/1.17")
# self.requires("spdlog/1.13.0")
# self.requires("cli11/2.4.1")
# self.requires("benchmark/1.8.3")
# if self.options.build_docs:
# self.requires("doxygen/1.9.4")
# self.requires("catch2/3.5.2")
# self.requires("gtest/1.14.0")
@property
def _min_cppstd(self):
return 14
# In case the project requires C++14/17/20/... the minimum compiler version should be listed
@property
def _compilers_minimum_version(self):
return {"msvc": "192", "gcc": "11", "clang": "13", "apple-clang": "14"}
def _validate_cppstd(self):
if self.settings.compiler.get_safe("cppstd"):
# Validate the minimum cpp standard supported when installing the package. For C++ projects only
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(
str(self.settings.compiler), False
)
if (
minimum_version
and Version(self.settings.compiler.version) < minimum_version
):
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)
@property
def _required_options(self):
options = []
# Usage: options.append(("boost", [("without_graph", False), ("without_test", False)]))
return options
def _strict_options_requirements(self):
for requirement, options in self._required_options:
for option_name, value in options:
setattr(self.options[requirement], f"{option_name}", value)
def _validate_options_requirements(self):
for requirement, options in self._required_options:
is_missing_option = not all(
self.dependencies[requirement].options.get_safe(f"{option_name}")
== value
for option_name, value in options
)
if is_missing_option:
raise ConanInvalidConfiguration(
f"{self.ref} requires {requirement} with these options: {options}"
)
def validate(self):
self._validate_cppstd()
self._validate_options_requirements()
def build_requirements(self):
self.tool_requires("cmake/[>=3.25 <4.0.0]")
def generate(self):
CMakeDeps(self).generate()
toolchain = CMakeToolchain(self)
toolchain.presets_prefix = ""
toolchain.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
if not self.conf.get("tools.build:skip_test", default=False):
cmake.test()
def package(self):
copy(
self,
pattern="LICENSE",
dst=os.path.join(self.package_folder, "licenses"),
src=self.source_folder,
)
cmake = CMake(self)
cmake.install()
# some files extensions and folders are not allowed. Please, read the FAQs to get informed.
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))
rm(self, "*.la", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "lib"))
rm(self, "*.pdb", os.path.join(self.package_folder, "bin"))
def package_info(self):
self.cpp_info.libs = ["starter"]
self.cpp_info.set_property("cmake_file_name", "starter")
self.cpp_info.set_property("cmake_target_name", "starter::starter")