forked from VincentWei/MiniGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFindZLIB.cmake
39 lines (35 loc) · 1.76 KB
/
FindZLIB.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
# - This module determines the zlib library of the system
# The following variables are set if the library found:
# ZLIB_FOUND - If false do nnt try to use zlib.
# ZLIB_INCLUDE_DIR - where to find the headfile of library.
# ZLIB_LIBRARY_DIR - where to find the zlib library.
# ZLIB_LIBRARY - the library needed to use zlib.
# find the headfile of library
set (ZLIB_HEADS zlib.h)
find_path (ZLIB_INCLUDE_DIR ${ZLIB_HEADS})
set (ZLIB_NAMES z zlib libz zdll)
find_library (ZLIB_LIBRARY NAMES ${ZLIB_NAMES})
# just find one of dependency, guess other one.
if (NOT ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR)
message ("We just find the headfile, try to guess the library location.")
set (ZLIB_LIBRARY_DIR "${ZLIB_INCLUDE_DIR}/../lib")
find_library (ZLIB_LIBRARY NAMES ${ZLIB_NAMES} PATHS ${ZLIB_LIBRARY_DIR})
elseif (NOT ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
message ("We just find the lib file, try to guess the include location.")
string (REGEX REPLACE "[a-z|A-Z|0-9|_|-]+[.].*$" "" ZLIB_LIBRARY_DIR ${ZLIB_LIBRARY})
find_path (ZLIB_INCLUDE_DIR ${ZLIB_HEADS} "${ZLIB_LIBRARY_DIR}../included")
endif()
# find the library.
if (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
set (ZLIB_FOUND TRUE)
if (NOT ZLIB_LIBRARY_DIR)
string (REGEX REPLACE "[a-z|A-Z|0-9|_|-]+[.].*$" "" ZLIB_LIBRARY_DIR ${ZLIB_LIBRARY})
endif ()
string (REGEX MATCH "[a-z|A-Z|0-9|_|-]+[.](a|so|lib|dll|LIB|DLL)[^/]*$" ZLIB_LIBRARY_WHOLE_NAME "${ZLIB_LIBRARY}")
string (REGEX MATCH "[^(lib)][a-z|A-Z|0-9|_|-]*" ZLIB_LIBRARY_NAME ${ZLIB_LIBRARY_WHOLE_NAME})
message (STATUS "Find ZLIB include in ${ZLIB_INCLUDE_DIR}")
message (STATUS "Find ZLIB library in ${ZLIB_LIBRARY}")
else ()
#set (ZLIB_FOUND FALSE)
message (STATUS "Could NOT find ZLIB, (missing: ZLIB_INCLUDE_DIR ZLIB_LIBRARY)")
endif ()