Bug#439121: Add a .pc file for libapt-pkt
Here is a patch adding the pkg-config files for the apt-pkg and apt-inst packages.>From 8ec88c729592b460978257341cbdc8a9668c0e9d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Corentin=20No=C3=ABl?= <corentin@elementary.io>
Date: Sat, 29 Oct 2016 16:07:24 +0200
Subject: [PATCH] Enable PkgConfig on the apt-pkg and apt-inst libraries
---
apt-inst/CMakeLists.txt | 3 +++
apt-inst/apt-inst.pc.in | 12 ++++++++++++
apt-pkg/CMakeLists.txt | 3 +++
apt-pkg/apt-pkg.pc.in | 11 +++++++++++
4 files changed, 29 insertions(+)
create mode 100644 apt-inst/apt-inst.pc.in
create mode 100644 apt-pkg/apt-pkg.pc.in
diff --git a/apt-inst/CMakeLists.txt b/apt-inst/CMakeLists.txt
index f757823..d11111a 100644
--- a/apt-inst/CMakeLists.txt
+++ b/apt-inst/CMakeLists.txt
@@ -10,6 +10,8 @@ set(APT_INST_MAJOR ${MAJOR} PARENT_SCOPE)
file(GLOB_RECURSE library "*.cc")
file(GLOB_RECURSE headers "*.h")
+configure_file(apt-inst.pc.in ${CMAKE_CURRENT_BINARY_DIR}/apt-inst.pc @ONLY)
+
# Create a library using the C++ files
add_library(apt-inst SHARED ${library})
@@ -23,4 +25,5 @@ add_version_script(apt-inst)
# Install the library and the headers
install(TARGETS apt-inst LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/apt-inst.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}")
diff --git a/apt-inst/apt-inst.pc.in b/apt-inst/apt-inst.pc.in
new file mode 100644
index 0000000..ccefe81
--- /dev/null
+++ b/apt-inst/apt-inst.pc.in
@@ -0,0 +1,12 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+
+Name: @PACKAGE@
+Description: Read deb packages informations
+Version: @MAJOR@.@MINOR@
+Libs: -L${libdir} -lapt-inst
+Cflags: -I${includedir}/apt-pkg
+Requires: apt-pkg
+
diff --git a/apt-pkg/CMakeLists.txt b/apt-pkg/CMakeLists.txt
index 1b493c8..f5f2220 100644
--- a/apt-pkg/CMakeLists.txt
+++ b/apt-pkg/CMakeLists.txt
@@ -16,6 +16,8 @@ execute_process(COMMAND grep "^#define APT_PKG_RELEASE"
message(STATUS "Building libapt-pkg ${MAJOR} (release ${MINOR})")
set(APT_PKG_MAJOR ${MAJOR} PARENT_SCOPE) # exporting for methods/CMakeLists.txt
+configure_file(apt-pkg.pc.in ${CMAKE_CURRENT_BINARY_DIR}/apt-pkg.pc @ONLY)
+
# Definition of the C++ files used to build the library
file(GLOB_RECURSE library "*.cc")
file(GLOB_RECURSE headers "*.h")
@@ -49,6 +51,7 @@ add_version_script(apt-pkg)
install(TARGETS apt-pkg LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/apt-pkg)
flatify(${PROJECT_BINARY_DIR}/include/apt-pkg/ "${headers}")
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/apt-pkg.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
if(CMAKE_BUILD_TYPE STREQUAL "Coverage")
target_link_libraries(apt-pkg PUBLIC noprofile)
diff --git a/apt-pkg/apt-pkg.pc.in b/apt-pkg/apt-pkg.pc.in
new file mode 100644
index 0000000..6a4115a
--- /dev/null
+++ b/apt-pkg/apt-pkg.pc.in
@@ -0,0 +1,11 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+
+Name: @PACKAGE@
+Description: Manage deb packages
+Version: @MAJOR@.@MINOR@
+Libs: -L${libdir} -lapt-pkg
+Cflags: -I${includedir}/apt-pkg
+
--
2.7.4
Reply to: