forked from sebastiandev/minizip
-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
133 lines (108 loc) · 3.19 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
122
123
124
125
126
127
128
129
130
131
132
#***************************************************************************
# Copyright: Matthias Schmieder,
# E-Mail: schmieder.matthias@gmail.com
# Year: 2016
#***************************************************************************
cmake_minimum_required(VERSION 3.0.0)
# 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")
set(MINIZIP_SRC "crypt.c"
"ioapi.c"
"ioapi_buf.c"
"ioapi_mem.c"
"minishared.c"
"tmzip.c"
"unzip.c"
"zip.c")
set(MINIZIP_PUBLIC_HEADERS "crypt.h"
"ioapi.h"
"ioapi_buf.h"
"ioapi_mem.h"
"minishared.h"
"tmzip.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")
add_definitions(-D__USE_FILE_OFFSET64)
add_definitions(-D__USE_LARGEFILE64)
add_definitions(-D_LARGEFILE64_SOURCE)
add_definitions(-D_FILE_OFFSET_BIT=64)
endif()
if(CMAKE_C_COMPILER MATCHES ".*clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3 -msse4.1 -maes")
endif()
# create minizip library
add_library(minizip ${MINIZIP_SRC} ${MINIZIP_PUBLIC_HEADERS})
set_property(TARGET minizip PROPERTY POSITION_INDEPENDENT_CODE ON)
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/aes_ni.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_ni.h
aes/aesopt.h
aes/aestab.h
aes/brg_endian.h
aes/brg_types.h
aes/fileenc.h
aes/hmac.h
aes/prng.h
aes/pwd2key.h
aes/sha1.h)
add_library(aes ${AES_SRC} ${AES_PUBLIC_HEADERS})
set_property(TARGET aes PROPERTY POSITION_INDEPENDENT_CODE ON)
set_target_properties(aes minizip
PROPERTIES
COMPILE_DEFINITIONS "O -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()
# Looking for zlib.h
include_directories("../zlib-ng/build/")
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()