forked from Mudlet/Mudlet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindZIP.cmake
99 lines (88 loc) · 2.84 KB
/
FindZIP.cmake
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
# Locate ZIP library
# This module defines
# ZIP_FOUND, if false, do not try to link to ZIP
# ZIP_LIBRARIES
# ZIP_INCLUDE_DIR, where to find zip*.h
find_package(PkgConfig)
pkg_search_module(PC_ZIP zip libzip)
find_path(
ZIP_INCLUDE_DIR zip.h
HINTS ${ZIP_DIR} $ENV{ZIP_DIR} ${PC_ZIP_INCLUDE_DIRS}
PATH_SUFFIXES include
PATHS ~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw # Fink
/opt/local # DarwinPorts
/opt/csw # Blastwave
/opt)
find_library(
ZIP_LIBRARY_RELEASE
NAMES zip zip_s
HINTS ${ZIP_DIR} $ENV{ZIP_DIR} ${PC_ZIP_LIBRARY_DIRS} ${PC_ZIP_LIBRARY_DIR}
PATH_SUFFIXES lib64 lib
PATHS ~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt)
find_library(
ZIP_LIBRARY_DEBUG
NAMES zipd zip_sd
HINTS ${ZIP_DIR} $ENV{ZIP_DIR} ${PC_ZIP_LIBRARY_DIRS} ${PC_ZIP_LIBRARY_DIR}
PATH_SUFFIXES lib64 lib
PATHS ~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt)
if(ZIP_LIBRARY_DEBUG AND ZIP_LIBRARY_RELEASE)
set(ZIP_LIBRARY optimized ${ZIP_LIBRARY_RELEASE} debug ${ZIP_LIBRARY_DEBUG})
get_filename_component(ZIP_FILENAME ${ZIP_LIBRARY_RELEASE} NAME)
elseif(ZIP_LIBRARY_RELEASE)
set(ZIP_LIBRARY ${ZIP_LIBRARY_RELEASE})
get_filename_component(ZIP_FILENAME ${ZIP_LIBRARY_RELEASE} NAME)
elseif(ZIP_LIBRARY_DEBUG)
set(ZIP_LIBRARY ${ZIP_LIBRARY_DEBUG})
get_filename_component(ZIP_FILENAME ${ZIP_LIBRARY_DEBUG} NAME)
endif()
if(PC_ZIP_zip_FOUND)
set(ZIP_VERSION ${PC_ZIP_zip_VERSION})
elseif(PC_ZIP_libzip_FOUND)
set(ZIP_VERSION ${PC_ZIP_libzip_VERSION})
else()
set(ZIP_VERSION ${PC_ZIP_VERSION})
endif()
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set ZIP_FOUND to TRUE if all
# listed variables are TRUE
find_package_handle_standard_args(ZIP REQUIRED_VARS ZIP_LIBRARY ZIP_INCLUDE_DIR
VERSION_VAR ZIP_VERSION)
string(FIND ${ZIP_FILENAME} zip_s ZIP_STATIC)
if(ZIP_STATIC EQUAL -1)
string(FIND ${ZIP_FILENAME} .a ZIP_STATIC)
endif()
mark_as_advanced(ZIP_INCLUDE_DIR ZIP_LIBRARY ZIP_LIBRARY_RELEASE
ZIP_LIBRARY_DEBUG)
if(ZIP_FOUND AND NOT TARGET ZIP::ZIP)
if(ZIP_STATIC EQUAL -1)
add_library(ZIP::ZIP SHARED IMPORTED)
set_target_properties(
ZIP::ZIP
PROPERTIES INTERFACE_COMPILE_DEFINITIONS ZIP_EXTERN= IMPORTED_LOCATION
"${ZIP_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${ZIP_INCLUDE_DIR}")
else()
add_library(ZIP::ZIP STATIC IMPORTED)
set_target_properties(
ZIP::ZIP PROPERTIES IMPORTED_LOCATION "${ZIP_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${ZIP_INCLUDE_DIR}")
endif()
endif()