]> git.lyx.org Git - lyx.git/blob - development/cmake/modules/FindZLIB.cmake
Cmake build: Add combo-values to the list of displayed lyx options
[lyx.git] / development / cmake / modules / FindZLIB.cmake
1 #
2 #  based on cmake file
3 #
4
5 set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
6
7 if (ZLIB_INCLUDE_DIR)
8   # Already in cache, be silent
9   set(ZLIB_FIND_QUIETLY TRUE)
10 endif()
11
12 set(zlibsearch "/usr/include" "/usr/local/include")
13 if (GNUWIN32_DIR)
14   list(APPEND zlibsearch "${GNUWIN32_DIR}/include")
15 endif()
16
17 find_path(ZLIB_INCLUDE_DIR zlib.h PATHS ${zlibsearch})
18
19 find_file(ZLIB_HEADER zlib.h
20         PATHS ${ZLIB_INCLUDE_DIR} NO_DEFAULT_PATH)
21         
22 set(POTENTIAL_Z_LIBS z zlib zdll)
23
24 find_library(ZLIB_LIBRARY NAMES ${POTENTIAL_Z_LIBS}
25         PATHS
26         ${ICONV_RELATIVE_TO_LIBINTL}
27         NO_DEFAULT_PATH)
28         
29
30 set(zlibsearch "C:\\Programme\\Microsoft Visual Studio 8\\VC\\lib")
31 if(SYSTEM_LIB_DIRS)
32   list(APPEND zlibsearch ${SYSTEM_LIB_DIRS})
33 endif()
34 if(GNUWIN32_DIR)
35   list(APPEND zlibsearch "${GNUWIN32_DIR}/lib")
36 endif()
37 find_library(ZLIB_LIBRARY NAMES ${POTENTIAL_Z_LIBS}
38         PATHS ${zlibsearch})
39
40 if(ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
41    set(ZLIB_FOUND TRUE)
42 endif()
43
44 if(ZLIB_FOUND)
45    if(NOT ZLIB_FIND_QUIETLY)
46       message(STATUS "Found Z: ${ZLIB_LIBRARY}")
47    endif()
48 else()
49    if(ZLIB_FIND_REQUIRED)
50       message(STATUS "Looked for Z libraries named ${POTENTIAL_Z_LIBS}.")
51       message(STATUS "Found no acceptable Z library. This is fatal.")
52       message(FATAL_ERROR "Could NOT find z library, set GNUWIN32_DIR to dir containing /include and /bin folders: -DGNUWIN32_DIR=...")
53    endif()
54 endif()
55
56 mark_as_advanced(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)