Skip to content

Commit c804862

Browse files
Fixed android, windows, mingw, mysys, and osx
Unfortunately, this means that we need to disable gif2webp command line utility for these target platforms. We will revisit this patch once giflib becomes fully supported.
1 parent f9a91ae commit c804862

File tree

3 files changed

+33
-23
lines changed

3 files changed

+33
-23
lines changed

CMakeLists.txt

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ HunterGate(
88

99
project(libwebp C)
1010

11-
hunter_add_package(PNG)
12-
hunter_add_package(Jpeg)
13-
hunter_add_package(TIFF)
14-
hunter_add_package(giflib)
15-
1611
# Options for coder / decoder executables.
1712
option(WEBP_ENABLE_SIMD "Enable any SIMD optimization." ON)
1813
option(WEBP_BUILD_CWEBP "Build the cwebp command line tool." OFF)
@@ -54,7 +49,7 @@ if(ANDROID)
5449
add_library(cpufeatures STATIC
5550
${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c
5651
)
57-
target_link_libraries(cpufeatures dl)
52+
target_link_libraries(cpufeatures PUBLIC dl)
5853
set(WEBP_DEP_LIBRARIES ${WEBP_DEP_LIBRARIES} cpufeatures)
5954
set(WEBP_DEP_INCLUDE_DIRS ${WEBP_DEP_INCLUDE_DIRS}
6055
${ANDROID_NDK}/sources/android/cpufeatures
@@ -127,7 +122,7 @@ add_library(webputilsdecode OBJECT ${WEBP_UTILS_COMMON_SRCS}
127122
${WEBP_UTILS_DEC_SRCS})
128123
add_library(webpdecoder $<TARGET_OBJECTS:webpdecode>
129124
$<TARGET_OBJECTS:webpdspdecode> $<TARGET_OBJECTS:webputilsdecode>)
130-
target_link_libraries(webpdecoder ${WEBP_DEP_LIBRARIES})
125+
target_link_libraries(webpdecoder PUBLIC ${WEBP_DEP_LIBRARIES})
131126

132127
# Build the webp library.
133128
add_library(webpencode OBJECT ${WEBP_ENC_SRCS})
@@ -137,7 +132,7 @@ add_library(webputils OBJECT ${WEBP_UTILS_COMMON_SRCS} ${WEBP_UTILS_DEC_SRCS}
137132
${WEBP_UTILS_ENC_SRCS})
138133
add_library(webp $<TARGET_OBJECTS:webpdecode> $<TARGET_OBJECTS:webpdsp>
139134
$<TARGET_OBJECTS:webpencode> $<TARGET_OBJECTS:webputils>)
140-
target_link_libraries(webp ${WEBP_DEP_LIBRARIES})
135+
target_link_libraries(webp PUBLIC ${WEBP_DEP_LIBRARIES})
141136

142137
# Make sure the OBJECT libraries are built with position independent code
143138
# (it is not ON by default).
@@ -146,7 +141,7 @@ set_target_properties(webpdecode webpdspdecode webputilsdecode
146141

147142
# Build the webp demux library.
148143
add_library(webpdemux ${WEBP_DEMUX_SRCS})
149-
target_link_libraries(webpdemux webp)
144+
target_link_libraries(webpdemux PUBLIC webp)
150145

151146
# Set the version numbers.
152147
function(parse_version FILE NAME VAR)
@@ -198,19 +193,19 @@ if(WEBP_BUILD_CWEBP OR WEBP_BUILD_DWEBP OR
198193
parse_Makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/imageio "IMAGEIOUTILS_SRCS"
199194
"imageio_util_[^ ]*")
200195
add_library(imageioutil ${IMAGEIOUTILS_SRCS})
201-
target_link_libraries(imageioutil webp)
196+
target_link_libraries(imageioutil PUBLIC webp ${WEBP_DEP_IMG_LIBRARIES})
202197

203198
# Image-decoding utility library.
204199
parse_Makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/imageio "IMAGEDEC_SRCS"
205200
"imagedec_[^ ]*")
206201
add_library(imagedec ${IMAGEDEC_SRCS})
207-
target_link_libraries(imagedec imageioutil webp ${WEBP_DEP_IMG_LIBRARIES})
202+
target_link_libraries(imagedec PUBLIC imageioutil webp ${WEBP_DEP_IMG_LIBRARIES})
208203

209204
# Image-encoding utility library.
210205
parse_Makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/imageio "IMAGEENC_SRCS"
211206
"imageenc_[^ ]*")
212207
add_library(imageenc ${IMAGEENC_SRCS})
213-
target_link_libraries(imageenc webp)
208+
target_link_libraries(imageenc PUBLIC webp ${WEBP_DEP_IMG_LIBRARIES})
214209

215210
set_property(TARGET exampleutil imageioutil imagedec imageenc
216211
PROPERTY INCLUDE_DIRECTORIES
@@ -249,7 +244,7 @@ if(WEBP_BUILD_GIF2WEBP OR WEBP_BUILD_IMG2WEBP)
249244
parse_Makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/src/mux "WEBP_MUX_SRCS"
250245
"")
251246
add_library(webpmux ${WEBP_MUX_SRCS})
252-
target_link_libraries(webpmux webp)
247+
target_link_libraries(webpmux PUBLIC webp)
253248
parse_version(mux/Makefile.am webpmux WEBP_MUX_SOVERSION)
254249
set_target_properties(webpmux PROPERTIES VERSION ${PACKAGE_VERSION}
255250
SOVERSION ${WEBP_MUX_SOVERSION})

cmake/cpu.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ set(WEBP_SIMD_FILES_TO_INCLUDE)
4646
set(WEBP_SIMD_FLAGS_TO_INCLUDE)
4747

4848
if(${ANDROID})
49-
if(${ANDROID_ABI} STREQUAL "armeabi-v7a")
49+
if(${CMAKE_ANDROID_ARCH_ABI} STREQUAL "armeabi-v7a")
5050
# This is because Android studio uses the configuration
5151
# "-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16"
5252
# that does not trigger neon optimizations but should

cmake/deps.cmake

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,35 @@ if(MATH_LIBRARY)
6262
list(APPEND WEBP_DEP_LIBRARIES ${MATH_LIBRARY})
6363
endif()
6464

65+
hunter_add_package(PNG)
6566
find_package(PNG CONFIG REQUIRED)
66-
find_package(JPEG CONFIG REQUIRED)
67-
find_package(TIFF CONFIG REQUIRED)
68-
find_package(giflib CONFIG REQUIRED)
67+
list(APPEND WEBP_DEP_IMG_LIBRARIES PNG::png)
6968
set(WEBP_HAVE_PNG 1)
70-
set(WEBP_HAVE_JPEG 1)
71-
set(WEBP_HAVE_TIFF 1)
72-
set(WEBP_HAVE_GIF 1)
7369
set(PNG_FOUND 1)
70+
71+
hunter_add_package(Jpeg)
72+
find_package(JPEG CONFIG REQUIRED)
73+
list(APPEND WEBP_DEP_IMG_LIBRARIES JPEG::jpeg)
74+
set(WEBP_HAVE_JPEG 1)
7475
set(JPEG_FOUND 1)
76+
77+
hunter_add_package(TIFF)
78+
find_package(TIFF CONFIG REQUIRED)
79+
list(APPEND WEBP_DEP_IMG_LIBRARIES TIFF::libtiff)
80+
set(WEBP_HAVE_TIFF 1)
7581
set(TIFF_FOUND 1)
76-
set(GIF_FOUND 1)
77-
list(APPEND WEBP_DEP_IMG_LIBRARIES PNG::png JPEG::jpeg TIFF::libtiff)
78-
list(APPEND WEBP_DEP_GIF_LIBRARIES giflib::giflib)
82+
83+
if(ANDROID OR MINGW OR MSYS OR CYGWIN)
84+
# giflib is currently not supported by hunter on Android, MinGW and MSYS
85+
set(WEBP_HAVE_GIF 0)
86+
set(GIF_FOUND 0)
87+
else()
88+
hunter_add_package(giflib)
89+
find_package(giflib CONFIG REQUIRED)
90+
list(APPEND WEBP_DEP_GIF_LIBRARIES giflib::giflib)
91+
set(WEBP_HAVE_GIF 1)
92+
set(GIF_FOUND 1)
93+
endif()
7994

8095
## Check for specific headers.
8196
include(CheckIncludeFiles)

0 commit comments

Comments
 (0)