@@ -33,11 +33,11 @@ set(PACKAGE "libplzma")
33
33
set (CPACK_PACKAGE_NAME "${PACKAGE} " )
34
34
set (CPACK_PACKAGE_VERSION_MAJOR "1" )
35
35
set (CPACK_PACKAGE_VERSION_MINOR "4" )
36
- set (CPACK_PACKAGE_VERSION_PATCH "4 " )
36
+ set (CPACK_PACKAGE_VERSION_PATCH "5 " )
37
37
set (CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR} .${CPACK_PACKAGE_VERSION_MINOR} " )
38
38
set (CPACK_PACKAGE_VENDOR "olehkulykov@gmail.com" )
39
39
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE} ${PACKAGE_VERSION} " )
40
- set (SOVERSION "1.4.4 " )
40
+ set (SOVERSION "1.4.5 " )
41
41
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME} -${CPACK_PACKAGE_VERSION} " )
42
42
set (VERSION "${CPACK_PACKAGE_VERSION} " )
43
43
@@ -97,26 +97,42 @@ More info: https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run
97
97
98
98
99
99
# ---- definitions ----
100
- if (WIN32 )
101
- message ("WIN32" )
102
- add_definitions (-DWIN32 )
103
- add_definitions (-D_WIN32 )
104
- add_definitions (-DUNICODE )
105
- add_definitions (-D_UNICODE )
100
+ if (WIN32 OR WIN64 )
101
+ add_definitions (-DUNICODE=1 )
102
+ add_definitions (-D_UNICODE=1 )
103
+
104
+ if (WIN64 OR CMAKE_SIZEOF_VOID_P EQUAL 8 )
105
+ message ("WIN 64" )
106
+ add_definitions (-DWIN64=1 )
107
+ add_definitions (-D_WIN64=1 )
108
+ elseif (WIN32 OR CMAKE_SIZEOF_VOID_P EQUAL 4 )
109
+ message ("WIN 32" )
110
+ add_definitions (-DWIN32=1 )
111
+ add_definitions (-D_WIN32=1 )
112
+ else ()
113
+ message ("WIN.. undefined" )
114
+ endif ()
115
+
116
+ endif ()
117
+
118
+ if (MINGW )
119
+ add_definitions (-DLIBPLZMA_MINGW=1 )
120
+ message ("MinGW" )
106
121
endif ()
107
122
108
- if (MSVC )
109
- message ("MSVC" )
110
- if (LIBPLZMA_OPT_MSVC_MULTITHREAD_STATIC )
111
- if (CMAKE_BUILD_TYPE MATCHES Debug )
123
+ if (MSVC )
124
+ # Run-Time Library
125
+ # https://learn.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library
126
+ if (LIBPLZMA_OPT_MSVC_MULTITHREAD_STATIC )
127
+ if (CMAKE_BUILD_TYPE MATCHES Debug )
112
128
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MTd" )
113
129
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MTd" )
114
130
else ()
115
131
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MT" )
116
132
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT" )
117
133
endif ()
118
134
else ()
119
- if (CMAKE_BUILD_TYPE MATCHES Debug )
135
+ if (CMAKE_BUILD_TYPE MATCHES Debug )
120
136
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MDd" )
121
137
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MDd" )
122
138
else ()
@@ -130,71 +146,80 @@ if(MSVC)
130
146
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8" )
131
147
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8" )
132
148
133
- if (LIBPLZMA_OPT_DISABLE_RUNTIME_TYPE_INFORMATION )
149
+ if (LIBPLZMA_OPT_DISABLE_RUNTIME_TYPE_INFORMATION )
134
150
# Disable Run-Time Type Information
151
+ # Defined as 1 if the /GR (Enable Run-Time Type Information) compiler option is set. Otherwise, undefined.
152
+ # When /GR is on, the compiler defines the _CPPRTTI preprocessor macro.
153
+ # By default, /GR is on. /GR- disables run-time type information.
154
+ # However, /GR increases the size of the .rdata sections of your image.
155
+ # If your code does not use dynamic_cast or typeid, /GR- may produce a smaller image.
156
+ # https://learn.microsoft.com/en-us/cpp/build/reference/gr-enable-run-time-type-information
135
157
# https://docs.microsoft.com/en-us/cpp/build/reference/gr-enable-run-time-type-information
136
158
# Check vs version: ?view=vs-2015
137
159
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GR-" )
138
160
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-" )
161
+ add_definitions (-DLIBPLZMA_NO_CPP_RTTI=1 )
139
162
endif ()
140
163
141
164
else ()
165
+
142
166
# C with -fPIC
143
167
check_c_compiler_flag ("-fPIC" WITH_FPIC_C )
144
- if (WITH_FPIC_C )
168
+ if (WITH_FPIC_C )
145
169
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC" )
146
170
endif ()
147
171
148
172
# CXX with -fPIC
149
173
check_cxx_compiler_flag ("-fPIC" WITH_FPIC_CXX )
150
- if (WITH_FPIC_CXX )
174
+ if (WITH_FPIC_CXX )
151
175
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" )
152
176
endif ()
153
177
154
- if (LIBPLZMA_OPT_DISABLE_RUNTIME_TYPE_INFORMATION )
178
+ if (LIBPLZMA_OPT_DISABLE_RUNTIME_TYPE_INFORMATION )
155
179
# CXX with -fno-rtti
156
180
check_cxx_compiler_flag ("-fno-rtti" WITH_FNO_RTTI_CXX )
157
- if (WITH_FNO_RTTI_CXX )
181
+ if (WITH_FNO_RTTI_CXX )
158
182
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti" )
159
183
add_definitions (-DLIBPLZMA_NO_CPP_RTTI=1 )
160
184
endif ()
161
185
endif ()
162
186
163
187
endif ()
164
188
165
- if (LIBPLZMA_OPT_TESTS )
189
+
190
+ if (LIBPLZMA_OPT_TESTS )
166
191
add_definitions (-DCMAKE_BUILD_WITH_TESTS=1 )
167
192
endif ()
168
193
169
- if (CMAKE_BUILD_TYPE MATCHES Debug )
194
+ if (CMAKE_BUILD_TYPE MATCHES Debug )
170
195
add_definitions (-DDEBUG=1 )
171
196
endif ()
172
197
173
- if (LIBPLZMA_OPT_BUILD_NUMBER )
198
+ if (LIBPLZMA_OPT_BUILD_NUMBER )
174
199
add_definitions (-DLIBPLZMA_VERSION_BUILD=${LIBPLZMA_OPT_BUILD_NUMBER} )
175
200
endif ()
176
201
177
- if (LIBPLZMA_OPT_NO_C_BINDINGS )
202
+ if (LIBPLZMA_OPT_NO_C_BINDINGS )
178
203
add_definitions (-DLIBPLZMA_NO_C_BINDINGS=1 )
179
204
endif ()
180
205
181
- if (LIBPLZMA_OPT_NO_CRYPTO )
206
+ if (LIBPLZMA_OPT_NO_CRYPTO )
182
207
add_definitions (-DLIBPLZMA_NO_CRYPTO=1 )
183
208
endif ()
184
209
185
- if (LIBPLZMA_OPT_HAVE_STD )
210
+ if (LIBPLZMA_OPT_HAVE_STD )
186
211
add_definitions (-DLIBPLZMA_HAVE_STD=1 )
187
212
endif ()
188
213
189
- if (LIBPLZMA_OPT_NO_TAR )
214
+ if (LIBPLZMA_OPT_NO_TAR )
190
215
add_definitions (-DLIBPLZMA_NO_TAR=1 )
191
216
endif ()
192
217
193
- if (LIBPLZMA_OPT_NO_PROGRESS )
218
+ if (LIBPLZMA_OPT_NO_PROGRESS )
194
219
add_definitions (-DLIBPLZMA_NO_PROGRESS=1 )
195
220
endif ()
196
221
197
- if (LIBPLZMA_OPT_THREAD_UNSAFE )
222
+ if (LIBPLZMA_OPT_THREAD_UNSAFE )
198
223
add_definitions (-DLIBPLZMA_THREAD_UNSAFE=1 )
199
224
endif ()
200
225
@@ -206,53 +231,77 @@ add_definitions(-DLIBPLZMA_BUILD=1)
206
231
set (THREADS_PREFER_PTHREAD_FLAG ON )
207
232
find_package (Threads REQUIRED )
208
233
209
- if (LIBPLZMA_OPT_ANDROID )
234
+ if (LIBPLZMA_OPT_ANDROID )
210
235
find_library (log -lib log )
211
236
endif ()
212
237
213
238
# ---- check include ----
214
239
CHECK_INCLUDE_FILE ("sys/types.h" LIBPLZMA_HAVE_SYS_TYPES_H )
215
- if (LIBPLZMA_HAVE_SYS_TYPES_H )
240
+ if (LIBPLZMA_HAVE_SYS_TYPES_H )
216
241
add_definitions (-DHAVE_SYS_TYPES_H=1 )
217
242
endif ()
243
+
218
244
CHECK_INCLUDE_FILE ("sys/sys_types.h" LIBPLZMA_HAVE_SYS_SYS_TYPES_H )
219
- if (LIBPLZMA_HAVE_SYS_SYS_TYPES_H )
245
+ if (LIBPLZMA_HAVE_SYS_SYS_TYPES_H )
220
246
add_definitions (-DHAVE_SYS_SYS_TYPES_H=1 )
221
247
endif ()
248
+
222
249
CHECK_INCLUDE_FILE ("sys/sysmacros.h" LIBPLZMA_HAVE_SYS_SYSMACROS_H )
223
- if (LIBPLZMA_HAVE_SYS_SYSMACROS_H )
250
+ if (LIBPLZMA_HAVE_SYS_SYSMACROS_H )
224
251
add_definitions (-DHAVE_SYS_SYSMACROS_H=1 )
225
252
endif ()
253
+
226
254
CHECK_INCLUDE_FILE ("sys/utime.h" LIBPLZMA_HAVE_SYS_UTIME_H )
227
- if (LIBPLZMA_HAVE_SYS_UTIME_H )
255
+ if (LIBPLZMA_HAVE_SYS_UTIME_H )
228
256
add_definitions (-DHAVE_SYS_UTIME_H=1 )
229
257
endif ()
258
+
230
259
CHECK_INCLUDE_FILE ("utime.h" LIBPLZMA_HAVE_UTIME_H )
231
- if (LIBPLZMA_HAVE_UTIME_H )
260
+ if (LIBPLZMA_HAVE_UTIME_H )
232
261
add_definitions (-DHAVE_UTIME_H=1 )
233
262
endif ()
234
263
264
+ CHECK_INCLUDE_FILE ("semaphore.h" LIBPLZMA_SEMAPHORE_H )
265
+ if (LIBPLZMA_SEMAPHORE_H )
266
+ add_definitions (-DHAVE_SEMAPHORE_H=1 )
267
+ endif ()
268
+
269
+ CHECK_INCLUDE_FILE ("unistd.h" LIBPLZMA_UNISTD_H )
270
+ if (LIBPLZMA_UNISTD_H )
271
+ add_definitions (-DHAVE_UNISTD_H=1 )
272
+ endif ()
273
+
274
+ CHECK_INCLUDE_FILE ("pthread.h" LIBPLZMA_PTHREAD_H )
275
+ if (LIBPLZMA_PTHREAD_H )
276
+ add_definitions (-DHAVE_PTHREAD_H=1 )
277
+ endif ()
278
+
279
+ CHECK_INCLUDE_FILE ("android/api-level.h" LIBPLZMA_ANDROID_API_LEVEL_H )
280
+ if (LIBPLZMA_ANDROID_API_LEVEL_H )
281
+ add_definitions (-DHAVE_ANDROID_API_LEVEL_H=1 )
282
+ endif ()
283
+
235
284
236
285
# ---- check functions ----
237
- if (MSVC )
286
+ if (MSVC )
238
287
check_symbol_exists (_wfopen_s "stdio.h" HAVE__WFOPEN_S )
239
- if (NOT HAVE__WFOPEN_S )
288
+ if (NOT HAVE__WFOPEN_S )
240
289
check_symbol_exists (_wfopen_s "wchar.h" HAVE__WFOPEN_S )
241
290
endif ()
242
- if (HAVE__WFOPEN_S )
291
+ if (HAVE__WFOPEN_S )
243
292
add_definitions (-DHAVE__WFOPEN_S=1 )
244
293
endif ()
245
294
246
295
check_symbol_exists (_wdupenv_s "stdlib.h" HAVE__WDUPENV_S )
247
- if (NOT HAVE__WDUPENV_S )
296
+ if (NOT HAVE__WDUPENV_S )
248
297
check_symbol_exists (_wdupenv_s "wchar.h" HAVE__WDUPENV_S )
249
298
endif ()
250
- if (HAVE__WDUPENV_S )
299
+ if (HAVE__WDUPENV_S )
251
300
add_definitions (-DHAVE__WDUPENV_S=1 )
252
301
endif ()
253
302
254
303
check_symbol_exists (_dupenv_s "stdlib.h" HAVE__DUPENV_S )
255
- if (HAVE__DUPENV_S )
304
+ if (HAVE__DUPENV_S )
256
305
add_definitions (-DHAVE__DUPENV_S=1 )
257
306
endif ()
258
307
endif (MSVC )
@@ -992,27 +1041,27 @@ source_group("CPP/7zip/Crypto"
992
1041
src/CPP/7zip/Crypto/StdAfx.h
993
1042
)
994
1043
995
- if (LIBPLZMA_OPT_SHARED )
1044
+ if (LIBPLZMA_OPT_SHARED )
996
1045
add_library (plzma SHARED ${LIBPLZMA_SOURCES} ${LIBPLZMA_PUBLIC_HEADERS} ${LIBPLZMA_INTERNAL_HEADERS} )
997
- set_property (TARGET plzma APPEND PROPERTY COMPILE_FLAGS -DLIBPLZMA_SHARED )
998
- if (MSVC )
1046
+ set_property (TARGET plzma APPEND PROPERTY COMPILE_FLAGS -DLIBPLZMA_SHARED=1 )
1047
+ if (MSVC )
999
1048
message ("Shared lib. MSVC" )
1000
1049
# MSVC does not append 'lib' - do it here to have consistent name
1001
1050
set_property (TARGET plzma PROPERTY PREFIX "lib" )
1002
1051
set_property (TARGET plzma PROPERTY IMPORT_PREFIX "lib" )
1003
1052
endif ()
1004
1053
target_link_libraries (plzma Threads::Threads )
1005
- if (LIBPLZMA_OPT_ANDROID )
1054
+ if (LIBPLZMA_OPT_ANDROID )
1006
1055
target_link_libraries (plzma android )
1007
1056
target_link_libraries (plzma ${log-lib} )
1008
1057
endif ()
1009
1058
install (TARGETS plzma DESTINATION lib )
1010
1059
endif ()
1011
1060
1012
- if (LIBPLZMA_OPT_STATIC )
1061
+ if (LIBPLZMA_OPT_STATIC )
1013
1062
add_library (plzma_static STATIC ${LIBPLZMA_SOURCES} ${LIBPLZMA_PUBLIC_HEADERS} ${LIBPLZMA_INTERNAL_HEADERS} )
1014
- set_property (TARGET plzma_static APPEND PROPERTY COMPILE_FLAGS -DLIBPLZMA_STATIC )
1015
- if (MSVC )
1063
+ set_property (TARGET plzma_static APPEND PROPERTY COMPILE_FLAGS -DLIBPLZMA_STATIC=1 )
1064
+ if (MSVC )
1016
1065
# MSVC does not append 'lib' - do it here to have consistent name
1017
1066
set_target_properties (plzma_static PROPERTIES PREFIX "lib" )
1018
1067
endif ()
@@ -1021,7 +1070,7 @@ endif()
1021
1070
1022
1071
install (FILES ${LIBPLZMA_PUBLIC_HEADERS} DESTINATION include )
1023
1072
1024
- if (LIBPLZMA_OPT_TESTS )
1073
+ if (LIBPLZMA_OPT_TESTS )
1025
1074
enable_testing ()
1026
1075
add_subdirectory (cmake_tests )
1027
1076
0 commit comments