Merge "- install pkg-config files during the CMake build"

This commit is contained in:
James Zern 2018-10-10 03:25:02 +00:00 committed by Gerrit Code Review
commit ef1094b0fe

View File

@ -41,6 +41,12 @@ if(WEBP_ENABLE_SWAP_16BIT_CSP)
add_definitions(-DWEBP_SWAP_16BIT_CSP=1) add_definitions(-DWEBP_SWAP_16BIT_CSP=1)
endif() endif()
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "\$\{prefix\}")
set(libdir "\$\{prefix\}/lib")
set(includedir "\$\{prefix\}/include")
set(PTHREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
# ############################################################################## # ##############################################################################
# Android only. # Android only.
if(ANDROID) if(ANDROID)
@ -57,6 +63,23 @@ else()
set(HAVE_CPU_FEATURES_H 0) set(HAVE_CPU_FEATURES_H 0)
endif() endif()
function(configure_pkg_config FILE)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.in"
"${CMAKE_CURRENT_BINARY_DIR}/${FILE}")
if(HAVE_MATH_LIBRARY)
# MSVC doesn't have libm
file(READ ${CMAKE_CURRENT_BINARY_DIR}/${FILE} data)
string(REPLACE "-lm" "" data ${data})
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${FILE} ${data})
endif()
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/${FILE}"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endfunction()
# ############################################################################## # ##############################################################################
# WebP source files. Read the Makefile.am to get the source files. # WebP source files. Read the Makefile.am to get the source files.
@ -151,6 +174,8 @@ set_target_properties(
PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\ PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h") ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h")
configure_pkg_config("src/libwebpdecoder.pc")
# Build the webp library. # Build the webp library.
add_library(webpencode OBJECT ${WEBP_ENC_SRCS}) add_library(webpencode OBJECT ${WEBP_ENC_SRCS})
target_include_directories(webpencode target_include_directories(webpencode
@ -197,6 +222,7 @@ set_target_properties(webpdecode
webpdsp webpdsp
webputils webputils
PROPERTIES POSITION_INDEPENDENT_CODE ON) PROPERTIES POSITION_INDEPENDENT_CODE ON)
configure_pkg_config("src/libwebp.pc")
# Build the webp demux library. # Build the webp demux library.
add_library(webpdemux ${WEBP_DEMUX_SRCS}) add_library(webpdemux ${WEBP_DEMUX_SRCS})
@ -212,6 +238,8 @@ ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/demux.h;\
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h;\ ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h;\
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h") ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h")
configure_pkg_config("src/demux/libwebpdemux.pc")
# Set the version numbers. # Set the version numbers.
function(parse_version FILE NAME VAR) function(parse_version FILE NAME VAR)
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/src/${FILE} SOURCE_FILE) file(READ ${CMAKE_CURRENT_SOURCE_DIR}/src/${FILE} SOURCE_FILE)
@ -367,6 +395,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h;\
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h;") ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h;")
set_target_properties(libwebpmux PROPERTIES OUTPUT_NAME webpmux) set_target_properties(libwebpmux PROPERTIES OUTPUT_NAME webpmux)
list(APPEND INSTALLED_LIBRARIES libwebpmux) list(APPEND INSTALLED_LIBRARIES libwebpmux)
configure_pkg_config("src/mux/libwebpmux.pc")
endif() endif()
if(WEBP_BUILD_GIF2WEBP) if(WEBP_BUILD_GIF2WEBP)