Skip to content

Commit 02c4818

Browse files
committed
Generate pkg-config files under CMake
configure_pkg_config_file helper function copied from the ogg repository.
1 parent 5eb65b1 commit 02c4818

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@ target_compile_definitions(opusfile
8383
$<$<BOOL:${OP_ENABLE_ASSERTIONS}>:OP_ENABLE_ASSERTIONS>
8484
$<$<BOOL:${OP_HAVE_LRINTF}>:OP_HAVE_LRINTF>
8585
)
86+
87+
# Helper function to configure pkg-config files
88+
function(configure_pkg_config_file pkg_config_file_in)
89+
set(prefix ${CMAKE_INSTALL_PREFIX})
90+
set(exec_prefix ${CMAKE_INSTALL_FULL_BINDIR})
91+
set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
92+
set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
93+
set(VERSION ${PROJECT_VERSION})
94+
string(REPLACE ".in" "" pkg_config_file ${pkg_config_file_in})
95+
configure_file(${pkg_config_file_in} ${pkg_config_file} @ONLY)
96+
endfunction()
97+
98+
configure_pkg_config_file(opusfile.pc.in)
99+
configure_pkg_config_file(opusurl.pc.in)
100+
86101
install(TARGETS opusfile
87102
EXPORT OpusFileTargets
88103
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
@@ -92,6 +107,10 @@ install(TARGETS opusfile
92107
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/opus"
93108
)
94109

110+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/opusfile.pc ${CMAKE_CURRENT_BINARY_DIR}/opusurl.pc
111+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
112+
)
113+
95114
if(NOT OP_DISABLE_HTTP)
96115
find_package(OpenSSL REQUIRED)
97116

0 commit comments

Comments
 (0)