diff --git a/recipes/imagl/all/CMakeLists.txt b/recipes/imagl/all/CMakeLists.txt new file mode 100644 index 0000000000000..d32836cbae4aa --- /dev/null +++ b/recipes/imagl/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.12) +project(cmake_wrapper) + +include("conanbuildinfo.cmake") +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/imagl/all/conandata.yml b/recipes/imagl/all/conandata.yml new file mode 100644 index 0000000000000..f58cd0ea1c049 --- /dev/null +++ b/recipes/imagl/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "0.1.0": + url: "https://gitlab-lepuy.iut-clermont.uca.fr/opengl/imagl/-/archive/v0.1.0/imagl-v0.1.0.tar.gz" + sha256: "9dcfba4c2efa8d44bf4cc9edd324794865dd6d6331467d3c69f5c5574db3844e" diff --git a/recipes/imagl/all/conanfile.py b/recipes/imagl/all/conanfile.py new file mode 100644 index 0000000000000..dbdede121a38f --- /dev/null +++ b/recipes/imagl/all/conanfile.py @@ -0,0 +1,81 @@ +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration +import os + + +required_conan_version = ">=1.32.0" + + +class ImaglConan(ConanFile): + name = "imagl" + license = "GPL-3.0-or-later" + homepage = "https://github.com/Woazim/imaGL" + url = "https://github.com/conan-io/conan-center-index" + 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} + generators = "cmake" + exports_sources = "CMakeLists.txt" + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + @property + def _compilers_minimum_version(self): + return { + "gcc": "9", + "Visual Studio": "16.5", + "clang": "10", + "apple-clang": "11" + } + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + os.rename(self.name + "-v" + self.version, self._source_subfolder) + + def validate(self): + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, 20) + 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.") + else: + self.output.warn("imagl requires C++20. Your compiler is unknown. Assuming it supports C++20.") + + def requirements(self): + if self.options.with_png: + self.requires("libpng/1.6.37") + + 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 + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + + def package_info(self): + debug_suffix = "d" if self.settings.build_type == "Debug" else "" + static_suffix = "" if self.options.shared else "s" + self.cpp_info.libs = ["imaGL{}{}".format(debug_suffix, static_suffix)] + if not self.options.shared: + self.cpp_info.defines = ["IMAGL_STATIC=1"] diff --git a/recipes/imagl/all/test_package/CMakeLists.txt b/recipes/imagl/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..4935b678899c5 --- /dev/null +++ b/recipes/imagl/all/test_package/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.1) +project(PackageTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(example example.cpp) +target_link_libraries(example ${CONAN_LIBS}) + +if(STATIC_LIB) + add_compile_definitions(IMAGL_STATIC) +endif() + +set_property(TARGET example PROPERTY CXX_STANDARD 20) +set_property(TARGET example PROPERTY CXX_STANDARD_REQUIRED ON) + +# CTest is a testing tool that can be used to test your project. +# enable_testing() +# add_test(NAME example +# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin +# COMMAND example) diff --git a/recipes/imagl/all/test_package/conanfile.py b/recipes/imagl/all/test_package/conanfile.py new file mode 100644 index 0000000000000..156e2a8976e7c --- /dev/null +++ b/recipes/imagl/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os +from conans import ConanFile, CMake, tools + + +class ImaglTestConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self): + bin_path = os.path.join("bin", "example") + self.run(bin_path, run_environment=True) diff --git a/recipes/imagl/all/test_package/example.cpp b/recipes/imagl/all/test_package/example.cpp new file mode 100644 index 0000000000000..205dbf81d1b23 --- /dev/null +++ b/recipes/imagl/all/test_package/example.cpp @@ -0,0 +1,12 @@ +#include +#include + +int main() { + try { + imaGL::CImaGL img("notfound.png"); + } + catch(...) { + } + std::cout << "It works!\n"; + return 0; +} diff --git a/recipes/imagl/config.yml b/recipes/imagl/config.yml new file mode 100644 index 0000000000000..6c11a439d0bc2 --- /dev/null +++ b/recipes/imagl/config.yml @@ -0,0 +1,3 @@ +versions: + "0.1.0": + folder: all