1From 992a497e9c5c421d3931e02a01e9d7c159f27135 Mon Sep 17 00:00:00 2001
2From: Luca Ceresoli <luca@lucaceresoli.net>
3Date: Thu, 26 Nov 2015 12:49:10 +0100
4Subject: [PATCH] Add a CMakeFile.txt to ease cross-compilation
5
6Info-ZIP's UnZip 6.0 has a complex, hand-crafted Makefile with a
7companion configure script which try to support an extremely wide
8range of UNIX-like operating systems. The result is an overly complex
9mass of code that does not support cross-compilation in several ways.
10
11Zip 3.0 has a similar build system, and has as many as 6 patches in
12Buildroot to cross-compile [0]. UnZip fails at building even with
13these patches adapted and a few more on top of them.
14
15Instead of tweaking and fixing a huge and complex build system, skip
16it entirely and add a pretty simple CMakeLists.txt that cross-compiles
17smoothly using CMake. It also preserves all of the Buildroot-provided
18build options and flags as the original Makefile does.
19
20[0] http://git.buildroot.net/buildroot/tree/package/infozip?id=2015.11-rc3
21
22Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
23---
24 CMakeLists.txt | 17 +++++++++++++++++
25 1 file changed, 17 insertions(+)
26 create mode 100644 CMakeLists.txt
27
28diff --git a/CMakeLists.txt b/CMakeLists.txt
29new file mode 100644
30index 0000000..27951b4
31--- /dev/null
32+++ b/CMakeLists.txt
33@@ -0,0 +1,17 @@
34+cmake_minimum_required(VERSION 2.8)
35+INCLUDE(CheckFunctionExists)
36+
37+project(unzip C)
38+
39+CHECK_FUNCTION_EXISTS(lchmod HAVE_LCHMOD)
40+if(NOT HAVE_LCHMOD)
41+add_definitions("-DNO_LCHMOD")
42+endif()
43+
44+set(UNZIP_SOURCES unzip.c crc32.c crypt.c envargs.c explode.c
45+  extract.c fileio.c globals.c inflate.c list.c match.c process.c
46+  ttyio.c ubz2err.c unreduce.c unshrink.c zipinfo.c unix/unix.c)
47+
48+include_directories(.)
49+add_executable(unzip ${UNZIP_SOURCES})
50+install(TARGETS unzip DESTINATION bin)
51--
521.9.1
53
54