summarylogtreecommitdiffstats
path: root/shared-libarchive.patch
blob: cc86185a7efe5aaa519479cee24f7e8decdb4dcf (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
From cf84155eb143d821963e8fdf18781dfa164eac9b Mon Sep 17 00:00:00 2001
From: "Azamat H. Hackimov" <azamat.hackimov@gmail.com>
Date: Fri, 9 Oct 2020 02:18:36 +0300
Subject: [PATCH] Make LibArchive as shared library dependency

---
 CMakeLists.txt             | 11 +++++++++++
 src/app/CMakeLists.txt     |  2 +-
 third_party/CMakeLists.txt | 22 ++++++++++++----------
 3 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9cb5a2cdfb..9d95936f36 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,6 +60,7 @@ option(USE_SHARED_CURL    "Use your installed copy of curl" off)
 option(USE_SHARED_GIFLIB  "Use your installed copy of giflib" off)
 option(USE_SHARED_JPEGLIB "Use your installed copy of jpeglib" off)
 option(USE_SHARED_ZLIB    "Use your installed copy of zlib" off)
+option(USE_SHARED_LIBARCHIVE "Use your installed copy of libarchive" off)
 option(USE_SHARED_LIBPNG  "Use your installed copy of libpng" off)
 option(USE_SHARED_TINYXML "Use your installed copy of tinyxml" off)
 option(USE_SHARED_PIXMAN  "Use your installed copy of pixman" off)
@@ -200,6 +201,16 @@ else()
 endif()
 include_directories(${ZLIB_INCLUDE_DIRS})
 
+# libarchive
+if(USE_SHARED_LIBARCHIVE)
+  find_package(LibArchive REQUIRED)
+else()
+  set(LibArchive_FOUND)
+  set(LibArchive_LIBRARIES archive_static)
+  set(LibArchive_INCLUDE_DIRS $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/libarchive/libarchive>)
+endif()
+include_directories(${LibArchive_INCLUDE_DIRS})
+
 # libpng
 if(USE_SHARED_LIBPNG)
   find_package(PNG REQUIRED)
diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt
index e1e3bc1ae3..4a37838e95 100644
--- a/src/app/CMakeLists.txt
+++ b/src/app/CMakeLists.txt
@@ -651,8 +651,8 @@ target_link_libraries(app-lib
   ${ZLIB_LIBRARIES}
   ${FREETYPE_LIBRARIES}
   ${HARFBUZZ_LIBRARIES}
+  ${LibArchive_LIBRARIES}
   json11
-  archive_static
   ${FMT_LIBRARIES}
   tinyexpr)
 
diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt
index ffd1c0cfcd..4839d4097c 100644
--- a/third_party/CMakeLists.txt.orig
+++ b/third_party/CMakeLists.txt
@@ -110,6 +110,7 @@ endif()
 add_subdirectory(json11)
 
 # libarchive
+if(NOT USE_SHARED_LIBARCHIVE)
 set(ENABLE_WERROR OFF CACHE BOOL "Treat warnings as errors - default is ON for Debug, OFF otherwise.")
 set(ENABLE_TEST OFF CACHE BOOL "Enable unit and regression tests")
 set(ENABLE_COVERAGE OFF CACHE BOOL "Enable code coverage (GCC only, automatically sets ENABLE_TEST to ON)")
@@ -123,6 +124,7 @@ set(ENABLE_CPIO OFF CACHE BOOL "Enable cpio building")
 add_subdirectory(libarchive)
 target_include_directories(archive_static INTERFACE
   $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/libarchive/libarchive>)
+endif()
 
 # benchmark
 if(ENABLE_BENCHMARKS)