summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt58
1 files changed, 35 insertions, 23 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 19deaa5..5ce81be 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,7 +21,6 @@ check_include_file(stddef.h HAVE_STDDEF_H)
21# Check to see if we have large file support 21# Check to see if we have large file support
22# 22#
23set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE) 23set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE)
24
25# We add these other definitions here because CheckTypeSize.cmake 24# We add these other definitions here because CheckTypeSize.cmake
26# in CMake 2.4.x does not automatically do so and we want 25# in CMake 2.4.x does not automatically do so and we want
27# compatibility with CMake 2.4.x. 26# compatibility with CMake 2.4.x.
@@ -34,9 +33,7 @@ endif()
34if(HAVE_STDDEF_H) 33if(HAVE_STDDEF_H)
35 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) 34 list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
36endif() 35endif()
37
38check_type_size(off64_t OFF64_T) 36check_type_size(off64_t OFF64_T)
39
40if(HAVE_OFF64_T) 37if(HAVE_OFF64_T)
41 add_definitions(-D_LARGEFILE64_SOURCE) 38 add_definitions(-D_LARGEFILE64_SOURCE)
42endif() 39endif()
@@ -63,23 +60,6 @@ if(NOT HAVE_ERRNO_H)
63endif() 60endif()
64 61
65# 62#
66# Check for mmap support
67#
68set(mmap_test_code "
69#include <sys/types.h>
70#include <sys/mman.h>
71#include <sys/stat.h>
72caddr_t hello() {
73 return mmap((caddr_t)0, (off_t)0, PROT_READ, MAP_SHARED, 0, (off_t)0);
74}
75int main() { return 0; }
76")
77check_c_source_compiles("${mmap_test_code}" USE_MMAP)
78if(USE_MMAP)
79 add_definitions(-DUSE_MMAP)
80endif()
81
82#
83# Create the zlibdefs.h file. 63# Create the zlibdefs.h file.
84# Note: we create it in CMAKE_CURRENT_SOURCE_DIR instead 64# Note: we create it in CMAKE_CURRENT_SOURCE_DIR instead
85# of CMAKE_CURRENT_BINARY_DIR because an empty zlibdefs.h 65# of CMAKE_CURRENT_BINARY_DIR because an empty zlibdefs.h
@@ -88,7 +68,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlibdefs.h.cmakein
88 ${CMAKE_CURRENT_SOURCE_DIR}/zlibdefs.h) 68 ${CMAKE_CURRENT_SOURCE_DIR}/zlibdefs.h)
89 69
90if(MSVC) 70if(MSVC)
91 set(CMAKE_DEBUG_POSTFIX "D") 71 set(CMAKE_DEBUG_POSTFIX "d")
92 add_definitions(-D_CRT_SECURE_NO_DEPRECATE) 72 add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
93 add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) 73 add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
94endif() 74endif()
@@ -130,15 +110,47 @@ set(ZLIB_SRCS
130 trees.c 110 trees.c
131 uncompr.c 111 uncompr.c
132 zutil.c 112 zutil.c
113 win32/zlib1.rc
133) 114)
134 115
116# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
117file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
118string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([0-9A-Za-z.]+)\".*"
119 "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
120
121if(MINGW)
122 # This gets us DLL resource information when compiling on MinGW.
123 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
124 COMMAND windres.exe
125 -D GCC_WINDRES
126 -I ${CMAKE_CURRENT_SOURCE_DIR}
127 -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
128 -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
129 set(ZLIB_SRCS ${ZLIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
130endif(MINGW)
131
135add_library(zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) 132add_library(zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
136set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) 133set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
137set_target_properties(zlib PROPERTIES VERSION 1.2.3.4) 134
138set_target_properties(zlib PROPERTIES SOVERSION 1) 135set_target_properties(zlib PROPERTIES SOVERSION 1)
136
137if(NOT CYGWIN)
138 # This property causes shared libraries on Linux to have the full version
139 # encoded into their final filename. We disable this on Cygwin because
140 # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
141 # seems to be the default.
142 #
143 # This has no effect with MSVC, on that platform the version info for
144 # the DLL comes from the resource file win32/zlib1.rc
145 set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
146endif()
147
139if(UNIX) 148if(UNIX)
140 # On unix like platforms the library is almost always called libz 149 # On unix-like platforms the library is almost always called libz
141 set_target_properties(zlib PROPERTIES OUTPUT_NAME z) 150 set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
151elseif(BUILD_SHARED_LIBS AND WIN32)
152 # Creates zlib1.dll when building shared library version
153 set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
142endif() 154endif()
143 155
144if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) 156if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )