| 1 |
# Copyright (c) 2020 Google LLC. |
| 2 |
# |
| 3 |
# Use of this source code is governed by a BSD-style license |
| 4 |
# that can be found in the LICENSE file in the root of the source |
| 5 |
# tree. An additional intellectual property rights grant can be found |
| 6 |
# in the file PATENTS. All contributing project authors may |
| 7 |
# be found in the AUTHORS file in the root of the source tree. |
| 8 |
|
| 9 |
if(APPLE) |
| 10 |
cmake_minimum_required(VERSION 3.17) |
| 11 |
else() |
| 12 |
cmake_minimum_required(VERSION 3.7) |
| 13 |
endif() |
| 14 |
|
| 15 |
if(POLICY CMP0072) |
| 16 |
cmake_policy(SET CMP0072 NEW) |
| 17 |
endif() |
| 18 |
|
| 19 |
project(WebP C) |
| 20 |
|
| 21 |
# Options for coder / decoder executables. |
| 22 |
if(BUILD_SHARED_LIBS) |
| 23 |
set(WEBP_LINK_STATIC_DEFAULT OFF) |
| 24 |
else() |
| 25 |
set(WEBP_LINK_STATIC_DEFAULT ON) |
| 26 |
endif() |
| 27 |
option(WEBP_LINK_STATIC |
| 28 |
"Link using static libraries. If OFF, use dynamic libraries." |
| 29 |
${WEBP_LINK_STATIC_DEFAULT}) |
| 30 |
if(NOT EMSCRIPTEN) |
| 31 |
# Disable SIMD on Emscripten by default, as it's a new unstable Wasm feature. |
| 32 |
# Users can still explicitly opt-in to make a SIMD-enabled build. |
| 33 |
set(WEBP_ENABLE_SIMD_DEFAULT ON) |
| 34 |
endif() |
| 35 |
option(WEBP_ENABLE_SIMD "Enable any SIMD optimization." |
| 36 |
${WEBP_ENABLE_SIMD_DEFAULT}) |
| 37 |
option(WEBP_BUILD_ANIM_UTILS "Build animation utilities." ON) |
| 38 |
option(WEBP_BUILD_CWEBP "Build the cwebp command line tool." ON) |
| 39 |
option(WEBP_BUILD_DWEBP "Build the dwebp command line tool." ON) |
| 40 |
option(WEBP_BUILD_GIF2WEBP "Build the gif2webp conversion tool." ON) |
| 41 |
option(WEBP_BUILD_IMG2WEBP "Build the img2webp animation tool." ON) |
| 42 |
option(WEBP_BUILD_VWEBP "Build the vwebp viewer tool." ON) |
| 43 |
option(WEBP_BUILD_WEBPINFO "Build the webpinfo command line tool." ON) |
| 44 |
option(WEBP_BUILD_LIBWEBPMUX "Build the libwebpmux library." ON) |
| 45 |
option(WEBP_BUILD_WEBPMUX "Build the webpmux command line tool." ON) |
| 46 |
option(WEBP_BUILD_EXTRAS "Build extras." ON) |
| 47 |
option(WEBP_BUILD_WEBP_JS "Emscripten build of webp.js." OFF) |
| 48 |
option(WEBP_USE_THREAD "Enable threading support" ON) |
| 49 |
option(WEBP_NEAR_LOSSLESS "Enable near-lossless encoding" ON) |
| 50 |
option(WEBP_ENABLE_SWAP_16BIT_CSP "Enable byte swap for 16 bit colorspaces." |
| 51 |
OFF) |
| 52 |
set(WEBP_BITTRACE "0" CACHE STRING "Bit trace mode (0=none, 1=bit, 2=bytes)") |
| 53 |
set_property(CACHE WEBP_BITTRACE PROPERTY STRINGS 0 1 2) |
| 54 |
option(WEBP_ENABLE_WUNUSED_RESULT "Add [[nodiscard]] to some functions. \ |
| 55 |
CMake must be at least 3.21 to force C23" OFF) |
| 56 |
|
| 57 |
if(WEBP_LINK_STATIC) |
| 58 |
if(WIN32) |
| 59 |
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) |
| 60 |
else() |
| 61 |
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) |
| 62 |
endif() |
| 63 |
set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
| 64 |
# vwebp does not compile on Ubuntu with static libraries so disabling it for |
| 65 |
# now. |
| 66 |
set(WEBP_BUILD_VWEBP OFF) |
| 67 |
endif() |
| 68 |
|
| 69 |
# Option needed for handling Unicode file names on Windows. |
| 70 |
if(WIN32) |
| 71 |
option(WEBP_UNICODE "Build Unicode executables." ON) |
| 72 |
endif() |
| 73 |
|
| 74 |
if(WEBP_BUILD_WEBP_JS) |
| 75 |
set(WEBP_BUILD_ANIM_UTILS OFF) |
| 76 |
set(WEBP_BUILD_CWEBP OFF) |
| 77 |
set(WEBP_BUILD_DWEBP OFF) |
| 78 |
set(WEBP_BUILD_GIF2WEBP OFF) |
| 79 |
set(WEBP_BUILD_IMG2WEBP OFF) |
| 80 |
set(WEBP_BUILD_VWEBP OFF) |
| 81 |
set(WEBP_BUILD_WEBPINFO OFF) |
| 82 |
set(WEBP_BUILD_WEBPMUX OFF) |
| 83 |
set(WEBP_BUILD_EXTRAS OFF) |
| 84 |
set(WEBP_USE_THREAD OFF) |
| 85 |
|
| 86 |
if(WEBP_ENABLE_SIMD) |
| 87 |
message(NOTICE |
| 88 |
"wasm2js does not support SIMD, disabling webp.js generation.") |
| 89 |
endif() |
| 90 |
endif() |
| 91 |
|
| 92 |
set(SHARPYUV_DEP_LIBRARIES) |
| 93 |
set(SHARPYUV_DEP_INCLUDE_DIRS) |
| 94 |
set(WEBP_DEP_LIBRARIES) |
| 95 |
set(WEBP_DEP_INCLUDE_DIRS) |
| 96 |
|
| 97 |
if(NOT CMAKE_BUILD_TYPE) |
| 98 |
set(CMAKE_BUILD_TYPE "Release" |
| 99 |
CACHE STRING "Build type: Release, Debug, MinSizeRel or RelWithDebInfo" |
| 100 |
FORCE) |
| 101 |
endif() |
| 102 |
|
| 103 |
# Include dependencies. |
| 104 |
if(WEBP_BUILD_ANIM_UTILS |
| 105 |
OR WEBP_BUILD_CWEBP |
| 106 |
OR WEBP_BUILD_DWEBP |
| 107 |
OR WEBP_BUILD_EXTRAS |
| 108 |
OR WEBP_BUILD_GIF2WEBP |
| 109 |
OR WEBP_BUILD_IMG2WEBP) |
| 110 |
set(WEBP_FIND_IMG_LIBS TRUE) |
| 111 |
else() |
| 112 |
set(WEBP_FIND_IMG_LIBS FALSE) |
| 113 |
endif() |
| 114 |
include(cmake/deps.cmake) |
| 115 |
include(GNUInstallDirs) |
| 116 |
|
| 117 |
if(BUILD_SHARED_LIBS AND NOT DEFINED CMAKE_INSTALL_RPATH) |
| 118 |
# Set the rpath to match autoconf/libtool behavior. Note this must be set |
| 119 |
# before target creation. |
| 120 |
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") |
| 121 |
endif() |
| 122 |
|
| 123 |
# ############################################################################## |
| 124 |
# Options. |
| 125 |
if(WEBP_ENABLE_SWAP_16BIT_CSP) |
| 126 |
add_definitions(-DWEBP_SWAP_16BIT_CSP=1) |
| 127 |
endif() |
| 128 |
|
| 129 |
if(NOT WEBP_BITTRACE STREQUAL "0") |
| 130 |
add_definitions(-DBITTRACE=${WEBP_BITTRACE}) |
| 131 |
endif() |
| 132 |
|
| 133 |
if(WEBP_UNICODE) |
| 134 |
# Windows recommends setting both UNICODE and _UNICODE. |
| 135 |
add_definitions(-DUNICODE -D_UNICODE) |
| 136 |
endif() |
| 137 |
|
| 138 |
if(WIN32 AND BUILD_SHARED_LIBS) |
| 139 |
add_definitions(-DWEBP_DLL) |
| 140 |
endif() |
| 141 |
|
| 142 |
# pkg-config variables used by *.pc.in. |
| 143 |
set(prefix ${CMAKE_INSTALL_PREFIX}) |
| 144 |
set(exec_prefix "\${prefix}") |
| 145 |
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}") |
| 146 |
set(libdir "${CMAKE_INSTALL_LIBDIR}") |
| 147 |
else() |
| 148 |
set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") |
| 149 |
endif() |
| 150 |
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") |
| 151 |
set(includedir "${CMAKE_INSTALL_INCLUDEDIR}") |
| 152 |
else() |
| 153 |
set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}") |
| 154 |
endif() |
| 155 |
set(PTHREAD_LIBS ${CMAKE_THREAD_LIBS_INIT}) |
| 156 |
set(INSTALLED_LIBRARIES) |
| 157 |
|
| 158 |
if(MSVC) |
| 159 |
# match the naming convention used by nmake |
| 160 |
set(webp_libname_prefix "lib") |
| 161 |
set(CMAKE_SHARED_LIBRARY_PREFIX "${webp_libname_prefix}") |
| 162 |
set(CMAKE_IMPORT_LIBRARY_PREFIX "${webp_libname_prefix}") |
| 163 |
set(CMAKE_STATIC_LIBRARY_PREFIX "${webp_libname_prefix}") |
| 164 |
endif() |
| 165 |
|
| 166 |
if(NOT WIN32) |
| 167 |
set(CMAKE_C_VISIBILITY_PRESET hidden) |
| 168 |
endif() |
| 169 |
|
| 170 |
if(WEBP_ENABLE_WUNUSED_RESULT) |
| 171 |
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21.0) |
| 172 |
set(CMAKE_C_STANDARD 23) |
| 173 |
else() |
| 174 |
unset(CMAKE_C_STANDARD) |
| 175 |
add_compile_options($<$<COMPILE_LANGUAGE:C>:-std=gnu2x>) |
| 176 |
endif() |
| 177 |
add_compile_options(-Wunused-result) |
| 178 |
add_definitions(-DWEBP_ENABLE_NODISCARD=1) |
| 179 |
endif() |
| 180 |
|
| 181 |
# ############################################################################## |
| 182 |
# Android only. |
| 183 |
if(ANDROID) |
| 184 |
include_directories(${ANDROID_NDK}/sources/android/cpufeatures) |
| 185 |
add_library(cpufeatures-webp STATIC |
| 186 |
${ANDROID_NDK}/sources/android/cpufeatures/cpu-features.c) |
| 187 |
list(APPEND INSTALLED_LIBRARIES cpufeatures-webp) |
| 188 |
target_link_libraries(cpufeatures-webp dl) |
| 189 |
set(SHARPYUV_DEP_LIBRARIES ${SHARPYUV_DEP_LIBRARIES} cpufeatures-webp) |
| 190 |
set(WEBP_DEP_LIBRARIES ${WEBP_DEP_LIBRARIES} cpufeatures-webp) |
| 191 |
set(cpufeatures_include_dir ${ANDROID_NDK}/sources/android/cpufeatures) |
| 192 |
set(SHARPYUV_DEP_INCLUDE_DIRS ${SHARPYUV_DEP_INCLUDE_DIRS} |
| 193 |
${cpufeatures_include_dir}) |
| 194 |
set(WEBP_DEP_INCLUDE_DIRS ${WEBP_DEP_INCLUDE_DIRS} ${cpufeatures_include_dir}) |
| 195 |
add_definitions(-DHAVE_CPU_FEATURES_H=1) |
| 196 |
set(HAVE_CPU_FEATURES_H 1) |
| 197 |
else() |
| 198 |
set(HAVE_CPU_FEATURES_H 0) |
| 199 |
endif() |
| 200 |
|
| 201 |
function(configure_pkg_config FILE) |
| 202 |
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.in" |
| 203 |
"${CMAKE_CURRENT_BINARY_DIR}/${FILE}" @ONLY) |
| 204 |
|
| 205 |
if(HAVE_MATH_LIBRARY) |
| 206 |
# MSVC doesn't have libm |
| 207 |
file(READ ${CMAKE_CURRENT_BINARY_DIR}/${FILE} data) |
| 208 |
string(REPLACE "-lm" "" data ${data}) |
| 209 |
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${FILE} ${data}) |
| 210 |
endif() |
| 211 |
|
| 212 |
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${FILE}" |
| 213 |
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) |
| 214 |
endfunction() |
| 215 |
|
| 216 |
# ############################################################################## |
| 217 |
# WebP source files. Read the Makefile.am to get the source files. |
| 218 |
|
| 219 |
# We expect the Makefiles to define the sources as defined in the first regex. |
| 220 |
# E.g.: libimagedec_la_SOURCES = image_dec.c image_dec.h |
| 221 |
function(parse_Makefile_am FOLDER VAR SRC_REGEX) |
| 222 |
file(READ ${FOLDER}/Makefile.am MAKEFILE_AM) |
| 223 |
string(REGEX MATCHALL "${SRC_REGEX}_SOURCES[ ]*\\+?=[ ]+[0-9a-z\\._ ]*" |
| 224 |
FILES_PER_LINE ${MAKEFILE_AM}) |
| 225 |
set(SRCS ${${VAR}}) |
| 226 |
foreach(FILES ${FILES_PER_LINE}) |
| 227 |
string(FIND ${FILES} "=" OFFSET) |
| 228 |
math(EXPR OFFSET "${OFFSET} + 2") |
| 229 |
string(SUBSTRING ${FILES} ${OFFSET} -1 FILES) |
| 230 |
if(FILES) |
| 231 |
string(REGEX MATCHALL "[0-9a-z\\._]+" FILES ${FILES}) |
| 232 |
foreach(FILE ${FILES}) |
| 233 |
list(APPEND SRCS ${FOLDER}/${FILE}) |
| 234 |
endforeach() |
| 235 |
endif() |
| 236 |
endforeach() |
| 237 |
set(${VAR} ${SRCS} PARENT_SCOPE) |
| 238 |
endfunction() |
| 239 |
|
| 240 |
set(WEBP_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) |
| 241 |
parse_makefile_am(${WEBP_SRC_DIR}/dec "WEBP_DEC_SRCS" "") |
| 242 |
parse_makefile_am(${WEBP_SRC_DIR}/demux "WEBP_DEMUX_SRCS" "") |
| 243 |
parse_makefile_am(${WEBP_SRC_DIR}/dsp "WEBP_DSP_COMMON_SRCS" "COMMON") |
| 244 |
parse_makefile_am(${WEBP_SRC_DIR}/dsp "WEBP_DSP_ENC_SRCS" "ENC") |
| 245 |
parse_makefile_am(${WEBP_SRC_DIR}/dsp "WEBP_DSP_ENC_SRCS" "dsp_[^ ]*") |
| 246 |
parse_makefile_am(${WEBP_SRC_DIR}/dsp "WEBP_DSP_DEC_SRCS" "decode_[^ ]*") |
| 247 |
parse_makefile_am(${WEBP_SRC_DIR}/enc "WEBP_ENC_SRCS" "") |
| 248 |
parse_makefile_am(${WEBP_SRC_DIR}/utils "WEBP_UTILS_COMMON_SRCS" "COMMON") |
| 249 |
parse_makefile_am(${WEBP_SRC_DIR}/utils "WEBP_UTILS_ENC_SRCS" "ENC") |
| 250 |
parse_makefile_am(${WEBP_SRC_DIR}/utils "WEBP_UTILS_DEC_SRCS" "decode_[^ ]*") |
| 251 |
|
| 252 |
# Remove the files specific to SIMD we don't use. |
| 253 |
foreach(FILE ${WEBP_SIMD_FILES_NOT_TO_INCLUDE}) |
| 254 |
list(REMOVE_ITEM WEBP_DSP_ENC_SRCS ${FILE}) |
| 255 |
list(REMOVE_ITEM WEBP_DSP_DEC_SRCS ${FILE}) |
| 256 |
endforeach() |
| 257 |
|
| 258 |
# Generate the config.h file. |
| 259 |
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/config.h.in |
| 260 |
${CMAKE_CURRENT_BINARY_DIR}/src/webp/config.h @ONLY) |
| 261 |
add_definitions(-DHAVE_CONFIG_H) |
| 262 |
|
| 263 |
# Set the version numbers. |
| 264 |
macro(set_version FILE TARGET_NAME NAME_IN_MAKEFILE) |
| 265 |
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/${FILE} SOURCE_FILE) |
| 266 |
string(REGEX MATCH |
| 267 |
"${NAME_IN_MAKEFILE}_la_LDFLAGS[^\n]* -version-info [0-9:]+" TMP |
| 268 |
${SOURCE_FILE}) |
| 269 |
string(REGEX MATCH "[0-9:]+" TMP ${TMP}) |
| 270 |
string(REGEX REPLACE ":" " " LT_VERSION ${TMP}) |
| 271 |
|
| 272 |
# See the libtool docs for more information: |
| 273 |
# https://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info |
| 274 |
# |
| 275 |
# c=<current>, a=<age>, r=<revision> |
| 276 |
# |
| 277 |
# libtool generates a .so file as .so.[c-a].a.r, while -version-info c:r:a is |
| 278 |
# passed to libtool. |
| 279 |
# |
| 280 |
# We set FULL = [c-a].a.r and MAJOR = [c-a]. |
| 281 |
separate_arguments(LT_VERSION) |
| 282 |
list(GET LT_VERSION 0 LT_CURRENT) |
| 283 |
list(GET LT_VERSION 1 LT_REVISION) |
| 284 |
list(GET LT_VERSION 2 LT_AGE) |
| 285 |
math(EXPR LT_CURRENT_MINUS_AGE "${LT_CURRENT} - ${LT_AGE}") |
| 286 |
|
| 287 |
set_target_properties( |
| 288 |
${TARGET_NAME} |
| 289 |
PROPERTIES VERSION ${LT_CURRENT_MINUS_AGE}.${LT_AGE}.${LT_REVISION} |
| 290 |
SOVERSION ${LT_CURRENT_MINUS_AGE}) |
| 291 |
if(APPLE) |
| 292 |
# For compatibility, set MACHO_COMPATIBILITY_VERSION and |
| 293 |
# MACHO_CURRENT_VERSION to match libtool. These properties were introduced |
| 294 |
# in 3.17: |
| 295 |
# https://cmake.org/cmake/help/latest/prop_tgt/MACHO_COMPATIBILITY_VERSION.html |
| 296 |
math(EXPR LIBWEBP_MACHO_COMPATIBILITY_VERSION "${LT_CURRENT} + 1") |
| 297 |
set_target_properties( |
| 298 |
${TARGET_NAME} |
| 299 |
PROPERTIES MACHO_COMPATIBILITY_VERSION |
| 300 |
${LIBWEBP_MACHO_COMPATIBILITY_VERSION} |
| 301 |
MACHO_CURRENT_VERSION |
| 302 |
${LIBWEBP_MACHO_COMPATIBILITY_VERSION}.${LT_REVISION}) |
| 303 |
endif() |
| 304 |
endmacro() |
| 305 |
|
| 306 |
# ############################################################################## |
| 307 |
# Build the webpdecoder library. |
| 308 |
|
| 309 |
# Creates a source file with an unused stub function in $CMAKE_BINARY_DIR and |
| 310 |
# adds it to the specified target. Currently used only with Xcode. |
| 311 |
# |
| 312 |
# See also: |
| 313 |
# https://cmake.org/cmake/help/v3.18/command/add_library.html#object-libraries |
| 314 |
# "Some native build systems (such as Xcode) may not like targets that have only |
| 315 |
# object files, so consider adding at least one real source file to any target |
| 316 |
# that references $<TARGET_OBJECTS:objlib>." |
| 317 |
function(libwebp_add_stub_file TARGET) |
| 318 |
set(stub_source_dir "${CMAKE_BINARY_DIR}") |
| 319 |
set(stub_source_file "${stub_source_dir}/libwebp_${TARGET}_stub.c") |
| 320 |
set(stub_source_code |
| 321 |
"// Generated file. DO NOT EDIT!\n" |
| 322 |
"// C source file created for target ${TARGET}.\n" |
| 323 |
"void libwebp_${TARGET}_stub_function(void)\;\n" |
| 324 |
"void libwebp_${TARGET}_stub_function(void) {}\n") |
| 325 |
file(WRITE "${stub_source_file}" ${stub_source_code}) |
| 326 |
|
| 327 |
target_sources(${TARGET} PRIVATE ${stub_source_file}) |
| 328 |
endfunction() |
| 329 |
|
| 330 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/sharpyuv "WEBP_SHARPYUV_SRCS" "") |
| 331 |
add_library(sharpyuv ${WEBP_SHARPYUV_SRCS}) |
| 332 |
target_link_libraries(sharpyuv ${SHARPYUV_DEP_LIBRARIES}) |
| 333 |
set_version(sharpyuv/Makefile.am sharpyuv sharpyuv) |
| 334 |
target_include_directories( |
| 335 |
sharpyuv PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} |
| 336 |
${CMAKE_CURRENT_SOURCE_DIR}/src) |
| 337 |
set_target_properties( |
| 338 |
sharpyuv |
| 339 |
PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/sharpyuv/sharpyuv.h;\ |
| 340 |
${CMAKE_CURRENT_SOURCE_DIR}/sharpyuv/sharpyuv_csp.h") |
| 341 |
configure_pkg_config("sharpyuv/libsharpyuv.pc") |
| 342 |
install( |
| 343 |
TARGETS sharpyuv |
| 344 |
EXPORT ${PROJECT_NAME}Targets |
| 345 |
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webp/sharpyuv |
| 346 |
INCLUDES |
| 347 |
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} |
| 348 |
${CMAKE_INSTALL_INCLUDEDIR}/webp |
| 349 |
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 350 |
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 351 |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 352 |
|
| 353 |
if(MSVC) |
| 354 |
# avoid security warnings for e.g., fopen() used in the examples. |
| 355 |
add_definitions(-D_CRT_SECURE_NO_WARNINGS) |
| 356 |
else() |
| 357 |
add_compile_options(-Wall) |
| 358 |
endif() |
| 359 |
include_directories(${WEBP_DEP_INCLUDE_DIRS}) |
| 360 |
add_library(webpdecode OBJECT ${WEBP_DEC_SRCS}) |
| 361 |
target_include_directories(webpdecode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} |
| 362 |
${CMAKE_CURRENT_SOURCE_DIR}) |
| 363 |
add_library(webpdspdecode OBJECT ${WEBP_DSP_COMMON_SRCS} ${WEBP_DSP_DEC_SRCS}) |
| 364 |
target_include_directories(webpdspdecode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} |
| 365 |
${CMAKE_CURRENT_SOURCE_DIR}) |
| 366 |
add_library(webputilsdecode OBJECT ${WEBP_UTILS_COMMON_SRCS} |
| 367 |
${WEBP_UTILS_DEC_SRCS}) |
| 368 |
target_include_directories(webputilsdecode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} |
| 369 |
${CMAKE_CURRENT_SOURCE_DIR}) |
| 370 |
add_library( |
| 371 |
webpdecoder $<TARGET_OBJECTS:webpdecode> $<TARGET_OBJECTS:webpdspdecode> |
| 372 |
$<TARGET_OBJECTS:webputilsdecode>) |
| 373 |
if(XCODE) |
| 374 |
libwebp_add_stub_file(webpdecoder) |
| 375 |
endif() |
| 376 |
target_link_libraries(webpdecoder ${WEBP_DEP_LIBRARIES}) |
| 377 |
target_include_directories( |
| 378 |
webpdecoder PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} |
| 379 |
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> |
| 380 |
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) |
| 381 |
set_target_properties( |
| 382 |
webpdecoder |
| 383 |
PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\ |
| 384 |
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h") |
| 385 |
|
| 386 |
configure_pkg_config("src/libwebpdecoder.pc") |
| 387 |
|
| 388 |
# Build the webp library. |
| 389 |
add_library(webpencode OBJECT ${WEBP_ENC_SRCS}) |
| 390 |
target_include_directories( |
| 391 |
webpencode PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} |
| 392 |
${CMAKE_CURRENT_SOURCE_DIR}/src) |
| 393 |
add_library(webpdsp OBJECT ${WEBP_DSP_COMMON_SRCS} ${WEBP_DSP_DEC_SRCS} |
| 394 |
${WEBP_DSP_ENC_SRCS}) |
| 395 |
target_include_directories(webpdsp PRIVATE ${CMAKE_CURRENT_BINARY_DIR} |
| 396 |
${CMAKE_CURRENT_SOURCE_DIR}) |
| 397 |
add_library(webputils OBJECT ${WEBP_UTILS_COMMON_SRCS} ${WEBP_UTILS_DEC_SRCS} |
| 398 |
${WEBP_UTILS_ENC_SRCS}) |
| 399 |
target_include_directories(webputils PRIVATE ${CMAKE_CURRENT_BINARY_DIR} |
| 400 |
${CMAKE_CURRENT_SOURCE_DIR}) |
| 401 |
add_library(webp $<TARGET_OBJECTS:webpdecode> $<TARGET_OBJECTS:webpdsp> |
| 402 |
$<TARGET_OBJECTS:webpencode> $<TARGET_OBJECTS:webputils>) |
| 403 |
target_link_libraries(webp sharpyuv) |
| 404 |
if(XCODE) |
| 405 |
libwebp_add_stub_file(webp) |
| 406 |
endif() |
| 407 |
target_link_libraries(webp ${WEBP_DEP_LIBRARIES}) |
| 408 |
target_include_directories( |
| 409 |
webp PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} |
| 410 |
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src> |
| 411 |
$<INSTALL_INTERFACE:include>) |
| 412 |
set_target_properties( |
| 413 |
webp |
| 414 |
PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\ |
| 415 |
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/encode.h;\ |
| 416 |
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h") |
| 417 |
|
| 418 |
# Make sure the OBJECT libraries are built with position independent code (it is |
| 419 |
# not ON by default). |
| 420 |
set_target_properties(webpdecode webpdspdecode webputilsdecode webpencode |
| 421 |
webpdsp webputils PROPERTIES POSITION_INDEPENDENT_CODE ON) |
| 422 |
configure_pkg_config("src/libwebp.pc") |
| 423 |
|
| 424 |
# Build the webp demux library. |
| 425 |
add_library(webpdemux ${WEBP_DEMUX_SRCS}) |
| 426 |
target_link_libraries(webpdemux webp) |
| 427 |
target_include_directories( |
| 428 |
webpdemux PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} |
| 429 |
PUBLIC $<INSTALL_INTERFACE:include>) |
| 430 |
set_target_properties( |
| 431 |
webpdemux |
| 432 |
PROPERTIES |
| 433 |
PUBLIC_HEADER |
| 434 |
"${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\ |
| 435 |
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/demux.h;\ |
| 436 |
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h;\ |
| 437 |
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h") |
| 438 |
|
| 439 |
configure_pkg_config("src/demux/libwebpdemux.pc") |
| 440 |
|
| 441 |
set_version(src/Makefile.am webp webp) |
| 442 |
set_version(src/Makefile.am webpdecoder webpdecoder) |
| 443 |
set_version(src/demux/Makefile.am webpdemux webpdemux) |
| 444 |
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/configure.ac CONFIGURE_FILE) |
| 445 |
string(REGEX MATCH "AC_INIT\\([^\n]*\\[[0-9\\.]+\\]" TMP ${CONFIGURE_FILE}) |
| 446 |
string(REGEX MATCH "[0-9\\.]+" PROJECT_VERSION ${TMP}) |
| 447 |
|
| 448 |
# Define the libraries to install. |
| 449 |
list(APPEND INSTALLED_LIBRARIES webpdecoder webp webpdemux) |
| 450 |
|
| 451 |
# Deal with SIMD. Change the compile flags for SIMD files we use. |
| 452 |
list(LENGTH WEBP_SIMD_FILES_TO_INCLUDE WEBP_SIMD_FILES_TO_INCLUDE_LENGTH) |
| 453 |
math(EXPR WEBP_SIMD_FILES_TO_INCLUDE_RANGE |
| 454 |
"${WEBP_SIMD_FILES_TO_INCLUDE_LENGTH}-1") |
| 455 |
|
| 456 |
foreach(I_FILE RANGE ${WEBP_SIMD_FILES_TO_INCLUDE_RANGE}) |
| 457 |
list(GET WEBP_SIMD_FILES_TO_INCLUDE ${I_FILE} FILE) |
| 458 |
list(GET WEBP_SIMD_FLAGS_TO_INCLUDE ${I_FILE} SIMD_COMPILE_FLAG) |
| 459 |
set_source_files_properties(${FILE} PROPERTIES COMPILE_FLAGS |
| 460 |
${SIMD_COMPILE_FLAG}) |
| 461 |
endforeach() |
| 462 |
|
| 463 |
if(NOT WEBP_BUILD_LIBWEBPMUX) |
| 464 |
set(WEBP_BUILD_GIF2WEBP OFF) |
| 465 |
set(WEBP_BUILD_IMG2WEBP OFF) |
| 466 |
set(WEBP_BUILD_WEBPMUX OFF) |
| 467 |
endif() |
| 468 |
|
| 469 |
if(WEBP_BUILD_GIF2WEBP AND NOT GIF_FOUND) |
| 470 |
set(WEBP_BUILD_GIF2WEBP OFF) |
| 471 |
endif() |
| 472 |
|
| 473 |
if(WEBP_BUILD_ANIM_UTILS AND NOT GIF_FOUND) |
| 474 |
set(WEBP_BUILD_ANIM_UTILS OFF) |
| 475 |
endif() |
| 476 |
|
| 477 |
# Build the executables if asked for. |
| 478 |
if(WEBP_BUILD_ANIM_UTILS |
| 479 |
OR WEBP_BUILD_CWEBP |
| 480 |
OR WEBP_BUILD_DWEBP |
| 481 |
OR WEBP_BUILD_EXTRAS |
| 482 |
OR WEBP_BUILD_GIF2WEBP |
| 483 |
OR WEBP_BUILD_IMG2WEBP |
| 484 |
OR WEBP_BUILD_VWEBP |
| 485 |
OR WEBP_BUILD_WEBPMUX |
| 486 |
OR WEBP_BUILD_WEBPINFO) |
| 487 |
# Example utility library. |
| 488 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "EXAMPLEUTIL_SRCS" |
| 489 |
"example_util_[^ ]*") |
| 490 |
list(APPEND EXAMPLEUTIL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/examples/stopwatch.h) |
| 491 |
add_library(exampleutil STATIC ${EXAMPLEUTIL_SRCS}) |
| 492 |
target_include_directories( |
| 493 |
exampleutil PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>) |
| 494 |
|
| 495 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/imageio "IMAGEIOUTILS_SRCS" |
| 496 |
"imageio_util_[^ ]*") |
| 497 |
add_library(imageioutil STATIC ${IMAGEIOUTILS_SRCS}) |
| 498 |
target_link_libraries(imageioutil webp) |
| 499 |
target_link_libraries(exampleutil imageioutil) |
| 500 |
|
| 501 |
# Image-decoding utility library. |
| 502 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/imageio "IMAGEDEC_SRCS" |
| 503 |
"imagedec_[^ ]*") |
| 504 |
add_library(imagedec STATIC ${IMAGEDEC_SRCS}) |
| 505 |
target_link_libraries(imagedec imageioutil webpdemux webp |
| 506 |
${WEBP_DEP_IMG_LIBRARIES}) |
| 507 |
|
| 508 |
# Image-encoding utility library. |
| 509 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/imageio "IMAGEENC_SRCS" |
| 510 |
"imageenc_[^ ]*") |
| 511 |
add_library(imageenc STATIC ${IMAGEENC_SRCS}) |
| 512 |
target_link_libraries(imageenc imageioutil webp) |
| 513 |
|
| 514 |
set_property( |
| 515 |
TARGET exampleutil imageioutil imagedec imageenc |
| 516 |
PROPERTY INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src |
| 517 |
${CMAKE_CURRENT_BINARY_DIR}/src) |
| 518 |
target_include_directories(imagedec PRIVATE ${WEBP_DEP_IMG_INCLUDE_DIRS}) |
| 519 |
target_include_directories(imageenc PRIVATE ${WEBP_DEP_IMG_INCLUDE_DIRS}) |
| 520 |
endif() |
| 521 |
|
| 522 |
if(WEBP_BUILD_DWEBP) |
| 523 |
# dwebp |
| 524 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "DWEBP_SRCS" "dwebp") |
| 525 |
add_executable(dwebp ${DWEBP_SRCS}) |
| 526 |
target_link_libraries(dwebp exampleutil imagedec imageenc) |
| 527 |
target_include_directories(dwebp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src) |
| 528 |
install(TARGETS dwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 529 |
endif() |
| 530 |
|
| 531 |
if(WEBP_BUILD_CWEBP) |
| 532 |
# cwebp |
| 533 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "CWEBP_SRCS" "cwebp") |
| 534 |
add_executable(cwebp ${CWEBP_SRCS}) |
| 535 |
target_link_libraries(cwebp exampleutil imagedec webp) |
| 536 |
target_include_directories(cwebp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src |
| 537 |
${CMAKE_CURRENT_SOURCE_DIR}) |
| 538 |
install(TARGETS cwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 539 |
endif() |
| 540 |
|
| 541 |
if(WEBP_BUILD_LIBWEBPMUX) |
| 542 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/src/mux "WEBP_MUX_SRCS" "") |
| 543 |
add_library(libwebpmux ${WEBP_MUX_SRCS}) |
| 544 |
target_link_libraries(libwebpmux webp) |
| 545 |
target_include_directories(libwebpmux PRIVATE ${CMAKE_CURRENT_BINARY_DIR} |
| 546 |
${CMAKE_CURRENT_SOURCE_DIR}) |
| 547 |
set_version(src/mux/Makefile.am libwebpmux webpmux) |
| 548 |
set_target_properties( |
| 549 |
libwebpmux |
| 550 |
PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux.h;\ |
| 551 |
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h;\ |
| 552 |
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h;") |
| 553 |
set_target_properties(libwebpmux PROPERTIES OUTPUT_NAME webpmux) |
| 554 |
list(APPEND INSTALLED_LIBRARIES libwebpmux) |
| 555 |
configure_pkg_config("src/mux/libwebpmux.pc") |
| 556 |
endif() |
| 557 |
|
| 558 |
if(WEBP_BUILD_GIF2WEBP) |
| 559 |
# gif2webp |
| 560 |
include_directories(${WEBP_DEP_GIF_INCLUDE_DIRS}) |
| 561 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "GIF2WEBP_SRCS" |
| 562 |
"gif2webp") |
| 563 |
add_executable(gif2webp ${GIF2WEBP_SRCS}) |
| 564 |
target_link_libraries(gif2webp exampleutil imageioutil webp libwebpmux |
| 565 |
${WEBP_DEP_GIF_LIBRARIES}) |
| 566 |
target_include_directories(gif2webp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src) |
| 567 |
install(TARGETS gif2webp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 568 |
endif() |
| 569 |
|
| 570 |
if(WEBP_BUILD_IMG2WEBP) |
| 571 |
# img2webp |
| 572 |
include_directories(${WEBP_DEP_IMG_INCLUDE_DIRS}) |
| 573 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "IMG2WEBP_SRCS" |
| 574 |
"img2webp") |
| 575 |
add_executable(img2webp ${IMG2WEBP_SRCS}) |
| 576 |
target_link_libraries(img2webp exampleutil imagedec imageioutil webp |
| 577 |
libwebpmux) |
| 578 |
target_include_directories(img2webp PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src |
| 579 |
${CMAKE_CURRENT_SOURCE_DIR}) |
| 580 |
install(TARGETS img2webp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 581 |
endif() |
| 582 |
|
| 583 |
if(WEBP_BUILD_VWEBP) |
| 584 |
# vwebp |
| 585 |
find_package(GLUT) |
| 586 |
if(GLUT_FOUND) |
| 587 |
include_directories(${WEBP_DEP_IMG_INCLUDE_DIRS}) |
| 588 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "VWEBP_SRCS" "vwebp") |
| 589 |
add_executable(vwebp ${VWEBP_SRCS}) |
| 590 |
target_link_libraries( |
| 591 |
vwebp |
| 592 |
${OPENGL_LIBRARIES} |
| 593 |
exampleutil |
| 594 |
GLUT::GLUT |
| 595 |
imageioutil |
| 596 |
webp |
| 597 |
webpdemux) |
| 598 |
target_include_directories( |
| 599 |
vwebp PRIVATE ${GLUT_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/src |
| 600 |
${OPENGL_INCLUDE_DIR}) |
| 601 |
install(TARGETS vwebp RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 602 |
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") |
| 603 |
check_c_compiler_flag("-Wno-deprecated-declarations" HAS_NO_DEPRECATED) |
| 604 |
if(HAS_NO_DEPRECATED) |
| 605 |
target_compile_options(vwebp PRIVATE "-Wno-deprecated-declarations") |
| 606 |
endif() |
| 607 |
endif() |
| 608 |
endif() |
| 609 |
endif() |
| 610 |
|
| 611 |
if(WEBP_BUILD_WEBPINFO) |
| 612 |
# webpinfo |
| 613 |
include_directories(${WEBP_DEP_IMG_INCLUDE_DIRS}) |
| 614 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "WEBPINFO_SRCS" |
| 615 |
"webpinfo") |
| 616 |
add_executable(webpinfo ${WEBPINFO_SRCS}) |
| 617 |
target_link_libraries(webpinfo exampleutil imageioutil) |
| 618 |
target_include_directories(webpinfo PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src |
| 619 |
${CMAKE_CURRENT_SOURCE_DIR}/src) |
| 620 |
install(TARGETS webpinfo RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 621 |
endif() |
| 622 |
|
| 623 |
if(WEBP_BUILD_WEBPMUX) |
| 624 |
# webpmux |
| 625 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "WEBPMUX_SRCS" |
| 626 |
"webpmux") |
| 627 |
add_executable(webpmux ${WEBPMUX_SRCS}) |
| 628 |
target_link_libraries(webpmux exampleutil imageioutil libwebpmux webp) |
| 629 |
target_include_directories(webpmux PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src) |
| 630 |
install(TARGETS webpmux RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 631 |
endif() |
| 632 |
|
| 633 |
if(WEBP_BUILD_EXTRAS) |
| 634 |
set(EXTRAS_MAKEFILE "${CMAKE_CURRENT_SOURCE_DIR}/extras") |
| 635 |
parse_makefile_am(${EXTRAS_MAKEFILE} "WEBP_EXTRAS_SRCS" "libwebpextras_la") |
| 636 |
parse_makefile_am(${EXTRAS_MAKEFILE} "GET_DISTO_SRCS" "get_disto") |
| 637 |
parse_makefile_am(${EXTRAS_MAKEFILE} "WEBP_QUALITY_SRCS" "webp_quality") |
| 638 |
parse_makefile_am(${EXTRAS_MAKEFILE} "VWEBP_SDL_SRCS" "vwebp_sdl") |
| 639 |
|
| 640 |
# libextras |
| 641 |
add_library(extras STATIC ${WEBP_EXTRAS_SRCS}) |
| 642 |
target_include_directories( |
| 643 |
extras PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} |
| 644 |
${CMAKE_CURRENT_SOURCE_DIR}/src) |
| 645 |
|
| 646 |
# get_disto |
| 647 |
add_executable(get_disto ${GET_DISTO_SRCS}) |
| 648 |
target_link_libraries(get_disto imagedec) |
| 649 |
target_include_directories(get_disto PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} |
| 650 |
${CMAKE_CURRENT_BINARY_DIR}/src) |
| 651 |
|
| 652 |
# webp_quality |
| 653 |
add_executable(webp_quality ${WEBP_QUALITY_SRCS}) |
| 654 |
target_link_libraries(webp_quality exampleutil imagedec extras) |
| 655 |
target_include_directories(webp_quality PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} |
| 656 |
${CMAKE_CURRENT_BINARY_DIR}) |
| 657 |
|
| 658 |
# vwebp_sdl |
| 659 |
find_package(SDL2 QUIET) |
| 660 |
if(WEBP_BUILD_VWEBP AND SDL2_FOUND) |
| 661 |
add_executable(vwebp_sdl ${VWEBP_SDL_SRCS}) |
| 662 |
target_link_libraries(vwebp_sdl ${SDL2_LIBRARIES} imageioutil webp) |
| 663 |
target_include_directories( |
| 664 |
vwebp_sdl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} |
| 665 |
${CMAKE_CURRENT_BINARY_DIR}/src ${SDL2_INCLUDE_DIRS}) |
| 666 |
set(WEBP_HAVE_SDL 1) |
| 667 |
target_compile_definitions(vwebp_sdl PUBLIC WEBP_HAVE_SDL) |
| 668 |
|
| 669 |
set(CMAKE_REQUIRED_INCLUDES "${SDL2_INCLUDE_DIRS}") |
| 670 |
check_c_source_compiles( |
| 671 |
" |
| 672 |
#define SDL_MAIN_HANDLED |
| 673 |
#include \"SDL.h\" |
| 674 |
int main(void) { |
| 675 |
return 0; |
| 676 |
} |
| 677 |
" |
| 678 |
HAVE_JUST_SDL_H) |
| 679 |
set(CMAKE_REQUIRED_INCLUDES) |
| 680 |
if(HAVE_JUST_SDL_H) |
| 681 |
target_compile_definitions(vwebp_sdl PRIVATE WEBP_HAVE_JUST_SDL_H) |
| 682 |
endif() |
| 683 |
endif() |
| 684 |
endif() |
| 685 |
|
| 686 |
if(WEBP_BUILD_WEBP_JS) |
| 687 |
# The default stack size changed from 5MB to 64KB in 3.1.27. See |
| 688 |
# https://crbug.com/webp/614. |
| 689 |
if(EMSCRIPTEN_VERSION VERSION_GREATER_EQUAL "3.1.27") |
| 690 |
# TOTAL_STACK size was renamed to STACK_SIZE in 3.1.27. The old name was |
| 691 |
# kept for compatibility, but prefer the new one in case it is removed in |
| 692 |
# the future. |
| 693 |
set(emscripten_stack_size "-sSTACK_SIZE=5MB") |
| 694 |
else() |
| 695 |
set(emscripten_stack_size "-sTOTAL_STACK=5MB") |
| 696 |
endif() |
| 697 |
find_package(SDL2 REQUIRED) |
| 698 |
# wasm2js does not support SIMD. |
| 699 |
if(NOT WEBP_ENABLE_SIMD) |
| 700 |
# JavaScript version |
| 701 |
add_executable(webp_js ${CMAKE_CURRENT_SOURCE_DIR}/extras/webp_to_sdl.c) |
| 702 |
target_link_libraries(webp_js webpdecoder SDL2) |
| 703 |
target_include_directories(webp_js PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) |
| 704 |
set(WEBP_HAVE_SDL 1) |
| 705 |
set_target_properties( |
| 706 |
webp_js |
| 707 |
PROPERTIES |
| 708 |
# Emscripten puts -sUSE_SDL2=1 in this variable, though it's needed at |
| 709 |
# compile time to ensure the headers are downloaded. |
| 710 |
COMPILE_OPTIONS "${SDL2_LIBRARIES}" |
| 711 |
LINK_FLAGS |
| 712 |
"-sWASM=0 ${emscripten_stack_size} \ |
| 713 |
-sEXPORTED_FUNCTIONS=_WebPToSDL -sINVOKE_RUN=0 \ |
| 714 |
-sEXPORTED_RUNTIME_METHODS=cwrap ${SDL2_LIBRARIES} \ |
| 715 |
-sALLOW_MEMORY_GROWTH") |
| 716 |
set_target_properties(webp_js PROPERTIES OUTPUT_NAME webp) |
| 717 |
target_compile_definitions(webp_js PUBLIC EMSCRIPTEN WEBP_HAVE_SDL) |
| 718 |
endif() |
| 719 |
|
| 720 |
# WASM version |
| 721 |
add_executable(webp_wasm ${CMAKE_CURRENT_SOURCE_DIR}/extras/webp_to_sdl.c) |
| 722 |
target_link_libraries(webp_wasm webpdecoder SDL2) |
| 723 |
target_include_directories(webp_wasm PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) |
| 724 |
set_target_properties( |
| 725 |
webp_wasm |
| 726 |
PROPERTIES |
| 727 |
# Emscripten puts -sUSE_SDL2=1 in this variable, though it's needed at |
| 728 |
# compile time to ensure the headers are downloaded. |
| 729 |
COMPILE_OPTIONS "${SDL2_LIBRARIES}" |
| 730 |
LINK_FLAGS |
| 731 |
"-sWASM=1 ${emscripten_stack_size} \ |
| 732 |
-sEXPORTED_FUNCTIONS=_WebPToSDL -sINVOKE_RUN=0 \ |
| 733 |
-sEXPORTED_RUNTIME_METHODS=cwrap ${SDL2_LIBRARIES} \ |
| 734 |
-sALLOW_MEMORY_GROWTH") |
| 735 |
target_compile_definitions(webp_wasm PUBLIC EMSCRIPTEN WEBP_HAVE_SDL) |
| 736 |
|
| 737 |
target_compile_definitions(webpdspdecode PUBLIC EMSCRIPTEN) |
| 738 |
endif() |
| 739 |
|
| 740 |
if(WEBP_BUILD_ANIM_UTILS) |
| 741 |
# anim_diff |
| 742 |
include_directories(${WEBP_DEP_IMG_INCLUDE_DIRS} ${WEBP_DEP_GIF_INCLUDE_DIRS}) |
| 743 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "ANIM_DIFF_SRCS" |
| 744 |
"anim_diff") |
| 745 |
add_executable(anim_diff ${ANIM_DIFF_SRCS}) |
| 746 |
target_link_libraries( |
| 747 |
anim_diff |
| 748 |
exampleutil |
| 749 |
imagedec |
| 750 |
imageenc |
| 751 |
imageioutil |
| 752 |
webp |
| 753 |
webpdemux |
| 754 |
${WEBP_DEP_GIF_LIBRARIES}) |
| 755 |
target_include_directories(anim_diff PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src) |
| 756 |
|
| 757 |
# anim_dump |
| 758 |
include_directories(${WEBP_DEP_IMG_INCLUDE_DIRS} ${WEBP_DEP_GIF_INCLUDE_DIRS}) |
| 759 |
parse_makefile_am(${CMAKE_CURRENT_SOURCE_DIR}/examples "ANIM_DUMP_SRCS" |
| 760 |
"anim_dump") |
| 761 |
add_executable(anim_dump ${ANIM_DUMP_SRCS}) |
| 762 |
target_link_libraries( |
| 763 |
anim_dump |
| 764 |
exampleutil |
| 765 |
imagedec |
| 766 |
imageenc |
| 767 |
imageioutil |
| 768 |
webp |
| 769 |
webpdemux |
| 770 |
${WEBP_DEP_GIF_LIBRARIES}) |
| 771 |
target_include_directories(anim_dump PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/src) |
| 772 |
endif() |
| 773 |
|
| 774 |
# Install the different headers and libraries. |
| 775 |
install( |
| 776 |
TARGETS ${INSTALLED_LIBRARIES} |
| 777 |
EXPORT ${PROJECT_NAME}Targets |
| 778 |
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webp |
| 779 |
INCLUDES |
| 780 |
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} |
| 781 |
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 782 |
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 783 |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 784 |
set(ConfigPackageLocation ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake/) |
| 785 |
install(EXPORT ${PROJECT_NAME}Targets NAMESPACE ${PROJECT_NAME}:: |
| 786 |
DESTINATION ${ConfigPackageLocation}) |
| 787 |
|
| 788 |
# Create the CMake version file. |
| 789 |
include(CMakePackageConfigHelpers) |
| 790 |
write_basic_package_version_file( |
| 791 |
"${CMAKE_CURRENT_BINARY_DIR}/WebPConfigVersion.cmake" |
| 792 |
VERSION ${PACKAGE_VERSION} COMPATIBILITY AnyNewerVersion) |
| 793 |
|
| 794 |
# Create the Config file. |
| 795 |
include(CMakePackageConfigHelpers) |
| 796 |
# Fix libwebpmux reference. The target name libwebpmux is used for compatibility |
| 797 |
# purposes, but the library mentioned in WebPConfig.cmake should be the |
| 798 |
# unprefixed version. Note string(...) can be replaced with list(TRANSFORM ...) |
| 799 |
# if cmake_minimum_required is >= 3.12. |
| 800 |
string(REGEX REPLACE "libwebpmux" "webpmux" INSTALLED_LIBRARIES |
| 801 |
"${INSTALLED_LIBRARIES}") |
| 802 |
|
| 803 |
if(MSVC) |
| 804 |
# For compatibility with nmake, MSVC builds use a custom prefix (lib) that |
| 805 |
# needs to be included in the library name. |
| 806 |
string(REGEX REPLACE "[A-Za-z0-9_]+" "${CMAKE_STATIC_LIBRARY_PREFIX}\\0" |
| 807 |
INSTALLED_LIBRARIES "${INSTALLED_LIBRARIES}") |
| 808 |
endif() |
| 809 |
|
| 810 |
configure_package_config_file( |
| 811 |
${CMAKE_CURRENT_SOURCE_DIR}/cmake/WebPConfig.cmake.in |
| 812 |
${CMAKE_CURRENT_BINARY_DIR}/WebPConfig.cmake |
| 813 |
INSTALL_DESTINATION ${ConfigPackageLocation} |
| 814 |
PATH_VARS CMAKE_INSTALL_INCLUDEDIR) |
| 815 |
|
| 816 |
# Install the generated CMake files. |
| 817 |
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/WebPConfigVersion.cmake" |
| 818 |
"${CMAKE_CURRENT_BINARY_DIR}/WebPConfig.cmake" |
| 819 |
DESTINATION ${ConfigPackageLocation}) |
| 820 |
|
| 821 |
# Install the man pages. |
| 822 |
set(MAN_PAGES |
| 823 |
cwebp.1 |
| 824 |
dwebp.1 |
| 825 |
gif2webp.1 |
| 826 |
img2webp.1 |
| 827 |
vwebp.1 |
| 828 |
webpmux.1 |
| 829 |
webpinfo.1) |
| 830 |
set(EXEC_BUILDS |
| 831 |
"CWEBP" |
| 832 |
"DWEBP" |
| 833 |
"GIF2WEBP" |
| 834 |
"IMG2WEBP" |
| 835 |
"VWEBP" |
| 836 |
"WEBPMUX" |
| 837 |
"WEBPINFO") |
| 838 |
list(LENGTH MAN_PAGES MAN_PAGES_LENGTH) |
| 839 |
math(EXPR MAN_PAGES_RANGE "${MAN_PAGES_LENGTH} - 1") |
| 840 |
|
| 841 |
foreach(I_MAN RANGE ${MAN_PAGES_RANGE}) |
| 842 |
list(GET EXEC_BUILDS ${I_MAN} EXEC_BUILD) |
| 843 |
if(WEBP_BUILD_${EXEC_BUILD}) |
| 844 |
list(GET MAN_PAGES ${I_MAN} MAN_PAGE) |
| 845 |
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/man/${MAN_PAGE} |
| 846 |
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT doc) |
| 847 |
endif() |
| 848 |
endforeach() |