Browse Source

libobs: Add pkgconfig support

Based on:

http://dailycommit.blogspot.com/2016/10/how-to-generate-pkg-config-file-with.html
https://people.freedesktop.org/~dbn/pkg-config-guide.html

Should allow third party plugins to find and use libobs more easily.

Closes obsproject/obs-studio#1467
Steve Wills 7 years ago
parent
commit
2f51abf994
2 changed files with 19 additions and 0 deletions
  1. 8 0
      libobs/CMakeLists.txt
  2. 11 0
      libobs/libobs.pc.in

+ 8 - 0
libobs/CMakeLists.txt

@@ -447,6 +447,14 @@ if(BUILD_CAPTIONS)
 endif()
 
 add_library(libobs SHARED ${libobs_SOURCES} ${libobs_HEADERS})
+if(UNIX AND NOT APPLE)
+	set(DEST_DIR "${CMAKE_INSTALL_PREFIX}")
+	foreach(LIB "obs" "rt")
+		set(PRIVATE_LIBS "${PRIVATE_LIBS} -l${LIB}")
+	endforeach()
+	CONFIGURE_FILE("libobs.pc.in" "libobs.pc" @ONLY)
+	install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libobs.pc" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
+endif()
 
 set_target_properties(libobs PROPERTIES
 	OUTPUT_NAME obs

+ 11 - 0
libobs/libobs.pc.in

@@ -0,0 +1,11 @@
+prefix=@DEST_DIR@
+exec_prefix=${prefix}
+libdir=${prefix}/@OBS_LIBRARY_DESTINATION@
+includedir=${prefix}/include
+
+Name: libobs
+Description: OBS Studio Library
+Version: @OBS_VERSION@
+Requires: x11
+Cflags: -I${includedir}
+Libs: -L${libdir} @PRIVATE_LIBS@