[sdl2-image] Features must use sdl2[x11] on Linux (#23725)

* Fix shared libs suffix

* Remove version-string

* version

* Use cmake version of shared lib suffix

* version

* Remove old feature processing

* version

* Real fix

* [sdl2] Fix x11 feature

* format

* version

* Fix suffix again

* version

* Fix external dependencies

* version

* Fix WebP linkage

* version

* Fix PNG linkage

* version

* Mark everything as default feature for testing

* version

* Trigger rebuild of sdl2pp

* version

* congig file

* Fix flags

* version

* Fix flags

* version

* Disable UWP warnings for TIFF

* version

* Fix CXX

* version

* revert cmake version

* version

* Fix config

* version

* Revert sdl2pp

* Fix config

* version

* Create config.cmake.in file

* version
This commit is contained in:
Thomas1664 2022-04-15 22:44:08 +02:00 committed by GitHub
parent 94c2aed904
commit 05bcc5fca4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 90 additions and 94 deletions

View File

@ -3,27 +3,14 @@ project(SDL2_image C)
### configuration ### ### configuration ###
list(APPEND CMAKE_MODULE_PATH "${CURRENT_INSTALLED_DIR}/share/libwebp")
# enable all file formats which are supported natively # enable all file formats which are supported natively
set(SUPPORTED_FORMATS BMP GIF LBM PCX PNM TGA XPM XCF XV SVG) set(SUPPORTED_FORMATS BMP GIF LBM PCX PNM TGA XPM XCF XV SVG)
# enable all file formats which are supported through external dependencies # enable all file formats which are supported through external dependencies
# first try to load them statically (lib file in vcpkg installation) option(USE_WEBP "Enable support for WebP format" OFF)
# if this fails try to make them a dynamic dependency (dll will be loaded at runtime) if possible. vcpkg cannot resolve these dependencies! option(USE_PNG "Enable support for PNG format" OFF)
# else do not support this file format at all option(USE_JPEG "Enable support for JPEG format" OFF)
option(USE_TIFF "Enable support for TIFF format" OFF)
# Can be explicitly enabled or disabled via USE_XYZ
set(DEPENDENCIES PNG JPEG TIFF WEBP)
# 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 ### ### implementation ###
@ -74,33 +61,34 @@ include_directories(${CMAKE_SOURCE_DIR})
target_link_libraries(SDL2_image SDL2::SDL2) target_link_libraries(SDL2_image SDL2::SDL2)
# external dependencies # external dependencies
foreach(DEPENDENCY IN LISTS DEPENDENCIES) if(USE_WEBP)
if(NOT USE_${DEPENDENCY}) find_package(WebP CONFIG REQUIRED)
continue() add_definitions(-DLOAD_WEBP)
endif() target_link_libraries(SDL2_image PRIVATE WebP::webp)
find_package(${DEPENDENCY})
if(NOT DEFINED ${DEPENDENCY}_FLAG)
set(${DEPENDENCY}_FLAG ${DEPENDENCY})
endif() endif()
add_definitions(-DLOAD_${${DEPENDENCY}_FLAG}) if(USE_PNG)
if(${DEPENDENCY}_FOUND) find_package(libpng REQUIRED)
message(STATUS " --> linking statically.") add_definitions(-DLOAD_PNG)
target_link_libraries(SDL2_image ${${DEPENDENCY}_LIBRARIES}) target_link_libraries(SDL2_image PRIVATE png)
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() endif()
if(USE_JPEG)
find_package(JPEG REQUIRED)
add_definitions(-DLOAD_JPG)
target_link_libraries(SDL2_image PRIVATE ${JPEG_LIBRARIES})
endif()
if(USE_TIFF)
find_package(TIFF REQUIRED)
add_definitions(-DLOAD_TIF)
target_link_libraries(SDL2_image PRIVATE TIFF::TIFF)
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996")
endif()
endif()
install(TARGETS SDL2_image install(TARGETS SDL2_image
EXPORT SDL2_image EXPORT SDL2_image
@ -110,11 +98,10 @@ install(TARGETS SDL2_image
install(FILES SDL_image.h DESTINATION include/SDL2 CONFIGURATIONS Release) install(FILES SDL_image.h DESTINATION include/SDL2 CONFIGURATIONS Release)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/sdl2-image-config.cmake" configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sdl2-image-config.cmake.in"
[[include(CMakeFindDependencyMacro) "${CMAKE_CURRENT_BINARY_DIR}/sdl2-image-config.cmake" @ONLY
find_dependency(SDL2 CONFIG) INSTALL_DESTINATION "share/sdl2-image")
include("${CMAKE_CURRENT_LIST_DIR}/sdl2-image-targets.cmake")
]])
set(prefix "") set(prefix "")
set(exec_prefix [[${prefix}]]) set(exec_prefix [[${prefix}]])
set(libdir [[${prefix}/lib]]) set(libdir [[${prefix}/lib]])
@ -141,20 +128,3 @@ install(EXPORT SDL2_image
FILE sdl2-image-targets.cmake FILE sdl2-image-targets.cmake
NAMESPACE SDL2:: NAMESPACE SDL2::
) )
message(STATUS "Link-time dependencies:")
message(STATUS " " SDL2::SDL2)
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()

View File

@ -15,30 +15,20 @@ vcpkg_extract_source_archive_ex(
) )
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/sdl2-image-config.cmake.in" DESTINATION "${SOURCE_PATH}")
set(USE_JPEG OFF) vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
if("libjpeg-turbo" IN_LIST FEATURES) FEATURES
set(USE_JPEG ON) libjpeg-turbo USE_JPEG
endif() tiff USE_TIFF
libwebp USE_WEBP
set(USE_TIFF OFF) )
if("tiff" IN_LIST FEATURES)
set(USE_TIFF ON)
endif()
set(USE_WEBP OFF)
if("libwebp" IN_LIST FEATURES)
set(USE_WEBP ON)
endif()
vcpkg_cmake_configure( vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}" SOURCE_PATH "${SOURCE_PATH}"
OPTIONS OPTIONS
"-DCURRENT_INSTALLED_DIR=${CURRENT_INSTALLED_DIR}"
-DUSE_PNG=ON -DUSE_PNG=ON
-DUSE_JPEG=${USE_JPEG} ${FEATURE_OPTIONS}
-DUSE_TIFF=${USE_TIFF}
-DUSE_WEBP=${USE_WEBP}
) )
vcpkg_cmake_install() vcpkg_cmake_install()

