forked from google/or-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZLIB.patch
210 lines (196 loc) · 7.49 KB
/
ZLIB.patch
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0fe939d..5f25cce 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,24 +1,23 @@
-cmake_minimum_required(VERSION 2.4.4)
-set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
+cmake_minimum_required(VERSION 2.8.12)
+cmake_policy(SET CMP0048 NEW)
+project(zlib VERSION 1.2.11.1 LANGUAGES C)
-project(zlib C)
+option(ASM686 "Enable building i686 assembly implementation" OFF)
+option(AMD64 "Enable building amd64 assembly implementation" OFF)
-set(VERSION "1.2.11")
+include(GNUInstallDirs)
+set(INSTALL_BIN_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "Installation directory for executables")
+set(INSTALL_LIB_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation directory for libraries")
+set(INSTALL_INC_DIR "${CMAKE_INSTALL_INCLUDEDIR}" CACHE PATH "Installation directory for headers")
-option(ASM686 "Enable building i686 assembly implementation")
-option(AMD64 "Enable building amd64 assembly implementation")
-
-set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
-set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
-set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
-set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
-set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
+set(INSTALL_MAN_DIR "${CMAKE_INSTALL_MANDIR}" CACHE PATH "Installation directory for manual pages")
+set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_DATADIR}/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
-enable_testing()
+include(CTest)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(stdint.h HAVE_STDINT_H)
@@ -63,7 +62,6 @@ if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
- include_directories(${CMAKE_CURRENT_SOURCE_DIR})
endif()
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
@@ -83,7 +81,6 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
${ZLIB_PC} @ONLY)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
-include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
#============================================================================
@@ -132,9 +129,9 @@ endif()
if(CMAKE_COMPILER_IS_GNUCC)
if(ASM686)
set(ZLIB_ASMS contrib/asm686/match.S)
- elseif (AMD64)
+ elseif(AMD64)
set(ZLIB_ASMS contrib/amd64/amd64-match.S)
- endif ()
+ endif()
if(ZLIB_ASMS)
add_definitions(-DASMV)
@@ -143,20 +140,20 @@ if(CMAKE_COMPILER_IS_GNUCC)
endif()
if(MSVC)
- if(ASM686)
+ if(ASM686)
ENABLE_LANGUAGE(ASM_MASM)
- set(ZLIB_ASMS
+ set(ZLIB_ASMS
contrib/masmx86/inffas32.asm
contrib/masmx86/match686.asm
- )
- elseif (AMD64)
+ )
+ elseif(AMD64)
ENABLE_LANGUAGE(ASM_MASM)
- set(ZLIB_ASMS
+ set(ZLIB_ASMS
contrib/masmx64/gvmat64.asm
contrib/masmx64/inffasx64.asm
- )
- endif()
-
+ )
+ # set(ZLIB_SRCS ${ZLIB_SRCS} contrib/masmx64/inffas8664.c)
+ endif()
if(ZLIB_ASMS)
add_definitions(-DASMV -DASMINF)
endif()
@@ -184,9 +181,25 @@ if(MINGW)
endif(MINGW)
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
+target_include_directories(zlib PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ $<INSTALL_INTERFACE:include>)
+set_target_properties(zlib PROPERTIES
+ DEFINE_SYMBOL ZLIB_DLL
+ SOVERSION 1)
+
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
-set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
-set_target_properties(zlib PROPERTIES SOVERSION 1)
+target_include_directories(zlibstatic PUBLIC
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ $<INSTALL_INTERFACE:include>)
+
+if(BUILD_SHARED_LIBS)
+ add_library(ZLIB::ZLIB ALIAS zlib)
+else()
+ add_library(ZLIB::ZLIB ALIAS zlibstatic)
+endif()
if(NOT CYGWIN)
# This property causes shared libraries on Linux to have the full version
@@ -197,6 +210,7 @@ if(NOT CYGWIN)
# This has no effect with MSVC, on that platform the version info for
# the DLL comes from the resource file win32/zlib1.rc
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
+ set_target_properties(zlibstatic PROPERTIES VERSION ${ZLIB_FULL_VERSION})
endif()
if(UNIX)
@@ -210,12 +224,30 @@ elseif(BUILD_SHARED_LIBS AND WIN32)
set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
endif()
-if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
+#if(WIN32)
+# add_definitions(-DZLIB_WINAPI)
+#endif()
+
+if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
install(TARGETS zlib zlibstatic
- RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
- ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
- LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
-endif()
+ EXPORT ZLIBTargets
+ RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
+ LIBRARY DESTINATION "${INSTALL_LIB_DIR}")
+ install(EXPORT ZLIBTargets
+ NAMESPACE ZLIB::
+ DESTINATION lib/cmake/ZLIB)
+ include(CMakePackageConfigHelpers)
+ write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/ZLIBConfigVersion.cmake"
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY SameMajorVersion)
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ZLIBConfig.cmake"
+ "include(\"\${CMAKE_CURRENT_LIST_DIR}/ZLIBTargets.cmake\")"
+ )
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ZLIBConfig.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/ZLIBConfigVersion.cmake"
+ DESTINATION lib/cmake/ZLIB)
+ endif()
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")
endif()
@@ -229,21 +261,22 @@ endif()
#============================================================================
# Example binaries
#============================================================================
-
-add_executable(example test/example.c)
-target_link_libraries(example zlib)
-add_test(example example)
-
-add_executable(minigzip test/minigzip.c)
-target_link_libraries(minigzip zlib)
-
-if(HAVE_OFF64_T)
- add_executable(example64 test/example.c)
- target_link_libraries(example64 zlib)
- set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
- add_test(example64 example64)
-
- add_executable(minigzip64 test/minigzip.c)
- target_link_libraries(minigzip64 zlib)
- set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
+if(BUILD_TESTING)
+ add_executable(example test/example.c)
+ target_link_libraries(example zlib)
+ add_test(example example)
+
+ add_executable(minigzip test/minigzip.c)
+ target_link_libraries(minigzip zlib)
+
+ if(HAVE_OFF64_T)
+ add_executable(example64 test/example.c)
+ target_link_libraries(example64 zlib)
+ set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
+ add_test(example64 example64)
+
+ add_executable(minigzip64 test/minigzip.c)
+ target_link_libraries(minigzip64 zlib)
+ set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
+ endif()
endif()