Skip to content

Commit eee00b6

Browse files
SSE4jzern
authored andcommitted
- install pkg-config files during the CMake build
Signed-off-by: Konstantin Ivlev <tomskside@gmail.com> Change-Id: I88b1a22b19dd9ecdb2ae38082fa9580dbc66d98c
1 parent 5c395f1 commit eee00b6

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ if(WEBP_ENABLE_SWAP_16BIT_CSP)
4141
add_definitions(-DWEBP_SWAP_16BIT_CSP=1)
4242
endif()
4343

44+
set(prefix ${CMAKE_INSTALL_PREFIX})
45+
set(exec_prefix "\$\{prefix\}")
46+
set(libdir "\$\{prefix\}/lib")
47+
set(includedir "\$\{prefix\}/include")
48+
set(PTHREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
49+
4450
# ##############################################################################
4551
# Android only.
4652
if(ANDROID)
@@ -57,6 +63,23 @@ else()
5763
set(HAVE_CPU_FEATURES_H 0)
5864
endif()
5965

66+
function(configure_pkg_config FILE)
67+
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${FILE}.in"
68+
"${CMAKE_CURRENT_BINARY_DIR}/${FILE}")
69+
70+
if(HAVE_MATH_LIBRARY)
71+
# MSVC doesn't have libm
72+
file(READ ${CMAKE_CURRENT_BINARY_DIR}/${FILE} data)
73+
string(REPLACE "-lm" "" data ${data})
74+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${FILE} ${data})
75+
endif()
76+
77+
install(
78+
FILES "${CMAKE_CURRENT_BINARY_DIR}/${FILE}"
79+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
80+
)
81+
endfunction()
82+
6083
# ##############################################################################
6184
# WebP source files. Read the Makefile.am to get the source files.
6285

@@ -151,6 +174,8 @@ set_target_properties(
151174
PROPERTIES PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/src/webp/decode.h;\
152175
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h")
153176

177+
configure_pkg_config("src/libwebpdecoder.pc")
178+
154179
# Build the webp library.
155180
add_library(webpencode OBJECT ${WEBP_ENC_SRCS})
156181
target_include_directories(webpencode
@@ -197,6 +222,7 @@ set_target_properties(webpdecode
197222
webpdsp
198223
webputils
199224
PROPERTIES POSITION_INDEPENDENT_CODE ON)
225+
configure_pkg_config("src/libwebp.pc")
200226

201227
# Build the webp demux library.
202228
add_library(webpdemux ${WEBP_DEMUX_SRCS})
@@ -212,6 +238,8 @@ ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/demux.h;\
212238
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h;\
213239
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h")
214240

241+
configure_pkg_config("src/demux/libwebpdemux.pc")
242+
215243
# Set the version numbers.
216244
function(parse_version FILE NAME VAR)
217245
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/src/${FILE} SOURCE_FILE)
@@ -367,6 +395,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/src/webp/mux_types.h;\
367395
${CMAKE_CURRENT_SOURCE_DIR}/src/webp/types.h;")
368396
set_target_properties(libwebpmux PROPERTIES OUTPUT_NAME webpmux)
369397
list(APPEND INSTALLED_LIBRARIES libwebpmux)
398+
configure_pkg_config("src/mux/libwebpmux.pc")
370399
endif()
371400

372401
if(WEBP_BUILD_GIF2WEBP)

0 commit comments

Comments
 (0)