View File

@ -0,0 +1,6 @@
include(CMakeFindDependencyMacro)
find_dependency(SDL2 CONFIG)
if(@USE_WEBP@)
find_dependency(WebP CONFIG)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/sdl2-image-targets.cmake")

View File

@ -1,7 +1,7 @@
{ {
"name": "sdl2-image", "name": "sdl2-image",
"version-string": "2.0.5", "version": "2.0.5",
"port-version": 4, "port-version": 5,
"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", "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",
"homepage": "https://www.libsdl.org/projects/SDL_image", "homepage": "https://www.libsdl.org/projects/SDL_image",
"dependencies": [ "dependencies": [
@ -20,18 +20,39 @@
"libjpeg-turbo": { "libjpeg-turbo": {
"description": "Support for JPEG image format", "description": "Support for JPEG image format",
"dependencies": [ "dependencies": [
"libjpeg-turbo" "libjpeg-turbo",
{
"name": "sdl2",
"features": [
"x11"
],
"platform": "!windows"
}
] ]
}, },
"libwebp": { "libwebp": {
"description": "Support for WEBP image format.", "description": "Support for WEBP image format.",
"dependencies": [ "dependencies": [
"libwebp" "libwebp",
{
"name": "sdl2",
"features": [
"x11"
],
"platform": "!windows"
}
] ]
}, },
"tiff": { "tiff": {
"description": "Support for TIFF image format", "description": "Support for TIFF image format",
"dependencies": [ "dependencies": [
{
"name": "sdl2",
"features": [
"x11"
],
"platform": "!windows"
},
"tiff" "tiff"
] ]
} }

View File

@ -26,9 +26,6 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
) )
if ("x11" IN_LIST FEATURES) if ("x11" IN_LIST FEATURES)
if (VCPKG_TARGET_IS_WINDOWS)
message(FATAL_ERROR "Feature x11 only support UNIX.")
endif()
message(WARNING "You will need to install Xorg dependencies to use feature x11:\nsudo apt install libx11-dev libxft-dev libxext-dev\n") message(WARNING "You will need to install Xorg dependencies to use feature x11:\nsudo apt install libx11-dev libxft-dev libxext-dev\n")
endif() endif()
@ -84,7 +81,6 @@ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP AND NOT VCPKG_TARGET_IS_M
endforeach() endforeach()
endif() endif()
configure_file("${SOURCE_PATH}/LICENSE.txt" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" COPYONLY)
vcpkg_copy_pdbs() vcpkg_copy_pdbs()
set(DYLIB_COMPATIBILITY_VERSION_REGEX "set\\(DYLIB_COMPATIBILITY_VERSION (.+)\\)") set(DYLIB_COMPATIBILITY_VERSION_REGEX "set\\(DYLIB_COMPATIBILITY_VERSION (.+)\\)")
@ -100,3 +96,5 @@ if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug")
endif() endif()
vcpkg_fixup_pkgconfig() vcpkg_fixup_pkgconfig()
file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

View File

@ -1,7 +1,7 @@
{ {
"name": "sdl2", "name": "sdl2",
"version": "2.0.20", "version": "2.0.20",
"port-version": 1, "port-version": 2,
"description": "Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.", "description": "Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D.",
"homepage": "https://www.libsdl.org/download-2.0.php", "homepage": "https://www.libsdl.org/download-2.0.php",
"dependencies": [ "dependencies": [
@ -19,7 +19,8 @@
"description": "Vulkan functionality for SDL" "description": "Vulkan functionality for SDL"
}, },
"x11": { "x11": {
"description": "Dynamically load X11 support" "description": "Dynamically load X11 support",
"supports": "!windows"
} }
} }
} }

View File

@ -6370,7 +6370,7 @@
}, },
"sdl2": { "sdl2": {
"baseline": "2.0.20", "baseline": "2.0.20",
"port-version": 1 "port-version": 2
}, },
"sdl2-gfx": { "sdl2-gfx": {
"baseline": "1.0.4", "baseline": "1.0.4",
@ -6378,7 +6378,7 @@
}, },
"sdl2-image": { "sdl2-image": {
"baseline": "2.0.5", "baseline": "2.0.5",
"port-version": 4 "port-version": 5
}, },
"sdl2-mixer": { "sdl2-mixer": {
"baseline": "2.0.4", "baseline": "2.0.4",

View File

@ -1,5 +1,10 @@
{ {
"versions": [ "versions": [
{
"git-tree": "623548e8c929f2160320bf9644e2cd5a75d4a608",
"version": "2.0.5",
"port-version": 5
},
{ {
"git-tree": "9042c449fc4c728c5b428332e09bc6d21a2acf34", "git-tree": "9042c449fc4c728c5b428332e09bc6d21a2acf34",
"version-string": "2.0.5", "version-string": "2.0.5",

View File

@ -1,5 +1,10 @@
{ {
"versions": [ "versions": [
{
"git-tree": "abf71c19917402dddef261e80d55c8ec04e9bf54",
"version": "2.0.20",
"port-version": 2
},
{ {
"git-tree": "9900463f2847ed86e25bac1688c527ae3486a024", "git-tree": "9900463f2847ed86e25bac1688c527ae3486a024",
"version": "2.0.20", "version": "2.0.20",