
From: Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
Author: Gianfranco Costamagna <locutusofborg@debian.org>
Date: Thu, 31 Dec 2020 15:34:13 +0100
Subject: [PATCH] Add pkgconfig handling for cmake.
Forwarded: https://github.com/BelledonneCommunications/mediastreamer2/pull/27
Last-Update: 2020-12-31

---
 CMakeLists.txt      | 9 +++++++++
 mediastreamer.pc.in | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -759,8 +759,12 @@
 	set(PACKAGE_DATA_DIR "${CMAKE_INSTALL_DATADIR}")
 endif()
 
+set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
+set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mediastreamer-config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/mediastreamer-config.h)
 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/mediastreamer-config.h PROPERTIES GENERATED ON)
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/mediastreamer.pc.in ${CMAKE_CURRENT_BINARY_DIR}/mediastreamer.pc)
+set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/mediastreamer.pc PROPERTIES GENERATED ON)
 add_definitions("-DHAVE_CONFIG_H")
 
 if(ENABLE_DOC)
@@ -794,6 +798,11 @@
 	NO_SET_AND_CHECK_MACRO
 )
 
+install(FILES
+	"${CMAKE_CURRENT_BINARY_DIR}/mediastreamer.pc"
+	DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
+)
+
 install(EXPORT ${EXPORT_TARGETS_NAME}Targets
 	FILE Mediastreamer2Targets.cmake
 	DESTINATION ${CONFIG_PACKAGE_LOCATION}
--- a/mediastreamer.pc.in
+++ b/mediastreamer.pc.in
@@ -1,11 +1,11 @@
 # This is a comment
-prefix=@prefix@
-exec_prefix=@exec_prefix@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=@CMAKE_INSTALL_PREFIX@
 includedir=@includedir@
 
 Name: mediastreamer 
 Description: A mediastreaming library for telephony applications
 Requires: ortp bctoolbox
 Version: @MEDIASTREAMER_VERSION@
-Libs: -L@libdir@ -lmediastreamer_base -lmediastreamer_voip
+Libs: -L@CMAKE_INSTALL_FULL_LIBDIR@ -lmediastreamer
 Cflags: -I@includedir@ @MS_PUBLIC_CFLAGS@
