-
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
Adding imagl recipe #4225
Adding imagl recipe #4225
Changes from 2 commits
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 |
---|---|---|
@@ -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" |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,66 @@ | ||||
from conans import ConanFile, CMake, tools, errors | ||||
|
||||
class ImaglConan(ConanFile): | ||||
name = "imagl" | ||||
license = "GPL-3" | ||||
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. Directly compatible with glTexImage* functions. Tested on linux, macOS and Windows with gcc, clang and msvc." | ||||
topics = ("opengl", "texture", "image") | ||||
settings = "os", "compiler", "build_type", "arch" | ||||
options = {"shared": [True, False]} | ||||
default_options = {"shared": False} | ||||
generators = "cmake" | ||||
requires = [("libpng/1.6.37")] | ||||
|
||||
def source(self): | ||||
tools.get(**self.conan_data["sources"][self.version]) | ||||
# This small hack might be useful to guarantee proper /MT /MD linkage | ||||
# in MSVC if the packaged project doesn't have variables to set it | ||||
# properly | ||||
tools.replace_in_file(self.name + "-v" + self.version + "/CMakeLists.txt", "# conan insert", | ||||
'''include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | ||||
conan_basic_setup()''') | ||||
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. patching sources needs to be done in the build method |
||||
|
||||
def build(self): | ||||
cmake = CMake(self) | ||||
cmake.verbose = True | ||||
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.
Suggested change
|
||||
cmake.configure(source_folder=self.name + "-v" + self.version, defs={"STATIC_LIB": "OFF" if self.options.shared else "ON"}) | ||||
cmake.build() | ||||
cmake.install() | ||||
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. this should be done in the package method |
||||
|
||||
# Explicit way: | ||||
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. pls remove dead code |
||||
# self.run('cmake %s/hello %s' | ||||
# % (self.source_folder, cmake.command_line)) | ||||
# self.run("cmake --build . %s" % cmake.build_config) | ||||
|
||||
def package(self): | ||||
self.copy("*.h", dst="include", src=self.package_folder + "include") | ||||
self.copy("*.lib", dst="lib", keep_path=False) | ||||
self.copy("*.dll", dst="bin", keep_path=False) | ||||
self.copy("*.so", dst="lib", keep_path=False) | ||||
self.copy("*.dylib", dst="lib", keep_path=False) | ||||
self.copy("*.a", dst="lib", keep_path=False) | ||||
self.copy(self.name + "-v" + self.version + "/LICENSE", dst="licenses", keep_path=False) | ||||
|
||||
def package_info(self): | ||||
debug_suffix = "" | ||||
static_suffix = "" | ||||
if self.settings.build_type == "Debug": debug_suffix = "d" | ||||
if not(self.options.shared): static_suffix = "s" | ||||
self.cpp_info.libs = ["imaGL{debug}{static}".format(debug = debug_suffix, static = static_suffix)] | ||||
|
||||
def configure(self): | ||||
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. This should be higher up in the order see this https://github.com/conan-io/conan-center-index/blob/ddd8c3c7499678583061a570b03cac615d67b157/docs/reviewing.md#order-of-methods-and-attributes For managing the c++ version requirements... I'd suggest you copy this snippet |
||||
if (self.settings.compiler == "clang" | ||||
and tools.Version(self.settings.compiler.version) < "10.0.0"): | ||||
raise errors.ConanInvalidConfiguration("Library imaGL need clang 10+") | ||||
if (self.settings.compiler == "gcc" | ||||
and tools.Version(self.settings.compiler.version) < "9.0.0"): | ||||
raise errors.ConanInvalidConfiguration("Library imaGL need gcc 9+") | ||||
if (self.settings.compiler == "apple-clang" | ||||
and tools.Version(self.settings.compiler.version) < "11.0.3"): | ||||
raise errors.ConanInvalidConfiguration("Library imaGL need apple-clang 11.0.3+") | ||||
if (self.settings.compiler == "Visual Studio" | ||||
and tools.Version(self.settings.compiler.version) < "16.5"): | ||||
raise errors.ConanInvalidConfiguration("Library imaGL need Visual Studio 16.5+") | ||||
|
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
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. 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) |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,22 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
import os | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
from conans import ConanFile, CMake, tools | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class ImaglTestConan(ConanFile): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
settings = "os", "compiler", "build_type", "arch" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options = {"shared": [True, False]} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
default_options = {"shared": False} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
generators = "cmake" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def build(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cmake = CMake(self) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# Current dir is "test_package/build/<build_id>" and CMakeLists.txt is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
# in "test_package" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cmake.configure(defs={"STATIC_LIB": "OFF" if self.options.shared else "ON"}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
cmake.build() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
def test(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
if not tools.cross_building(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
os.chdir("bin") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
self.run(".%sexample" % os.sep) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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. Please follow our usual test package format
Suggested change
|
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; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"0.1.0": | ||
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.
You are missing the
fPIC
option