forked from hunter-packages/minizip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
140 lines (112 loc) · 3.33 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
133
134
135
136
137
138
139
140
#***************************************************************************
# 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()
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/ruslo/hunter/archive/v0.14.26.tar.gz"
SHA1 "45ac03944db2bc7fc55dfceca42d89ec7fa1dca2"
)
project("minizip")
hunter_add_package(ZLIB)
find_package(ZLIB CONFIG REQUIRED)
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")
endif()
# create minizip library
add_library(minizip ${MINIZIP_SRC} ${MINIZIP_PUBLIC_HEADERS})
target_link_libraries(minizip PUBLIC ZLIB::zlib)
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated")
set(config_install_dir "lib/cmake/${PROJECT_NAME}")
# Configuration
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
set(targets_export_name "${PROJECT_NAME}Targets")
set(namespace "${PROJECT_NAME}::")
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})
target_compile_definitions(aes PUBLIC "HAVE_AES")
target_link_libraries(minizip PUBLIC aes)
install(
TARGETS aes
EXPORT "${targets_export_name}"
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 "${targets_export_name}"
INCLUDES DESTINATION "include"
RUNTIME DESTINATION "bin"
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib"
)
install(EXPORT "${targets_export_name}"
DESTINATION "${config_install_dir}"
NAMESPACE "${namespace}")
include(CMakePackageConfigHelpers)
configure_package_config_file(
"cmake/Config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${config_install_dir}"
)
install(FILES "${project_config}" DESTINATION "${config_install_dir}")
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()