Skip to content

Commit

Permalink
(#4630) Add imagl/0.2.1
Browse files Browse the repository at this point in the history
* Adding imagl recipe

* Adding configuration requirements in configure()

* Prepare for CCI

Signed-off-by: Uilian Ries <uilianries@gmail.com>

* Update conanfile.py

* Setting minimum Visual Studio to 16 to let CCI work.

* removing fPIC option for Windows config

* Adding imaGL 0.1.1

* Adding imagl 0.2.0

* Deleting unsupported option in configure, adding _supports_jpeg property, hardly detecting msvc compiler version

* Nicer way to get MSVC version.

* maybe this one, which directly comes from other recipes. But it does not work on my computer...

* More checks on clang and Visual, according to last building failures.

* Add a check to VS version >= 16 before trying to run vswhere

* When vswhere is not runnable, raise a ConanInvalidConfiguration.

* Workaround to check libc++ version.

* Using CXX environment variable to run clang++

* Direct access to clang at /usr/bin/clang++

* Check for libc++ as stdlib before checking its version

* Avoid to build imaGL in CCI with clang 11. Adding some Visual Studio tunning as well to let choose toolset minor version.

* Removed unused import subprocess

* Better looking with imports and "allow_clang_11" option

* Remove fPIC option for shared option

* Code formatting correction, warning when using allow_clang_11 & comments on CMake's Ninja generator need

* Removing vswhere in validate() and affectation to settings.compiler.cppstd

* Removing Ninja generator forcing which is no more needed since CCI uses MSVC 19.28

Co-authored-by: Uilian Ries <uilianries@gmail.com>
  • Loading branch information
Woazim and uilianries authored May 18, 2021
1 parent 73b6ce4 commit 496fd2b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 13 deletions.
6 changes: 6 additions & 0 deletions recipes/imagl/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@ sources:
"0.1.1":
url: "https://gitlab-lepuy.iut-clermont.uca.fr/opengl/imagl/-/archive/v0.1.1/imagl-v0.1.1.tar.gz"
sha256: "4a7502cc733431af6423246fe5144e2eddb984454a66cca51742c852980ac862"
"0.1.2":
url: "https://gitlab-lepuy.iut-clermont.uca.fr/opengl/imagl/-/archive/v0.1.2/imagl-v0.1.2.tar.gz"
sha256: "d1edf74e00f969a47dc56e4400b805600d6997270339d49e91b7c6112a2cb37e"
"0.2.1":
url: "https://gitlab-lepuy.iut-clermont.uca.fr/opengl/imagl/-/archive/v0.2.1/imagl-v0.2.1.tar.gz"
sha256: "5a68cdeff4338e411695cca16c4230567de298f8efee2a9fadcc6fa644a70248"
78 changes: 65 additions & 13 deletions recipes/imagl/all/conanfile.py
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"


Expand All @@ -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
Expand All @@ -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"

def source(self):
tools.get(**self.conan_data["sources"][self.version])
Expand All @@ -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

Expand Down
4 changes: 4 additions & 0 deletions recipes/imagl/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ versions:
folder: all
"0.1.1":
folder: all
"0.1.2":
folder: all
"0.2.1":
folder: all

0 comments on commit 496fd2b

Please sign in to comment.