aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Bader <mail@patrickbader.eu>2017-01-06 19:08:31 +0100
committerPatrick Bader <mail@patrickbader.eu>2017-01-06 19:08:31 +0100
commit37a5504855a83e24eb06ca1b5dd16b3dabd68313 (patch)
treeebc599b7700aaeb74366fe07f69e42038754be33
parent795ac00e6e7acf5b23b84af0399b418f6164e45c (diff)
downloadvcpkg-37a5504855a83e24eb06ca1b5dd16b3dabd68313.tar.gz
vcpkg-37a5504855a83e24eb06ca1b5dd16b3dabd68313.zip
finished port of sdl2_image
- optional dependencies which are installed in vcpkg are automatically linked - unavailable dependencies are marked as dynamically linked and dlls have to be copied manually if respective file formats are used
-rw-r--r--ports/sdl2-image/CMakeLists.txt81
-rw-r--r--ports/sdl2-image/CONTROL6
-rw-r--r--ports/sdl2-image/FindWEBP.cmake51
-rw-r--r--ports/sdl2-image/portfile.cmake5
4 files changed, 132 insertions, 11 deletions
diff --git a/ports/sdl2-image/CMakeLists.txt b/ports/sdl2-image/CMakeLists.txt
index 3167294d3..a77662c0e 100644
--- a/ports/sdl2-image/CMakeLists.txt
+++ b/ports/sdl2-image/CMakeLists.txt
@@ -1,16 +1,29 @@
cmake_minimum_required(VERSION 2.6)
project(SDL2_image)
-find_path(SDL_INCLUDE_DIR SDL2/SDL.h)
-find_library(SDL_LIBRARY SDL2)
+### configuration ###
-include_directories(${SDL_INCLUDE_DIR})
-include_directories(${SDL_INCLUDE_DIR}/SDL2)
-include_directories(${CMAKE_SOURCE_DIR})
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
+# enable all file formats which are supported natively
+set(SUPPORTED_FORMATS BMP GIF LBM PCX PNM TGA XPM XCF XV)
-#add_definitions(-DNOCONTROLS -DTHREADED_AUDIO)
+# enable all file formats which are supported through external dependencies
+# first try to load them statically (lib file in vcpkg installation)
+# if this fails try to make them a dynamic dependency (dll will be loaded at runtime) if possible. vcpkg cannot resolve these dependencies!
+# else do not support this file format at all
+set(DEPENDENCIES PNG JPEG TIFF WEBP)
-# some c++ code just assumes memset is available
+# patch library names for preprocessor flags
+set(JPEG_FLAG JPG)
+set(TIFF_FLAG TIF)
+
+# names of potentially dynamically loaded libraries
+set(JPEG_DYNAMIC \"libjpeg-9.dll\")
+set(PNG_DYNAMIC \"libpng16-16.dll\")
+set(TIFF_DYNAMIC \"libtiff-5.dll\")
+set(WEBP_DYNAMIC \"libwebp-4.dll\")
+
+### implementation ###
add_library(SDL2_image
IMG.c
@@ -30,15 +43,67 @@ add_library(SDL2_image
IMG_xxx.c
)
+foreach(FORMAT ${SUPPORTED_FORMATS})
+ add_definitions(-DLOAD_${FORMAT})
+endforeach(FORMAT)
+
+# SDL
+find_path(SDL_INCLUDE_DIR SDL2/SDL.h)
+find_library(SDL_LIBRARY SDL2)
+
+include_directories(${SDL_INCLUDE_DIR})
+include_directories(${SDL_INCLUDE_DIR}/SDL2)
+include_directories(${CMAKE_SOURCE_DIR})
+
target_link_libraries(SDL2_image ${SDL_LIBRARY})
+# external dependencies
+foreach(DEPENDENCY ${DEPENDENCIES})
+ find_package(${DEPENDENCY})
+
+ if(NOT DEFINED ${DEPENDENCY}_FLAG)
+ set(${DEPENDENCY}_FLAG ${DEPENDENCY})
+ endif()
+
+ add_definitions(-DLOAD_${${DEPENDENCY}_FLAG})
+ if(${DEPENDENCY}_FOUND)
+ message(STATUS " --> linking statically.")
+ target_link_libraries(SDL2_image ${${DEPENDENCY}_LIBRARIES})
+ elseif(DEFINED ${DEPENDENCY}_DYNAMIC)
+ message(STATUS " --> linking dynamically.")
+ add_definitions(-DLOAD_${${DEPENDENCY}_FLAG}_DYNAMIC=${${DEPENDENCY}_DYNAMIC})
+ set(RUNTIME_DEPENDENCIES ON)
+ else()
+ message(STATUS " --> skipping.")
+ endif()
+endforeach(DEPENDENCY)
+
+if(DEFINED RUNTIME_DEPENDENCIES)
+ include_directories(VisualC/external/include)
+endif()
+
+
install(TARGETS SDL2_image
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
-install(FILES SDL_image.h DESTINATION include CONFIGURATIONS Release)
+install(FILES SDL_image.h DESTINATION include/SDL2_image CONFIGURATIONS Release)
message(STATUS "Link-time dependencies:")
message(STATUS " " ${SDL_LIBRARY})
+foreach(DEPENDENCY ${DEPENDENCIES})
+ if(${DEPENDENCY}_FOUND)
+ message(STATUS " " ${DEPENDENCY})
+ endif()
+endforeach(DEPENDENCY)
+
+if(DEFINED RUNTIME_DEPENDENCIES)
+ message(STATUS "Run-time dependencies:")
+ foreach(DEPENDENCY ${DEPENDENCIES})
+ if(NOT ${DEPENDENCY}_FOUND AND DEFINED ${DEPENDENCY}_DYNAMIC)
+ message(STATUS " " ${${DEPENDENCY}_DYNAMIC})
+ endif()
+ endforeach(DEPENDENCY)
+endif() \ No newline at end of file
diff --git a/ports/sdl2-image/CONTROL b/ports/sdl2-image/CONTROL
index 591550cdc..f9785ba22 100644
--- a/ports/sdl2-image/CONTROL
+++ b/ports/sdl2-image/CONTROL
@@ -1,3 +1,5 @@
Source: sdl2-image
-Version:
-Description:
+Version: 2.0.1
+Build-Depends: sdl2
+Description: SDL_image is an image file loading library. It loads images as SDL surfaces and textures, and supports the following formats: BMP, GIF, JPEG, LBM, PCX, PNG, PNM, TGA, TIFF, WEBP, XCF, XPM, XV
+
diff --git a/ports/sdl2-image/FindWEBP.cmake b/ports/sdl2-image/FindWEBP.cmake
new file mode 100644
index 000000000..ddabe71fe
--- /dev/null
+++ b/ports/sdl2-image/FindWEBP.cmake
@@ -0,0 +1,51 @@
+# - Try to find WebP.
+# Once done, this will define
+#
+# WEBP_FOUND - system has WebP.
+# WEBP_INCLUDE_DIRS - the WebP. include directories
+# WEBP_LIBRARIES - link these to use WebP.
+#
+# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
+# Copyright (C) 2013 Igalia S.L.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
+# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+find_package(PkgConfig)
+pkg_check_modules(PC_WEBP QUIET libwebp)
+
+# Look for the header file.
+find_path(WEBP_INCLUDE_DIRS
+ NAMES webp/decode.h
+ HINTS ${PC_WEBP_INCLUDEDIR} ${PC_WEBP_INCLUDE_DIRS}
+)
+mark_as_advanced(WEBP_INCLUDE_DIRS)
+
+# Look for the library.
+find_library(
+ WEBP_LIBRARIES
+ NAMES webp
+ HINTS ${PC_WEBP_LIBDIR} ${PC_WEBP_LIBRARY_DIRS}
+)
+mark_as_advanced(WEBP_LIBRARIES)
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(WEBP DEFAULT_MSG WEBP_INCLUDE_DIRS WEBP_LIBRARIES) \ No newline at end of file
diff --git a/ports/sdl2-image/portfile.cmake b/ports/sdl2-image/portfile.cmake
index f70d237c2..4cc6ce74a 100644
--- a/ports/sdl2-image/portfile.cmake
+++ b/ports/sdl2-image/portfile.cmake
@@ -21,10 +21,11 @@ vcpkg_apply_patches(
${CMAKE_CURRENT_LIST_DIR}/correct-sdl-headers-dir.patch)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
+file(COPY ${CMAKE_CURRENT_LIST_DIR}/FindWEBP.cmake DESTINATION ${SOURCE_PATH}/cmake)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
- # OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 -DUSE_THIS_TOO=2
+ # OPTIONS
# OPTIONS_RELEASE -DOPTIMIZE=1
# OPTIONS_DEBUG -DDEBUGGABLE=1
)
@@ -34,3 +35,5 @@ vcpkg_install_cmake()
# Handle copyright
file(COPY ${SOURCE_PATH}/COPYING.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/sdl2-image)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/sdl2-image/COPYING.txt ${CURRENT_PACKAGES_DIR}/share/sdl2-image/copyright)
+
+vcpkg_copy_pdbs() \ No newline at end of file