-
Notifications
You must be signed in to change notification settings - Fork 22
/
CMakeLists.txt
94 lines (77 loc) · 2.14 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
cmake_minimum_required(VERSION 3.12)
project(elzip)
cmake_policy(SET CMP0077 NEW)
option(ELZIP_EXCLUDE_MINIZIP "Use this to exclude internal minizip copy." OFF)
option(ELZIP_TESTS "includes tests for 11Zip." OFF)
option(ELZIP_DECOMPRESS_ONLY "Only support decompression" OFF)
if(NOT ELZIP_EXCLUDE_MINIZIP)
set(MZ_BZIP2 OFF)
set(MZ_ICONV OFF)
set(MZ_LZMA OFF)
set(MZ_SIGNING OFF)
set(MZ_ZSTD OFF)
set(MZ_FETCH_LIBS ON)
# Enabling MZ_COMPAT
set(MZ_COMPAT ON)
if (ELZIP_DECOMPRESS_ONLY)
set(MZ_LIBCOMP OFF)
set(MZ_PKCRYPT OFF)
set(MZ_WZAES OFF)
set(MZ_OPENSSL OFF)
set(MZ_LIBBSD OFF)
set(MZ_PKCRYPT OFF)
set(MZ_WZAES OFF)
set(MZ_DECOMPRESS_ONLY ON)
else()
set(MZ_PKCRYPT ON)
set(MZ_WZAES ON)
endif()
add_subdirectory(extlibs/minizip EXCLUDE_FROM_ALL)
endif()
list(FIND "${CMAKE_CXX_COMPILE_FEATURES}" "cxx_std_17" __hascxx17)
if ("${__hascxx17}" STREQUAL "-1")
set(HAS_FILESYSTEM ON)
else()
set(HAS_FILESYSTEM NO)
endif()
file(GLOB LZIP_HEADERS include/elzip/*.hpp)
if (NOT HAS_FILESYSTEM)
set(ELZIP_CPP src/elzip_fs_fallback.cpp)
else()
set(ELZIP_CPP src/elzip.cpp)
endif()
file(GLOB LZIP_SOURCES
${ELZIP_CPP}
src/unzipper.cpp
src/zipper.cpp
)
add_library(elzip ${LZIP_HEADERS} ${LZIP_SOURCES})
target_link_libraries(elzip minizip)
if (NOT HAS_FILESYSTEM)
target_link_libraries(elzip tinydir)
elseif (CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(elzip stdc++fs)
endif()
if (HAS_FILESYSTEM)
target_compile_features(elzip PUBLIC
cxx_std_17 # Require at least c++17
)
else()
target_compile_features(elzip PUBLIC
cxx_std_11 # Require at least c++11
)
endif()
target_include_directories(elzip
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/elzip>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/extlibs>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
if(ELZIP_TESTS)
set(BUILD_TESTING ON)
include(CTest)
add_subdirectory(tests)
endif()