forked from zlib-ng/minizip-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
122 lines (98 loc) · 2.89 KB
/
CMakeLists.txt
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
#***************************************************************************
# Copyright: Matthias Schmieder,
# E-Mail: [email protected]
# Year: 2016
#***************************************************************************
cmake_minimum_required(VERSION 2.8)
# Set a consistent MACOSX_RPATH default across all CMake versions.
# When CMake 2.8.12 is required, change this default to 1.
# When CMake 3.0.0 is required, remove this block (see CMP0042).
if(NOT DEFINED CMAKE_MACOSX_RPATH)
set(CMAKE_MACOSX_RPATH 0)
endif()
project("minizip")
# set cmake debug postfix to d
set(CMAKE_DEBUG_POSTFIX "d")
# Ensure correct version of zlib is referenced
set(ZLIB_ROOT ${DEF_ZLIB_ROOT} CACHE PATH "Parent directory of zlib installation")
find_package(ZLIB REQUIRED)
if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
endif()
set(MINIZIP_SRC "ioapi.c"
"ioapi_buf.c"
"ioapi_mem.c"
"unzip.c"
"zip.c")
set(MINIZIP_PUBLIC_HEADERS "crypt.h"
"ioapi.h"
"ioapi_buf.h"
"ioapi_mem.h"
"unzip.h"
"zip.h")
if(WIN32)
list(APPEND MINIZIP_SRC "iowin32.c")
list(APPEND MINIZIP_PUBLIC_HEADERS "iowin32.h")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif()
if(UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -O3")
endif()
# create minizip library
add_library(minizip ${MINIZIP_SRC} ${MINIZIP_PUBLIC_HEADERS})
target_link_libraries(minizip ZLIB::ZLIB)
option(USE_AES "enables building of aes library" ON)
if(USE_AES)
set(AES_SRC
aes/aescrypt.c
aes/aeskey.c
aes/aestab.c
aes/entropy.c
aes/fileenc.c
aes/hmac.c
aes/prng.c
aes/pwd2key.c
aes/sha1.c)
set(AES_PUBLIC_HEADERS
aes/aes.h
aes/aes_via_ace.h
aes/aesopt.h
aes/aestab.h
aes/brg_endian.h
aes/brg_types.h
aes/entropy.h
aes/fileenc.h
aes/hmac.h
aes/prng.h
aes/pwd2key.h
aes/sha1.h)
add_library(aes ${AES_SRC} ${AES_PUBLIC_HEADERS})
add_definitions(-DHAVE_AES)
target_link_libraries(minizip aes)
install(TARGETS aes EXPORT minizip-exports
INCLUDES DESTINATION "include"
RUNTIME DESTINATION "bin"
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib")
install(FILES ${AES_PUBLIC_HEADERS}
DESTINATION "include/minizip/aes")
endif()
install(TARGETS minizip EXPORT minizip-exports
INCLUDES DESTINATION "include"
RUNTIME DESTINATION "bin"
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib")
install(EXPORT minizip-exports
DESTINATION "cmake"
NAMESPACE "MINIZIP::")
install(FILES ${MINIZIP_PUBLIC_HEADERS}
DESTINATION "include/minizip")
option (BUILD_TEST "enabled building of executables minizip and miniunz. Requires ZLIB!" OFF)
if(BUILD_TEST)
add_executable(miniunz_exec miniunz.c)
target_link_libraries(miniunz_exec minizip)
add_executable(minizip_exec minizip.c)
target_link_libraries(minizip_exec minizip)
install(TARGETS miniunz_exec minizip_exec
RUNTIME DESTINATION "bin")
endif()