Skip to content

Commit 05bcc5f

Browse files
authored
[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
1 parent 94c2aed commit 05bcc5f

File tree

9 files changed

+88
-92
lines changed

9 files changed

+88
-92
lines changed

ports/sdl2-image/CMakeLists.txt

Lines changed: 32 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,14 @@ project(SDL2_image C)
33

44
### configuration ###
55

6-
list(APPEND CMAKE_MODULE_PATH "${CURRENT_INSTALLED_DIR}/share/libwebp")
76
# enable all file formats which are supported natively
87
set(SUPPORTED_FORMATS BMP GIF LBM PCX PNM TGA XPM XCF XV SVG)
98

109
# enable all file formats which are supported through external dependencies
11-
# first try to load them statically (lib file in vcpkg installation)
12-
# if this fails try to make them a dynamic dependency (dll will be loaded at runtime) if possible. vcpkg cannot resolve these dependencies!
13-
# else do not support this file format at all
14-
15-
# Can be explicitly enabled or disabled via USE_XYZ
16-
set(DEPENDENCIES PNG JPEG TIFF WEBP)
17-
18-
# patch library names for preprocessor flags
19-
set(JPEG_FLAG JPG)
20-
set(TIFF_FLAG TIF)
21-
22-
# names of potentially dynamically loaded libraries
23-
set(JPEG_DYNAMIC \"libjpeg-9.dll\")
24-
set(PNG_DYNAMIC \"libpng16-16.dll\")
25-
set(TIFF_DYNAMIC \"libtiff-5.dll\")
26-
set(WEBP_DYNAMIC \"libwebp-4.dll\")
10+
option(USE_WEBP "Enable support for WebP format" OFF)
11+
option(USE_PNG "Enable support for PNG format" OFF)
12+
option(USE_JPEG "Enable support for JPEG format" OFF)
13+
option(USE_TIFF "Enable support for TIFF format" OFF)
2714

2815
### implementation ###
2916

@@ -74,33 +61,34 @@ include_directories(${CMAKE_SOURCE_DIR})
7461
target_link_libraries(SDL2_image SDL2::SDL2)
7562

7663
# external dependencies
77-
foreach(DEPENDENCY IN LISTS DEPENDENCIES)
78-
if(NOT USE_${DEPENDENCY})
79-
continue()
80-
endif()
81-
find_package(${DEPENDENCY})
82-
83-
if(NOT DEFINED ${DEPENDENCY}_FLAG)
84-
set(${DEPENDENCY}_FLAG ${DEPENDENCY})
85-
endif()
64+
if(USE_WEBP)
65+
find_package(WebP CONFIG REQUIRED)
66+
add_definitions(-DLOAD_WEBP)
67+
target_link_libraries(SDL2_image PRIVATE WebP::webp)
68+
endif()
8669

87-
add_definitions(-DLOAD_${${DEPENDENCY}_FLAG})
88-
if(${DEPENDENCY}_FOUND)
89-
message(STATUS " --> linking statically.")
90-
target_link_libraries(SDL2_image ${${DEPENDENCY}_LIBRARIES})
91-
elseif(DEFINED ${DEPENDENCY}_DYNAMIC)
92-
message(STATUS " --> linking dynamically.")
93-
add_definitions(-DLOAD_${${DEPENDENCY}_FLAG}_DYNAMIC=${${DEPENDENCY}_DYNAMIC})
94-
set(RUNTIME_DEPENDENCIES ON)
95-
else()
96-
message(STATUS " --> skipping.")
97-
endif()
98-
endforeach(DEPENDENCY)
70+
if(USE_PNG)
71+
find_package(libpng REQUIRED)
72+
add_definitions(-DLOAD_PNG)
73+
target_link_libraries(SDL2_image PRIVATE png)
74+
endif()
9975

100-
if(DEFINED RUNTIME_DEPENDENCIES)
101-
include_directories(VisualC/external/include)
76+
if(USE_JPEG)
77+
find_package(JPEG REQUIRED)
78+
add_definitions(-DLOAD_JPG)
79+
target_link_libraries(SDL2_image PRIVATE ${JPEG_LIBRARIES})
10280
endif()
10381

82+
if(USE_TIFF)
83+
find_package(TIFF REQUIRED)
84+
add_definitions(-DLOAD_TIF)
85+
target_link_libraries(SDL2_image PRIVATE TIFF::TIFF)
86+
87+
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
88+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996")
89+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996")
90+
endif()
91+
endif()
10492

10593
install(TARGETS SDL2_image
10694
EXPORT SDL2_image
@@ -110,11 +98,10 @@ install(TARGETS SDL2_image
11098

11199
install(FILES SDL_image.h DESTINATION include/SDL2 CONFIGURATIONS Release)
112100

113-
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/sdl2-image-config.cmake"
114-
[[include(CMakeFindDependencyMacro)
115-
find_dependency(SDL2 CONFIG)
116-
include("${CMAKE_CURRENT_LIST_DIR}/sdl2-image-targets.cmake")
117-
]])
101+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sdl2-image-config.cmake.in"
102+
"${CMAKE_CURRENT_BINARY_DIR}/sdl2-image-config.cmake" @ONLY
103+
INSTALL_DESTINATION "share/sdl2-image")
104+
118105
set(prefix "")
119106
set(exec_prefix [[${prefix}]])
120107
set(libdir [[${prefix}/lib]])
@@ -141,20 +128,3 @@ install(EXPORT SDL2_image
141128
FILE sdl2-image-targets.cmake
142129
NAMESPACE SDL2::
143130
)
144-
145-
message(STATUS "Link-time dependencies:")
146-
message(STATUS " " SDL2::SDL2)
147-
foreach(DEPENDENCY ${DEPENDENCIES})
148-
if(${DEPENDENCY}_FOUND)
149-
message(STATUS " " ${DEPENDENCY})
150-
endif()
151-
endforeach(DEPENDENCY)
152-
153-
if(DEFINED RUNTIME_DEPENDENCIES)
154-
message(STATUS "Run-time dependencies:")
155-
foreach(DEPENDENCY ${DEPENDENCIES})
156-
if(NOT ${DEPENDENCY}_FOUND AND DEFINED ${DEPENDENCY}_DYNAMIC)
157-
message(STATUS " " ${${DEPENDENCY}_DYNAMIC})
158-
endif()
159-
endforeach(DEPENDENCY)
160-
endif()

ports/sdl2-image/portfile.cmake

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,20 @@ vcpkg_extract_source_archive_ex(
1515
)
1616

1717
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
18+
file(COPY "${CMAKE_CURRENT_LIST_DIR}/sdl2-image-config.cmake.in" DESTINATION "${SOURCE_PATH}")
1819

19-
set(USE_JPEG OFF)
20-
if("libjpeg-turbo" IN_LIST FEATURES)
21-
set(USE_JPEG ON)
22-
endif()
23-
24-
set(USE_TIFF OFF)
25-
if("tiff" IN_LIST FEATURES)
26-
set(USE_TIFF ON)
27-
endif()
28-
29-
set(USE_WEBP OFF)
30-
if("libwebp" IN_LIST FEATURES)
31-
set(USE_WEBP ON)
32-
endif()
20+
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
21+
FEATURES
22+
libjpeg-turbo USE_JPEG
23+
tiff USE_TIFF
24+
libwebp USE_WEBP
25+
)
3326

3427
vcpkg_cmake_configure(
3528
SOURCE_PATH "${SOURCE_PATH}"
3629
OPTIONS
37-
"-DCURRENT_INSTALLED_DIR=${CURRENT_INSTALLED_DIR}"
3830
-DUSE_PNG=ON
39-
-DUSE_JPEG=${USE_JPEG}
40-
-DUSE_TIFF=${USE_TIFF}
41-
-DUSE_WEBP=${USE_WEBP}
31+
${FEATURE_OPTIONS}
4232
)
4333

4434
vcpkg_cmake_install()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include(CMakeFindDependencyMacro)
2+
find_dependency(SDL2 CONFIG)
3+
if(@USE_WEBP@)
4+
find_dependency(WebP CONFIG)
5+
endif()
6+
include("${CMAKE_CURRENT_LIST_DIR}/sdl2-image-targets.cmake")

ports/sdl2-image/vcpkg.json

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sdl2-image",
3-
"version-string": "2.0.5",
4-
"port-version": 4,
3+
"version": "2.0.5",
4+
"port-version": 5,
55
"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",
66
"homepage": "https://www.libsdl.org/projects/SDL_image",
77
"dependencies": [
@@ -20,18 +20,39 @@
2020
"libjpeg-turbo": {
2121
"description": "Support for JPEG image format",
2222
"dependencies": [
23-
"libjpeg-turbo"
23+
"libjpeg-turbo",
24+
{
25+
"name": "sdl2",
26+
"features": [
27+
"x11"
28+
],
29+
"platform": "!windows"
30+
}
2431
]
2532
},
2633
"libwebp": {
2734
"description": "Support for WEBP image format.",
2835
"dependencies": [
29-
"libwebp"
36+
"libwebp",
37+
{
38+
"name": "sdl2",
39+
"features": [
40+
"x11"
41+
],
42+
"platform": "!windows"
43+
}
3044
]
3145
},
3246
"tiff": {
3347
"description": "Support for TIFF image format",
3448
"dependencies": [
49+
{
50+
"name": "sdl2",
51+
"features": [
52+
"x11"
53+
],
54+
"platform": "!windows"
55+
},
3556
"tiff"
3657
]
3758
}

ports/sdl2/portfile.cmake

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
2626
)
2727

2828
if ("x11" IN_LIST FEATURES)
29-
if (VCPKG_TARGET_IS_WINDOWS)
30-
message(FATAL_ERROR "Feature x11 only support UNIX.")
31-
endif()
3229
message(WARNING "You will need to install Xorg dependencies to use feature x11:\nsudo apt install libx11-dev libxft-dev libxext-dev\n")
3330
endif()
3431

@@ -84,7 +81,6 @@ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_UWP AND NOT VCPKG_TARGET_IS_M
8481
endforeach()
8582
endif()
8683

87-
configure_file("${SOURCE_PATH}/LICENSE.txt" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" COPYONLY)
8884
vcpkg_copy_pdbs()
8985

9086
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")
10096
endif()
10197

10298
vcpkg_fixup_pkgconfig()
99+
100+
file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

ports/sdl2/vcpkg.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sdl2",
33
"version": "2.0.20",
4-
"port-version": 1,
4+
"port-version": 2,
55
"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.",
66
"homepage": "https://www.libsdl.org/download-2.0.php",
77
"dependencies": [
@@ -19,7 +19,8 @@
1919
"description": "Vulkan functionality for SDL"
2020
},
2121
"x11": {
22-
"description": "Dynamically load X11 support"
22+
"description": "Dynamically load X11 support",
23+
"supports": "!windows"
2324
}
2425
}
2526
}

versions/baseline.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6370,15 +6370,15 @@
63706370
},
63716371
"sdl2": {
63726372
"baseline": "2.0.20",
6373-
"port-version": 1
6373+
"port-version": 2
63746374
},
63756375
"sdl2-gfx": {
63766376
"baseline": "1.0.4",
63776377
"port-version": 8
63786378
},
63796379
"sdl2-image": {
63806380
"baseline": "2.0.5",
6381-
"port-version": 4
6381+
"port-version": 5
63826382
},
63836383
"sdl2-mixer": {
63846384
"baseline": "2.0.4",

versions/s-/sdl2-image.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"versions": [
3+
{
4+
"git-tree": "623548e8c929f2160320bf9644e2cd5a75d4a608",
5+
"version": "2.0.5",
6+
"port-version": 5
7+
},
38
{
49
"git-tree": "9042c449fc4c728c5b428332e09bc6d21a2acf34",
510
"version-string": "2.0.5",

versions/s-/sdl2.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
{
22
"versions": [
3+
{
4+
"git-tree": "abf71c19917402dddef261e80d55c8ec04e9bf54",
5+
"version": "2.0.20",
6+
"port-version": 2
7+
},
38
{
49
"git-tree": "9900463f2847ed86e25bac1688c527ae3486a024",
510
"version": "2.0.20",

0 commit comments

Comments
 (0)