From 86c88b9f634cc938c89dffeac03d7c0114746686 Mon Sep 17 00:00:00 2001
From: Christoph Haag <christoph.haag@collabora.com>
Date: Mon, 2 Dec 2019 19:16:13 +0100
Subject: [PATCH] Add library soname from openvr version

---
 src/CMakeLists.txt | 1 +
 1 file changed, 1 insertion(+)

--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,8 @@
 # Project name.
 project(openvr_api)
 
+include(GNUInstallDirs)
+
 set( LIBNAME "openvr_api" )
 set(OPENVR_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../headers)
 
@@ -74,6 +76,7 @@ source_group("VRCommon" FILES
 # Build the library.
 if(BUILD_SHARED)
 	add_library(${LIBNAME} SHARED ${SOURCE_FILES})
+	set_target_properties(${LIBNAME} PROPERTIES SOVERSION "${VERSION_MAJOR}" VERSION "${OPENVR_VERSION}")
 elseif(BUILD_FRAMEWORK)
 	set( LIBNAME "OpenVR" )
 	add_library( ${LIBNAME} 
@@ -122,12 +125,12 @@ endif()
 target_link_libraries(${LIBNAME} ${EXTRA_LIBS} ${CMAKE_DL_LIBS})
 target_include_directories(${LIBNAME} PUBLIC ${OPENVR_HEADER_DIR})
 
-install(TARGETS ${LIBNAME} DESTINATION lib)
+install(TARGETS ${LIBNAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})
 install(FILES ${PUBLIC_HEADER_FILES} DESTINATION include/openvr)
 
 # Generate a .pc file for linux environments
 if(PLATFORM_NAME MATCHES "linux")
-    set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
+	set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
     CONFIGURE_FILE("openvr.pc.in" "openvr.pc" @ONLY)
 
     set(OPENVR_PC ${CMAKE_CURRENT_BINARY_DIR}/openvr.pc)
--- a/src/openvr.pc.in
+++ b/src/openvr.pc.in
@@ -1,6 +1,6 @@
 prefix=@CMAKE_INSTALL_PREFIX@
-exec_prefix=${prefix}
-libdir=${prefix}/lib
+exec_prefix=@CMAKE_INSTALL_PREFIX@
+libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@
 includedir=${prefix}/include/openvr
 
 Name: openvr
