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

add sdl2_image/2.0.5 and sdl2_mixer/2.0.4 #1317

Merged
merged 22 commits into from
Jul 21, 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
104 changes: 104 additions & 0 deletions recipes/sdl2_image/2.0.5/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
cmake_minimum_required(VERSION 2.8)

project(SDL2_image)

include(conanbuildinfo.cmake)
conan_basic_setup()

find_package(SDL2 REQUIRED CONFIG)

macro(add_image_option type)
option(${type} "${type} images support" ON)
if(${type})
add_definitions("-DLOAD_${type}")
if(${type}_DYNAMIC)
add_definitions("-DLOAD_${type}_DYNAMIC")
endif()
endif()
endmacro()

if(APPLE)
option(IMAGEIO "use native Mac OS X frameworks for loading images" ON)
if(IMAGEIO)
set(IMAGEIO_SOURCE "source_subfolder/IMG_ImageIO.m")
else()
add_definitions("-DSDL_IMAGE_USE_COMMON_BACKEND")
endif()
endif()

add_image_option(BMP)
add_image_option(GIF)
add_image_option(JPG)
add_image_option(LBM)
add_image_option(PCX)
add_image_option(PNG)
add_image_option(PNM)
add_image_option(SVG)
add_image_option(TGA)
add_image_option(TIF)
add_image_option(WEBP)
add_image_option(XCF)
add_image_option(XPM)
add_image_option(XV)

set(SOURCES
source_subfolder/IMG.c
source_subfolder/IMG_bmp.c
source_subfolder/IMG_gif.c
source_subfolder/IMG_jpg.c
source_subfolder/IMG_lbm.c
source_subfolder/IMG_pcx.c
source_subfolder/IMG_png.c
source_subfolder/IMG_pnm.c
source_subfolder/IMG_svg.c
source_subfolder/IMG_tga.c
source_subfolder/IMG_tif.c
source_subfolder/IMG_xcf.c
source_subfolder/IMG_xpm.c
source_subfolder/IMG_xv.c
source_subfolder/IMG_webp.c
${IMAGEIO_SOURCE}
)

add_library(${PROJECT_NAME} ${SOURCES})

target_include_directories(${PROJECT_NAME} PRIVATE "source_subfolder")

if(${SDL_IS_SHARED})
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2::SDL2)
else()
target_link_libraries(${PROJECT_NAME} PRIVATE SDL2::SDL2-static)
endif()

if(${TIF})
find_package(TIFF REQUIRED CONFIG)
target_link_libraries(${PROJECT_NAME} PRIVATE TIFF::TIFF)
endif()

if(${JPG})
find_package(JPEG REQUIRED CONFIG)
target_link_libraries(${PROJECT_NAME} PRIVATE JPEG::JPEG)
endif()

if(${PNG})
find_package(PNG REQUIRED CONFIG)
target_link_libraries(${PROJECT_NAME} PRIVATE PNG::PNG)
endif()

if(${WEBP})
find_package(WebP REQUIRED CONFIG)
target_link_libraries(${PROJECT_NAME} PRIVATE WebP::webp)
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER source_subfolder/SDL_image.h)

if(${BUILD_SHARED_LIBS})
target_compile_definitions(${PROJECT_NAME} PRIVATE DLL_EXPORT)
endif()

install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION "lib"
LIBRARY DESTINATION "lib"
RUNTIME DESTINATION "bin"
PUBLIC_HEADER DESTINATION "include/SDL2"
)
4 changes: 4 additions & 0 deletions recipes/sdl2_image/2.0.5/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"2.0.5":
url: "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.5.tar.gz"
sha256: "bdd5f6e026682f7d7e1be0b6051b209da2f402a2dd8bd1c4bd9c25ad263108d0"
127 changes: 127 additions & 0 deletions recipes/sdl2_image/2.0.5/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
from conans import ConanFile, tools, CMake
import os


class SDL2ImageConan(ConanFile):
name = "sdl2_image"
description = "SDL_image is an image file loading library"
topics = ("sdl2_image", "sdl_image", "sdl2", "sdl", "images", "opengl")
url = "https://github.com/bincrafters/community"
homepage = "https://www.libsdl.org/projects/SDL_image/"
license = "MIT"
exports_sources = ["CMakeLists.txt"]
generators = ["cmake", "cmake_find_package_multi"]
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
"bmp": [True, False],
"gif": [True, False],
"lbm": [True, False],
"pcx": [True, False],
"pnm": [True, False],
"svg": [True, False],
"tga": [True, False],
"xcf": [True, False],
"xpm": [True, False],
"xv": [True, False],
"jpg": [True, False],
"tif": [True, False],
"png": [True, False],
"webp": [True, False],
"imageio": [True, False]}
default_options = {
"shared": False,
"fPIC": True,
"bmp": True,
"gif": True,
"lbm": True,
"pcx": True,
"pnm": True,
"svg": True,
"tga": True,
"xcf": True,
"xpm": True,
"xv": True,
"jpg": True,
"tif": True,
"png": True,
"webp": True,
"imageio": False
}

