-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add imagl/0.2.1 #4630
Add imagl/0.2.1 #4630
Changes from all commits
e9078dd
8376ef5
34a13cf
e12e215
109a45e
a391575
906a478
a5c8d70
37ea45e
4c90e58
1345d65
e2ad08a
5028584
065ea9b
4932cd9
12c9114
e49ff9c
eaa0681
376bd3e
da8f340
055e6a9
36707d3
ae26a9a
0fd9fe3
e2bcef8
a416447
0dcdf20
3476bcb
0aab732
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
from conans import ConanFile, CMake, tools | ||
from conans.errors import ConanInvalidConfiguration | ||
from conans.errors import ConanInvalidConfiguration, ConanException | ||
import os | ||
|
||
|
||
required_conan_version = ">=1.32.0" | ||
|
||
|
||
|
@@ -14,8 +13,20 @@ class ImaglConan(ConanFile): | |
description = "A lightweight library to load image for OpenGL application." | ||
topics = ("opengl", "texture", "image") | ||
settings = "os", "compiler", "build_type", "arch" | ||
options = {"shared": [True, False], "fPIC": [True, False], "with_png": [True, False]} | ||
default_options = {"shared": False, "fPIC": True, "with_png": True} | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"with_png": [True, False], | ||
"with_jpeg": [True, False], | ||
"allow_clang_11": [None, True, False] | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"with_png": True, | ||
"with_jpeg": True, | ||
"allow_clang_11": None | ||
} | ||
generators = "cmake" | ||
exports_sources = "CMakeLists.txt" | ||
_cmake = None | ||
|
@@ -30,12 +41,21 @@ def _build_subfolder(self): | |
|
||
@property | ||
def _compilers_minimum_version(self): | ||
return { | ||
"gcc": "9", | ||
"Visual Studio": "16", | ||
"clang": "10", | ||
"apple-clang": "11" | ||
minimum_versions = { | ||
"gcc": "9", | ||
"Visual Studio": "16.2", | ||
"msvc": "19.22", | ||
"clang": "10", | ||
"apple-clang": "11" | ||
} | ||
if tools.Version(self.version) <= "0.1.1" or tools.Version(self.version) == "0.2.0": | ||
minimum_versions["Visual Studio"] = "16.5" | ||
minimum_versions["msvc"] = "19.25" | ||
return minimum_versions | ||
|
||
@property | ||
def _supports_jpeg(self): | ||
return tools.Version(self.version) >= "0.2.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Version 0.2.0 is not listed in config.yml... is this a typo? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's fine for me, I guess that jpeg support was added in 0.2.0, so it doesn't matter that exact 0.2.0 version was not in CCI, it makes the recipe more robust if for any reason 0.2.0 is added later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We started by adding 0.2.0 but there was a new point release since then |
||
|
||
def source(self): | ||
tools.get(**self.conan_data["sources"][self.version]) | ||
|
@@ -44,27 +64,59 @@ def source(self): | |
def validate(self): | ||
if self.settings.compiler.cppstd: | ||
tools.check_min_cppstd(self, 20) | ||
|
||
def lazy_lt_semver(v1, v2): | ||
lv1 = [int(v) for v in v1.split(".")] | ||
lv2 = [int(v) for v in v2.split(".")] | ||
min_length = min(len(lv1), len(lv2)) | ||
return lv1[:min_length] < lv2[:min_length] | ||
|
||
#Special check for clang that can only be linked to libc++ | ||
if self.settings.compiler == "clang" and self.settings.compiler.libcxx != "libc++": | ||
raise ConanInvalidConfiguration("imagl requires some C++20 features, which are available in libc++ for clang compiler.") | ||
|
||
compiler_version = str(self.settings.compiler.version) | ||
|
||
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) | ||
if minimum_version: | ||
if tools.Version(self.settings.compiler.version) < minimum_version: | ||
raise ConanInvalidConfiguration("imagl requires C++20, which your compiler does not fully support.") | ||
if not minimum_version: | ||
self.output.warn("imaGL requires C++20. Your compiler is unknown. Assuming it supports C++20.") | ||
elif lazy_lt_semver(compiler_version, minimum_version): | ||
raise ConanInvalidConfiguration("imaGL requires some C++20 features, which your {} {} compiler does not support.".format(str(self.settings.compiler), compiler_version)) | ||
elif str(self.settings.compiler) == "clang" and compiler_version == "11" and not self.options.allow_clang_11: | ||
raise ConanInvalidConfiguration("Clang 11 is not currently supported by conan center index. To build imaGL, append '-o imagl:allow_clang_11=True --build missing' to your 'conan install' command line.") | ||
else: | ||
self.output.warn("imagl requires C++20. Your compiler is unknown. Assuming it supports C++20.") | ||
print("Your compiler is {} {} and is compatible.".format(str(self.settings.compiler), compiler_version)) | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
if not self._supports_jpeg: | ||
del self.options.with_jpeg | ||
if not str(self.settings.compiler) == "clang" or not str(self.settings.compiler.version) == "11": | ||
del self.options.allow_clang_11 | ||
else: | ||
self.output.warn("allow_clang_11 option will be removed in the future when conan center index will support clang 11.") | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
del self.options.fPIC | ||
|
||
def requirements(self): | ||
if self.options.with_png: | ||
self.requires("libpng/1.6.37") | ||
if self._supports_jpeg and self.options.with_jpeg: | ||
self.requires("libjpeg/9d") | ||
|
||
def _configure_cmake(self): | ||
if self._cmake: | ||
return self._cmake | ||
|
||
self._cmake = CMake(self) | ||
|
||
self._cmake.definitions["STATIC_LIB"] = not self.options.shared | ||
self._cmake.definitions["SUPPORT_PNG"] = self.options.with_png | ||
if self._supports_jpeg: | ||
self._cmake.definitions["SUPPORT_JPEG"] = self.options.with_jpeg | ||
self._cmake.configure(build_folder=self._build_subfolder) | ||
return self._cmake | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,7 @@ versions: | |
folder: all | ||
"0.1.1": | ||
folder: all | ||
"0.1.2": | ||
folder: all | ||
"0.2.1": | ||
folder: all |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Version 0.2.0 is not listed in config.yml... is this a typo?