@cpp.js/package-zlib 1.0.0-beta.25 → 1.0.0-beta.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,236 @@
1
+ cmake_minimum_required(VERSION 2.4.4...3.15.0)
2
+ set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
3
+
4
+ project(zlib C)
5
+
6
+ set(VERSION "1.3.1")
7
+
8
+ option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
9
+
10
+ set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
11
+ set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
12
+ set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
13
+ set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
14
+ set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
15
+
16
+ include(CheckTypeSize)
17
+ include(CheckFunctionExists)
18
+ include(CheckIncludeFile)
19
+ include(CheckCSourceCompiles)
20
+ enable_testing()
21
+
22
+ check_include_file(sys/types.h HAVE_SYS_TYPES_H)
23
+ check_include_file(stdint.h HAVE_STDINT_H)
24
+ check_include_file(stddef.h HAVE_STDDEF_H)
25
+
26
+ #
27
+ # Check to see if we have large file support
28
+ #
29
+ set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
30
+ # We add these other definitions here because CheckTypeSize.cmake
31
+ # in CMake 2.4.x does not automatically do so and we want
32
+ # compatibility with CMake 2.4.x.
33
+ if(HAVE_SYS_TYPES_H)
34
+ list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
35
+ endif()
36
+ if(HAVE_STDINT_H)
37
+ list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
38
+ endif()
39
+ if(HAVE_STDDEF_H)
40
+ list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
41
+ endif()
42
+ check_type_size(off64_t OFF64_T)
43
+ if(HAVE_OFF64_T)
44
+ add_definitions(-D_LARGEFILE64_SOURCE=1)
45
+ endif()
46
+ set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
47
+
48
+ #
49
+ # Check for fseeko
50
+ #
51
+ check_function_exists(fseeko HAVE_FSEEKO)
52
+ if(NOT HAVE_FSEEKO)
53
+ add_definitions(-DNO_FSEEKO)
54
+ endif()
55
+
56
+ #
57
+ # Check for unistd.h
58
+ #
59
+ check_include_file(unistd.h Z_HAVE_UNISTD_H)
60
+
61
+ if(MSVC)
62
+ set(CMAKE_DEBUG_POSTFIX "d")
63
+ add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
64
+ add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
65
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR})
66
+ endif()
67
+
68
+ if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
69
+ # If we're doing an out of source build and the user has a zconf.h
70
+ # in their source tree...
71
+ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
72
+ message(STATUS "Renaming")
73
+ message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
74
+ message(STATUS "to 'zconf.h.included' because this file is included with zlib")
75
+ message(STATUS "but CMake generates it automatically in the build directory.")
76
+ file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
77
+ endif()
78
+ endif()
79
+
80
+ set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
81
+ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
82
+ ${ZLIB_PC} @ONLY)
83
+ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
84
+ ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
85
+ include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
86
+
87
+
88
+ #============================================================================
89
+ # zlib
90
+ #============================================================================
91
+
92
+ set(ZLIB_PUBLIC_HDRS
93
+ ${CMAKE_CURRENT_BINARY_DIR}/zconf.h
94
+ zlib.h
95
+ )
96
+ set(ZLIB_PRIVATE_HDRS
97
+ crc32.h
98
+ deflate.h
99
+ gzguts.h
100
+ inffast.h
101
+ inffixed.h
102
+ inflate.h
103
+ inftrees.h
104
+ trees.h
105
+ zutil.h
106
+ )
107
+ set(ZLIB_SRCS
108
+ adler32.c
109
+ compress.c
110
+ crc32.c
111
+ deflate.c
112
+ gzclose.c
113
+ gzlib.c
114
+ gzread.c
115
+ gzwrite.c
116
+ inflate.c
117
+ infback.c
118
+ inftrees.c
119
+ inffast.c
120
+ trees.c
121
+ uncompr.c
122
+ zutil.c
123
+ )
124
+
125
+ if(NOT MINGW)
126
+ set(ZLIB_DLL_SRCS
127
+ win32/zlib1.rc # If present will override custom build rule below.
128
+ )
129
+ endif()
130
+
131
+ # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
132
+ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
133
+ string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
134
+ "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
135
+
136
+ if(MINGW)
137
+ # This gets us DLL resource information when compiling on MinGW.
138
+ if(NOT CMAKE_RC_COMPILER)
139
+ set(CMAKE_RC_COMPILER windres.exe)
140
+ endif()
141
+
142
+ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
143
+ COMMAND ${CMAKE_RC_COMPILER}
144
+ -D GCC_WINDRES
145
+ -I ${CMAKE_CURRENT_SOURCE_DIR}
146
+ -I ${CMAKE_CURRENT_BINARY_DIR}
147
+ -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
148
+ -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
149
+ set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
150
+ endif(MINGW)
151
+
152
+ add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
153
+ target_include_directories(zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
154
+ add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
155
+ target_include_directories(zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
156
+ set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
157
+ set_target_properties(zlib PROPERTIES SOVERSION 1)
158
+
159
+ if(NOT CYGWIN)
160
+ # This property causes shared libraries on Linux to have the full version
161
+ # encoded into their final filename. We disable this on Cygwin because
162
+ # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
163
+ # seems to be the default.
164
+ #
165
+ # This has no effect with MSVC, on that platform the version info for
166
+ # the DLL comes from the resource file win32/zlib1.rc
167
+ set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
168
+ endif()
169
+
170
+ if(UNIX)
171
+ # On unix-like platforms the library is almost always called libz
172
+ message("aaaa")
173
+ message("${BUILD_TYPE}")
174
+ if (BUILD_TYPE STREQUAL "SHARED")
175
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z)
176
+ set_target_properties(zlibstatic PROPERTIES OUTPUT_NAME z2)
177
+ elseif(BUILD_TYPE STREQUAL "STATIC")
178
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME z2)
179
+ set_target_properties(zlibstatic PROPERTIES OUTPUT_NAME z)
180
+ else()
181
+ set_target_properties(zlib PROPERTIES OUTPUT_NAME a)
182
+ set_target_properties(zlibstatic PROPERTIES OUTPUT_NAME b)
183
+ endif()
184
+ if(NOT APPLE AND NOT(CMAKE_SYSTEM_NAME STREQUAL AIX))
185
+ set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
186
+ endif()
187
+ elseif(BUILD_SHARED_LIBS AND WIN32)
188
+ # Creates zlib1.dll when building shared library version
189
+ set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
190
+ endif()
191
+
192
+ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
193
+ if (BUILD_TYPE STREQUAL "SHARED")
194
+ install(TARGETS zlib
195
+ RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
196
+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
197
+ LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
198
+ elseif(BUILD_TYPE STREQUAL "STATIC")
199
+ install(TARGETS zlibstatic
200
+ RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
201
+ ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
202
+ LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
203
+ endif()
204
+ endif()
205
+ if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
206
+ install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")
207
+ endif()
208
+ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
209
+ install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3")
210
+ endif()
211
+ if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
212
+ install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
213
+ endif()
214
+
215
+ #============================================================================
216
+ # Example binaries
217
+ #============================================================================
218
+ if(ZLIB_BUILD_EXAMPLES)
219
+ add_executable(example test/example.c)
220
+ target_link_libraries(example zlib)
221
+ add_test(example example)
222
+
223
+ add_executable(minigzip test/minigzip.c)
224
+ target_link_libraries(minigzip zlib)
225
+
226
+ if(HAVE_OFF64_T)
227
+ add_executable(example64 test/example.c)
228
+ target_link_libraries(example64 zlib)
229
+ set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
230
+ add_test(example64 example64)
231
+
232
+ add_executable(minigzip64 test/minigzip.c)
233
+ target_link_libraries(minigzip64 zlib)
234
+ set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
235
+ endif()
236
+ endif()
package/cppjs.build.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export default {
2
2
  getURL: (version) => `https://zlib.net/zlib-${version}.tar.gz`,
3
+ copyToSource: { 'assets/CMakeLists.txt': 'CMakeLists.txt' },
3
4
  buildType: 'cmake',
4
5
  getBuildParams: () => ['-DZLIB_BUILD_EXAMPLES=OFF'],
5
6
  };
@@ -10,19 +10,16 @@
10
10
  <key>HeadersPath</key>
11
11
  <string>Headers</string>
12
12
  <key>LibraryIdentifier</key>
13
- <string>ios-arm64_arm64e_x86_64-simulator</string>
13
+ <string>ios-arm64_arm64e</string>
14
14
  <key>LibraryPath</key>
15
15
  <string>libz.a</string>
16
16
  <key>SupportedArchitectures</key>
17
17
  <array>
18
18
  <string>arm64</string>
19
19
  <string>arm64e</string>
20
- <string>x86_64</string>
21
20
  </array>
22
21
  <key>SupportedPlatform</key>
23
22
  <string>ios</string>
24
- <key>SupportedPlatformVariant</key>
25
- <string>simulator</string>
26
23
  </dict>
27
24
  <dict>
28
25
  <key>BinaryPath</key>
@@ -30,16 +27,19 @@
30
27
  <key>HeadersPath</key>
31
28
  <string>Headers</string>
32
29
  <key>LibraryIdentifier</key>
33
- <string>ios-arm64_arm64e</string>
30
+ <string>ios-arm64_arm64e_x86_64-simulator</string>
34
31
  <key>LibraryPath</key>
35
32
  <string>libz.a</string>
36
33
  <key>SupportedArchitectures</key>
37
34
  <array>
38
35
  <string>arm64</string>
39
36
  <string>arm64e</string>
37
+ <string>x86_64</string>
40
38
  </array>
41
39
  <key>SupportedPlatform</key>
42
40
  <string>ios</string>
41
+ <key>SupportedPlatformVariant</key>
42
+ <string>simulator</string>
43
43
  </dict>
44
44
  </array>
45
45
  <key>CFBundlePackageType</key>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpp.js/package-zlib",
3
- "version": "1.0.0-beta.25",
3
+ "version": "1.0.0-beta.26",
4
4
  "nativeVersion": "1.3.1",
5
5
  "description": "This package provides the precompiled zlib library, built using cpp.js, for easy integration into JavaScript, WebAssembly and React Native projects. It offers compression and decompression functionalities through the zlib API, ensuring high performance and cross-platform compatibility. Ideal for use in web and mobile applications.",
6
6
  "homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-package-zlib#readme",