_cmake = None
_source_subfolder = "source_subfolder"
_build_subfolder = "build_subfolder"

def config_options(self):
del self.settings.compiler.libcxx
del self.settings.compiler.cppstd
if self.settings.os == "Windows":
del self.options.fPIC
if self.settings.os != "Macos":
del self.options.imageio

def requirements(self):
self.requires("sdl2/2.0.14@bincrafters/stable")
if self.options.tif:
self.requires("libtiff/4.0.9")
if self.options.jpg:
self.requires("libjpeg/9d")
if self.options.png:
self.requires("libpng/1.6.37")
if self.options.webp:
self.requires("libwebp/1.0.3")
self.requires("zlib/1.2.11")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = "SDL2_image-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def _configure_cmake(self):
if self._cmake:
return self._cmake

self._cmake = CMake(self)
self._cmake.definitions["BMP"] = self.options.bmp
self._cmake.definitions["GIF"] = self.options.gif
self._cmake.definitions["IMAGEIO"] = self.options.get_safe("imageio")
self._cmake.definitions["JPG"] = self.options.jpg
self._cmake.definitions["LBM"] = self.options.lbm
self._cmake.definitions["PCX"] = self.options.pcx
self._cmake.definitions["PNG"] = self.options.png
self._cmake.definitions["PNM"] = self.options.pnm
self._cmake.definitions["SVG"] = self.options.svg
self._cmake.definitions["TGA"] = self.options.tga
self._cmake.definitions["TIF"] = self.options.tif
self._cmake.definitions["WEBP"] = self.options.webp
self._cmake.definitions["XCF"] = self.options.xcf
self._cmake.definitions["XPM"] = self.options.xpm
self._cmake.definitions["XV"] = self.options.xv
# TODO: https://github.com/bincrafters/community/pull/1317#pullrequestreview-584847138
self._cmake.definitions["TIF_DYNAMIC"] = self.options["libtiff"].shared if self.options.tif else False
self._cmake.definitions["JPG_DYNAMIC"] = self.options["libjpeg"].shared if self.options.jpg else False
self._cmake.definitions["PNG_DYNAMIC"] = self.options["libpng"].shared if self.options.png else False
self._cmake.definitions["WEBP_DYNAMIC"] = self.options["libwebp"].shared if self.options.webp else False
self._cmake.definitions["SDL_IS_SHARED"] = self.options["sdl2"].shared

self._cmake.configure(build_dir="build")
return self._cmake

def build(self):
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy(pattern="COPYING.txt", dst="license", src=self._source_subfolder)
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
self.cpp_info.libs = ["SDL2_image"]
self.cpp_info.includedirs.append(os.path.join("include", "SDL2"))
# TODO: Add components in a sane way. SDL2_image might be incorrect, as the current dev version uses SDL2::image
# The current dev version is the first version with official CMake support
self.cpp_info.names["cmake_find_package"] = "SDL2_image"
self.cpp_info.names["cmake_find_package_multi"] = "SDL2_image"
11 changes: 11 additions & 0 deletions recipes/sdl2_image/2.0.5/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)


include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()

find_package(SDL2_image REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} SDL2_image::SDL2_image)
17 changes: 17 additions & 0 deletions recipes/sdl2_image/2.0.5/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
19 changes: 19 additions & 0 deletions recipes/sdl2_image/2.0.5/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <cstdlib>
#include <iostream>
#include "SDL_image.h"

int main(int argc, char *argv[])
{
SDL_version compile_version;
const SDL_version * link_version=IMG_Linked_Version();
SDL_IMAGE_VERSION(&compile_version);
std::cout << "SDL2_image compile version: " <<
int(compile_version.major) << "." <<
int(compile_version.minor) << "." <<
int(compile_version.patch) << std::endl;
std::cout << "SDL2_image link version: " <<
int(link_version->major) << "." <<
int(link_version->minor) << "." <<
int(link_version->patch) << std::endl;
return EXIT_SUCCESS;
}
3 changes: 3 additions & 0 deletions recipes/sdl2_image/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"2.0.5":
folder: "2.0.5"
Loading