aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/unarr/debundle-7zip.patch
blob: 1118b905fcd7021b8ee9f49fc62716239d743d53 (plain)
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f38b229..3d5c150 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,19 +52,6 @@ add_library(
   # common/custalloc.c
   common/stream.c
   common/unarr.c
-  lzmasdk/7zTypes.h
-  lzmasdk/Compiler.h
-  lzmasdk/CpuArch.h
-  lzmasdk/Ppmd.h
-  lzmasdk/Ppmd7.h
-  lzmasdk/Ppmd8.h
-  lzmasdk/Precomp.h
-  lzmasdk/CpuArch.c
-  lzmasdk/Ppmd7.c
-  lzmasdk/Ppmd8.c
-  lzmasdk/Ppmd7Dec.c
-  lzmasdk/Ppmd7aDec.c
-  lzmasdk/Ppmd8Dec.c
   rar/lzss.h
   rar/rar.h
   rar/rarvm.h
@@ -102,6 +89,12 @@ target_include_directories(
 if(BUILD_SHARED_LIBS)
   target_compile_definitions(unarr PUBLIC UNARR_IS_SHARED_LIBRARY)
 endif()
+# Debundle 7zip
+find_package(7zip CONFIG REQUIRED)
+target_link_libraries(unarr PRIVATE 7zip::7zip)
+# 7zip upstream does not supply a .pc file. Add it to Libs.private.
+set(PROJECT_LIBS_PRIVATE "${PROJECT_LIBS_PRIVATE} -l7zip")
+set(UNARR_DEPENDS_7zip "find_dependency(7zip CONFIG)")
 
 if(USE_SYSTEM_BZ2)
   find_package(BZip2)
@@ -115,7 +108,8 @@ if(BZIP2_FOUND)
   endif()
   target_compile_definitions(unarr PRIVATE -DHAVE_BZIP2)
   # Bzip2 upstream does not supply a .pc file. Add it to Libs.private.
-  set(PROJECT_LIBS_PRIVATE "-I${BZIP2_INCLUDE_DIRS} -l${BZIP2_LIBRARIES}")
+  set(PROJECT_CFLAGS "${PROJECT_CFLAGS} -I${BZIP2_INCLUDE_DIRS}")
+  set(PROJECT_LIBS_PRIVATE "${PROJECT_LIBS_PRIVATE} -l${BZIP2_LIBRARIES}")
   set(UNARR_DEPENDS_BZip2 "find_dependency(BZip2)")
 endif()
 
@@ -154,28 +148,6 @@ if(ZLIB_FOUND)
 endif()
 
 if(ENABLE_7Z)
-  target_sources(
-    unarr
-    PRIVATE lzmasdk/7z.h
-            lzmasdk/7zArcIn.c
-            lzmasdk/7zBuf.h
-            lzmasdk/7zBuf.c
-            lzmasdk/7zDec.c
-            lzmasdk/7zStream.c
-            lzmasdk/7zWindows.h
-            lzmasdk/Bcj2.h
-            lzmasdk/Bcj2.c
-            lzmasdk/Bra.c
-            lzmasdk/Bra.h
-            lzmasdk/Bra86.c
-            lzmasdk/7zCrc.h
-            lzmasdk/Delta.h
-            lzmasdk/Delta.c
-            lzmasdk/Lzma2Dec.h
-            lzmasdk/Lzma2Dec.c)
-  if(LIBLZMA_FOUND) # TODO: Replace 7z lzma with system lzma
-    target_sources(unarr PRIVATE lzmasdk/LzmaDec.h lzmasdk/LzmaDec.c)
-  endif()
   target_compile_definitions(unarr PRIVATE -DHAVE_7Z -DZ7_PPMD_SUPPORT)
 endif()
 
@@ -194,8 +166,7 @@ if(UNIX
             -Werror-implicit-function-declaration
             $<$<CONFIG:Release>:-fomit-frame-pointer>
             $<$<C_COMPILER_ID:Clang,AppleClang>:
-            -Wno-missing-field-initializers>
-            -flto)
+            -Wno-missing-field-initializers>)
   if(BUILD_FUZZER)
     target_compile_options(unarr PUBLIC "${sanitize_opts}")
     target_compile_definitions(
@@ -218,7 +189,7 @@ if(UNIX
 
   # Clang linker needs -flto too when doing lto
   if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
-    set(linker_opts "${linker_opts} -flto")
+    set(linker_opts "${linker_opts}")
   endif()
 
   set_target_properties(unarr PROPERTIES LINK_FLAGS "${linker_opts}")
diff --git a/_7z/_7z.h b/_7z/_7z.h
index 7f207e1..f488e42 100644
--- a/_7z/_7z.h
+++ b/_7z/_7z.h
@@ -6,9 +6,9 @@
 
 #include "../common/unarr-imp.h"
 
-#include "../lzmasdk/7zTypes.h"
+#include <7zip/C/7zTypes.h>
 #ifdef HAVE_7Z
-#include "../lzmasdk/7z.h"
+#include <7zip/C/7z.h>
 #endif
 
 typedef struct ar_archive_7z_s ar_archive_7z;
diff --git a/pkg-config.pc.cmake b/pkg-config.pc.cmake
index 9055aef..a8581e0 100644
--- a/pkg-config.pc.cmake
+++ b/pkg-config.pc.cmake
@@ -5,7 +5,7 @@ libdir=@PROJECT_INSTALL_LIBDIR@
 Name: @PROJECT_NAME@
 Description: @PROJECT_DESCRIPTION@
 Version: @PROJECT_VERSION@
-Cflags: -I${includedir}
+Cflags: -I${includedir}@PROJECT_CFLAGS@
 Requires.private: @PROJECT_REQUIRES_PRIVATE@
 Libs: -L${libdir} -l@PROJECT_NAME@
 Libs.private: @PROJECT_LIBS_PRIVATE@
diff --git a/rar/rar.h b/rar/rar.h
index a0a420a..b522a33 100644
--- a/rar/rar.h
+++ b/rar/rar.h
@@ -7,7 +7,7 @@
 #include "../common/unarr-imp.h"
 
 #include "lzss.h"
-#include "../lzmasdk/Ppmd7.h"
+#include <7zip/C/Ppmd7.h>
 #include <limits.h>
 
 static inline size_t smin(size_t a, size_t b) { return a < b ? a : b; }
diff --git a/unarr-config.cmake.in b/unarr-config.cmake.in
index 1c95f9b..4d82965 100644
--- a/unarr-config.cmake.in
+++ b/unarr-config.cmake.in
@@ -5,6 +5,7 @@ include(CMakeFindDependencyMacro)
 @UNARR_DEPENDS_BZip2@
 @UNARR_DEPENDS_LibLZMA@
 @UNARR_DEPENDS_ZLIB@
+@UNARR_DEPENDS_7zip@
 
 if (NOT TARGET unarr::unarr)
   include("${CMAKE_CURRENT_LIST_DIR}/unarr-targets.cmake")
diff --git a/zip/zip.h b/zip/zip.h
index b2ba34c..23da8d8 100644
--- a/zip/zip.h
+++ b/zip/zip.h
@@ -16,9 +16,9 @@
 #ifdef HAVE_LIBLZMA
 #include <lzma.h>
 #else
-#include "../lzmasdk/LzmaDec.h"
+#include <7zip/C/LzmaDec.h>
 #endif
-#include "../lzmasdk/Ppmd8.h"
+#include <7zip/C/Ppmd8.h>
 
 typedef struct ar_archive_zip_s ar_archive_zip;