Skip to content
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

Adding imagl recipe #4225

Merged
merged 4 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions recipes/imagl/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8.12)
project(cmake_wrapper)

include("conanbuildinfo.cmake")
conan_basic_setup()

add_subdirectory(source_subfolder)
4 changes: 4 additions & 0 deletions recipes/imagl/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -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"
81 changes: 81 additions & 0 deletions recipes/imagl/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Visual Studio": "16.5",
"Visual Studio": "16",

https://c3i.jfrog.io/c3i/misc/logs/pr/4225/4/imagl/0.1.0/summary.json

{
        "reference": "imagl/0.1.0",
        "packageID": "INVALID",
        "settings": {
            "os": "Windows",
            "os_build": "Windows",
            "arch": "x86_64",
            "arch_build": "x86_64",
            "compiler": "Visual Studio",
            "compiler.version": "16",
            "build_type": "Debug",
            "compiler.runtime": "MDd"
        },
        "options": {
            "imagl:shared": "True"
        },
        "status": "DUPLICATED",
        "profile": null,
        "build": null,
        "test": null
    },

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for you to commit this simple change, since the pull request is now approved? Or do I have to create a new pull request / issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to make a new PR, this way CCI can generate all new packages

"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"]
21 changes: 21 additions & 0 deletions recipes/imagl/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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()
Comment on lines +10 to +12
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this most likely needs to be in the package info


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)
17 changes: 17 additions & 0 deletions recipes/imagl/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 12 additions & 0 deletions recipes/imagl/all/test_package/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <iostream>
#include <imaGL/imaGL.h>

int main() {
try {
imaGL::CImaGL img("notfound.png");
}
catch(...) {
}
std::cout << "It works!\n";
return 0;
}
3 changes: 3 additions & 0 deletions recipes/imagl/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"0.1.0":
folder: all