From cc170860e5b77d7c9f3b9ce8730b719976dab2bb Mon Sep 17 00:00:00 2001
From: Alexey Firago <alexey_firago@mentor.com>
Date: Mon, 30 Oct 2017 23:24:49 +0300
Subject: [PATCH] CMakeLists.txt: Fix libraries installation for Linux

* Set libs versions as in Makefile

Signed-off-by: Alexey Firago <alexey_firago@mentor.com>
---
 CMakeLists.txt | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9663934..5719435 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,6 +30,15 @@ set(PACKAGE_TARNAME   "${PACKAGE_NAME}-${PACKAGE_VERSION}")
 set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/")
 project(${PACKAGE_NAME} C CXX)

+set (CORE_VERSION_MAJOR "4")
+set (CORE_VERSION "4.0.0")
+
+set (CPP_VERSION_MAJOR "1")
+set (CPP_VERSION "1.6.6")
+
+set (CSHARP_VERSION_MAJOR "1")
+set (CSHARP_VERSION "1.6.6")
+
 set(gRPC_INSTALL_BINDIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
 set(gRPC_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
 set(gRPC_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
@@ -840,6 +849,10 @@ if(WIN32 AND MSVC)
   endif()
 endif()

+if(_gRPC_PLATFORM_LINUX)
+  set_property(TARGET gpr PROPERTY VERSION ${CORE_VERSION})
+  set_property(TARGET gpr PROPERTY SOVERSION ${CORE_VERSION_MAJOR})
+endif()

 target_include_directories(gpr
   PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
@@ -1228,6 +1241,10 @@ if(WIN32 AND MSVC)
   endif()
 endif()

+if(_gRPC_PLATFORM_LINUX)
+  set_property(TARGET grpc PROPERTY VERSION ${CORE_VERSION})
+  set_property(TARGET grpc PROPERTY SOVERSION ${CORE_VERSION_MAJOR})
+endif()

 target_include_directories(grpc
   PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
@@ -1534,6 +1551,10 @@ if(WIN32 AND MSVC)
   endif()
 endif()

+if(_gRPC_PLATFORM_LINUX)
+  set_property(TARGET grpc_cronet PROPERTY VERSION ${CORE_VERSION})
+  set_property(TARGET grpc_cronet PROPERTY SOVERSION ${CORE_VERSION_MAJOR})
+endif()

 target_include_directories(grpc_cronet
   PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
@@ -2366,6 +2387,10 @@ if(WIN32 AND MSVC)
   endif()
 endif()

+if(_gRPC_PLATFORM_LINUX)
+  set_property(TARGET grpc_unsecure PROPERTY VERSION ${CORE_VERSION})
+  set_property(TARGET grpc_unsecure PROPERTY SOVERSION ${CORE_VERSION_MAJOR})
+endif()

 target_include_directories(grpc_unsecure
   PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
@@ -2583,6 +2608,10 @@ if(WIN32 AND MSVC)
   endif()
 endif()

+if(_gRPC_PLATFORM_LINUX)
+  set_property(TARGET grpc++ PROPERTY VERSION ${CPP_VERSION})
+  set_property(TARGET grpc++ PROPERTY SOVERSION ${CPP_VERSION_MAJOR})
+endif()

 target_include_directories(grpc++
   PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
@@ -3013,6 +3042,10 @@ if(WIN32 AND MSVC)
   endif()
 endif()

+if(_gRPC_PLATFORM_LINUX)
+  set_property(TARGET grpc++_cronet PROPERTY VERSION ${CPP_VERSION})
+  set_property(TARGET grpc++_cronet PROPERTY SOVERSION ${CPP_VERSION_MAJOR})
+endif()

 target_include_directories(grpc++_cronet
   PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
@@ -3213,6 +3246,11 @@ protobuf_generate_grpc_cpp(
   src/proto/grpc/status/status.proto
 )

+if(_gRPC_PLATFORM_LINUX)
+  set_property(TARGET grpc++_error_details PROPERTY VERSION ${CPP_VERSION})
+  set_property(TARGET grpc++_error_details PROPERTY SOVERSION ${CPP_VERSION_MAJOR})
+endif()
+
 target_include_directories(grpc++_error_details
   PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
   PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@@ -3343,6 +3381,11 @@ protobuf_generate_grpc_cpp(
   src/proto/grpc/reflection/v1alpha/reflection.proto
 )

+if(_gRPC_PLATFORM_LINUX)
+  set_property(TARGET grpc++_reflection PROPERTY VERSION ${CPP_VERSION})
+  set_property(TARGET grpc++_reflection PROPERTY SOVERSION ${CPP_VERSION_MAJOR})
+endif()
+
 target_include_directories(grpc++_reflection
   PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
   PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
@@ -3762,6 +3805,10 @@ if(WIN32 AND MSVC)
   endif()
 endif()

+if(_gRPC_PLATFORM_LINUX)
+  set_property(TARGET grpc++_unsecure PROPERTY VERSION ${CPP_VERSION})
+  set_property(TARGET grpc++_unsecure PROPERTY SOVERSION ${CPP_VERSION_MAJOR})
+endif()

 target_include_directories(grpc++_unsecure
   PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
@@ -4075,6 +4122,10 @@ if(WIN32 AND MSVC)
   endif()
 endif()

+if(_gRPC_PLATFORM_LINUX)
+  set_property(TARGET grpc_plugin_support PROPERTY VERSION ${CORE_VERSION})
+  set_property(TARGET grpc_plugin_support PROPERTY SOVERSION ${CORE_VERSION_MAJOR})
+endif()

 target_include_directories(grpc_plugin_support
   PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
@@ -4599,6 +4650,10 @@ if(WIN32 AND MSVC)
   endif()
 endif()

+if(_gRPC_PLATFORM_LINUX)
+  set_property(TARGET grpc_csharp_ext PROPERTY VERSION ${CSHARP_VERSION})
+  set_property(TARGET grpc_csharp_ext PROPERTY SOVERSION ${CSHARP_VERSION_MAJOR})
+endif()

 target_include_directories(grpc_csharp_ext
   PUBLIC $<INSTALL_INTERFACE:include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
--
2.7.4
