File: 0004-cmake-Add-support-for-installation.patch

package info (click to toggle)
upb 0.0.0~git200730-2
  • links: PTS
  • area: main
  • in suites: sid
  • size: 1,696 kB
  • sloc: ansic: 16,828; cpp: 5,098; python: 360; pascal: 160; ruby: 21; sh: 19; makefile: 6
file content (96 lines) | stat: -rw-r--r-- 2,968 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Description: [PATCH 4/5] cmake: Add support for installation
 This change makes use of CMake GNUInstallDirs module and allows one to
 install upb on the system with `make install` target.
Author: Michal Rostecki <mrostecki@opensuse.org>
Last-Update: 2020-06-29

---

--- upb-0.orig/CMakeLists.txt
+++ upb-0/CMakeLists.txt
@@ -13,6 +13,12 @@ cmake_policy(SET CMP0048 NEW)
 
 project(upb)
 
+include(GNUInstallDirs)
+
+if(NOT DEFINED CMAKE_INSTALL_CMAKEDIR)
+  set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/upb")
+endif()
+
 set(upb_SOVERSION 0)
 
 # Prevent CMake from setting -rdynamic on Linux (!!).
@@ -77,6 +83,9 @@ add_library(upb
   upb/upb.hpp)
 set_target_properties(upb PROPERTIES
   SOVERSION ${upb_SOVERSION})
+install(TARGETS upb EXPORT upb-targets
+  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 target_link_libraries(upb
   port)
 add_library(generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me INTERFACE)
@@ -88,6 +97,9 @@ add_library(descriptor_upb_proto
   generated_for_cmake/google/protobuf/descriptor.upb.h)
 set_target_properties(descriptor_upb_proto PROPERTIES
   SOVERSION ${upb_SOVERSION})
+install(TARGETS descriptor_upb_proto EXPORT descriptor_upb_proto-targets
+  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 add_library(upb_reflection
   upb/def.c
   upb/msg.h
@@ -102,6 +114,9 @@ target_link_libraries(upb_reflection
   port
   table
   upb)
+install(TARGETS upb_reflection EXPORT upb_reflection-targets
+  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 add_library(textformat
   upb/text_encode.c
   upb/text_encode.h)
@@ -134,6 +149,9 @@ target_link_libraries(upb_handlers
   upb_reflection
   table
   upb)
+install(TARGETS upb_handlers EXPORT upb_handlers-targets
+  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 add_library(upb_pb
   upb/pb/compile_decoder.c
   upb/pb/decoder.c
@@ -154,6 +172,9 @@ target_link_libraries(upb_pb
   upb_reflection
   table
   upb)
+install(TARGETS upb_pb EXPORT upb_pb-targets
+  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 add_library(upb_json
   generated_for_cmake/upb/json/parser.c
   upb/json/printer.c
@@ -164,6 +185,9 @@ set_target_properties(upb_json PROPERTIE
 target_link_libraries(upb_json
   upb
   upb_pb)
+install(TARGETS upb_json EXPORT upb_json-targets
+  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
 add_library(upb_cc_bindings INTERFACE)
 target_link_libraries(upb_cc_bindings INTERFACE
   descriptor_upb_proto
@@ -178,5 +202,10 @@ target_link_libraries(upb_test
   upb_handlers
   port
   upb)
-
-
+install(FILES
+  upb/decode.h
+  upb/encode.h
+  upb/msg.h
+  upb/port_def.inc
+  upb/port_undef.inc
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/upb)