Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate pkg-config files under CMake #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ endif()
check_symbol_exists(lrintf "math.h" OP_HAVE_LRINTF)
cmake_pop_check_state()

# Helper function to configure pkg-config files
function(configure_pkg_config_file pkg_config_file_in)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_FULL_BINDIR})
set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
set(VERSION ${PROJECT_VERSION})
string(REPLACE ".in" "" pkg_config_file ${pkg_config_file_in})
configure_file(${pkg_config_file_in} ${pkg_config_file} @ONLY)
endfunction()

add_library(opusfile
"${CMAKE_CURRENT_SOURCE_DIR}/include/opusfile.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/info.c"
Expand Down Expand Up @@ -83,6 +94,10 @@ target_compile_definitions(opusfile
$<$<BOOL:${OP_ENABLE_ASSERTIONS}>:OP_ENABLE_ASSERTIONS>
$<$<BOOL:${OP_HAVE_LRINTF}>:OP_HAVE_LRINTF>
)
if(OP_HAVE_LIBM)
set(lrintf_lib "-lm")
endif()
configure_pkg_config_file(opusfile.pc.in)
install(TARGETS opusfile
EXPORT OpusFileTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
Expand All @@ -91,6 +106,9 @@ install(TARGETS opusfile
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/opus"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/opus"
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/opusfile.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)

if(NOT OP_DISABLE_HTTP)
find_package(OpenSSL REQUIRED)
Expand Down Expand Up @@ -177,6 +195,8 @@ if(NOT OP_DISABLE_HTTP)
$<$<C_COMPILER_ID:Clang,GNU>:-Wno-long-long>
$<$<C_COMPILER_ID:Clang,GNU>:-fvisibility=hidden>
)
set(openssl "openssl")
configure_pkg_config_file(opusurl.pc.in)
install(TARGETS opusurl
EXPORT OpusFileTargets
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
Expand All @@ -185,6 +205,9 @@ if(NOT OP_DISABLE_HTTP)
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/opus"
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/opus"
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/opusurl.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)
endif()

if(NOT OP_DISABLE_EXAMPLES)
Expand Down