-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
459 lines (403 loc) · 12.1 KB
/
CMakeLists.txt
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
cmake_minimum_required (VERSION 3.11)
project (PTHREADS4W
VERSION 3.0.3.0
LANGUAGES C
)
include (GNUInstallDirs)
set (CMAKE_DEBUG_POSTFIX d)
if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
set (DEFAULT_BUILD_TYPE "Debug")
endif()
if (MSVC)
set (COMPILER_INDICATOR "V")
else()
set (COMPILER_INDICATOR "G")
endif()
# Set the possible values of build type for cmake-gui
if (CMAKE_CONFIGURATION_TYPES)
set (CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE
STRING "Semicolon separated list of supported configuration types, only supports debug and release, anything else will be ignored" FORCE
)
set_property (CACHE CMAKE_CONFIGURATION_TYPES PROPERTY STRINGS
"Debug" "Release"
)
endif()
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message (STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
set (CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE
STRING "Choose the type of build." FORCE
)
endif()
option (BUILD_TESTING "Run Tests after compile" ON)
option (PTHREADS4W_BUILD_C "Build lib with no exceptions - uses setjmp/longjmp" ON)
option (PTHREADS4W_BUILD_CE "Build lib with C++ Error Handling" OFF)
option (PTHREADS4W_BUILD_SE "Build lib with structured Error Handling" OFF)
option (PTHREADS4W_BUILD_ALL "Build all 3 flavours of the libs" OFF)
if (PTHREADS4W_BUILD_ALL)
set (PTHREADS4W_BUILD_C TRUE)
set (PTHREADS4W_BUILD_CE TRUE)
set (PTHREADS4W_BUILD_SE TRUE)
endif()
set (PTHREAD_SOURCES
cleanup.c
create.c
dll.c
errno.c
global.c
pthread_attr_destroy.c
pthread_attr_getaffinity_np.c
pthread_attr_getdetachstate.c
pthread_attr_getinheritsched.c
pthread_attr_getname_np.c
pthread_attr_getschedparam.c
pthread_attr_getschedpolicy.c
pthread_attr_getscope.c
pthread_attr_getstackaddr.c
pthread_attr_getstacksize.c
pthread_attr_init.c
pthread_attr_setaffinity_np.c
pthread_attr_setdetachstate.c
pthread_attr_setinheritsched.c
pthread_attr_setname_np.c
pthread_attr_setschedparam.c
pthread_attr_setschedpolicy.c
pthread_attr_setscope.c
pthread_attr_setstackaddr.c
pthread_attr_setstacksize.c
pthread_barrier_destroy.c
pthread_barrier_init.c
pthread_barrier_wait.c
pthread_barrierattr_destroy.c
pthread_barrierattr_getpshared.c
pthread_barrierattr_init.c
pthread_barrierattr_setpshared.c
pthread_cancel.c
pthread_cond_destroy.c
pthread_cond_init.c
pthread_cond_signal.c
pthread_cond_wait.c
pthread_condattr_destroy.c
pthread_condattr_getpshared.c
pthread_condattr_init.c
pthread_condattr_setpshared.c
pthread_delay_np.c
pthread_detach.c
pthread_equal.c
pthread_exit.c
pthread_getconcurrency.c
pthread_getname_np.c
pthread_getschedparam.c
pthread_getspecific.c
pthread_getunique_np.c
pthread_getw32threadhandle_np.c
pthread_join.c
pthread_key_create.c
pthread_key_delete.c
pthread_kill.c
pthread_mutex_consistent.c
pthread_mutex_destroy.c
pthread_mutex_init.c
pthread_mutex_lock.c
pthread_mutex_timedlock.c
pthread_mutex_trylock.c
pthread_mutex_unlock.c
pthread_mutexattr_destroy.c
pthread_mutexattr_getkind_np.c
pthread_mutexattr_getpshared.c
pthread_mutexattr_getrobust.c
pthread_mutexattr_gettype.c
pthread_mutexattr_init.c
pthread_mutexattr_setkind_np.c
pthread_mutexattr_setpshared.c
pthread_mutexattr_setrobust.c
pthread_mutexattr_settype.c
pthread_num_processors_np.c
pthread_once.c
pthread_rwlock_destroy.c
pthread_rwlock_init.c
pthread_rwlock_rdlock.c
pthread_rwlock_timedrdlock.c
pthread_rwlock_timedwrlock.c
pthread_rwlock_tryrdlock.c
pthread_rwlock_trywrlock.c
pthread_rwlock_unlock.c
pthread_rwlock_wrlock.c
pthread_rwlockattr_destroy.c
pthread_rwlockattr_getpshared.c
pthread_rwlockattr_init.c
pthread_rwlockattr_setpshared.c
pthread_self.c
pthread_setaffinity.c
pthread_setcancelstate.c
pthread_setcanceltype.c
pthread_setconcurrency.c
pthread_setname_np.c
pthread_setschedparam.c
pthread_setspecific.c
pthread_spin_destroy.c
pthread_spin_init.c
pthread_spin_lock.c
pthread_spin_trylock.c
pthread_spin_unlock.c
pthread_testcancel.c
pthread_timechange_handler_np.c
pthread_timedjoin_np.c
pthread_tryjoin_np.c
pthread_win32_attach_detach_np.c
ptw32_calloc.c
ptw32_callUserDestroyRoutines.c
ptw32_cond_check_need_init.c
ptw32_getprocessors.c
ptw32_is_attr.c
ptw32_MCS_lock.c
ptw32_mutex_check_need_init.c
ptw32_new.c
ptw32_processInitialize.c
ptw32_processTerminate.c
ptw32_relmillisecs.c
ptw32_reuse.c
ptw32_rwlock_cancelwrwait.c
ptw32_rwlock_check_need_init.c
ptw32_semwait.c
ptw32_spinlock_check_need_init.c
ptw32_threadDestroy.c
ptw32_threadStart.c
ptw32_throw.c
ptw32_timespec.c
ptw32_tkAssocCreate.c
ptw32_tkAssocDestroy.c
sched_get_priority_max.c
sched_get_priority_min.c
sched_getscheduler.c
sched_setaffinity.c
sched_setscheduler.c
sched_yield.c
sem_close.c
sem_destroy.c
sem_getvalue.c
sem_init.c
sem_open.c
sem_post_multiple.c
sem_post.c
sem_timedwait.c
sem_trywait.c
sem_unlink.c
sem_wait.c
w32_CancelableWait.c
)
set (PTHREAD_HEADERS
_ptw32.h
pthread.h
sched.h
)
if (PTHREADS4W_BUILD_C)
add_library (pthread${COMPILER_INDICATOR}C SHARED
${PTHREAD_SOURCES}
)
add_library (Threads::Threads ALIAS pthread${COMPILER_INDICATOR}C)
add_library (Threads::Shared ALIAS pthread${COMPILER_INDICATOR}C)
target_include_directories (pthread${COMPILER_INDICATOR}C
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/pthread>
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
set_target_properties (pthread${COMPILER_INDICATOR}C PROPERTIES
OUTPUT_NAME pthreadV${COMPILER_INDICATOR}${PTHREADS4W_VERSION_MAJOR}
EXPORT_NAME Threads::Threads
VERSION ${PTHREADS4W_VERSION}
SOVERSION ${PTHREADS4W_VERSION_MAJOR}
PUBLIC_HEADER "${PTHREAD_HEADERS}"
)
target_compile_definitions (pthread${COMPILER_INDICATOR}C
PUBLIC CLEANUP=__PTW32_CLEANUP_C
PRIVATE __PTW32_BUILD_INLINED
PRIVATE HAVE_CONFIG_H
)
install (TARGETS pthread${COMPILER_INDICATOR}C
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT Runtime
EXPORT PTHREADS4W
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER
COMPONENT Development
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pthread
)
add_library (pthread${COMPILER_INDICATOR}C-static STATIC
${PTHREAD_SOURCES}
)
add_library (Threads::Static ALIAS pthread${COMPILER_INDICATOR}C-static)
target_include_directories (pthread${COMPILER_INDICATOR}C-static
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/pthread>
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
set_target_properties (pthread${COMPILER_INDICATOR}C-static PROPERTIES
OUTPUT_NAME libpthread${COMPILER_INDICATOR}C${PTHREADS4W_VERSION_MAJOR}
EXPORT_NAME Threads::Static
VERSION ${PTHREADS4W_VERSION}
SOVERSION ${PTHREADS4W_VERSION_MAJOR}
PUBLIC_HEADER "${PTHREAD_HEADERS}"
)
target_compile_definitions (pthread${COMPILER_INDICATOR}C-static
PUBLIC CLEANUP=__PTW32_CLEANUP_C
PRIVATE __PTW32_BUILD_INLINED
PRIVATE __PTW32_STATIC_LIB
PRIVATE HAVE_CONFIG_H
)
install (TARGETS pthread${COMPILER_INDICATOR}C-static
COMPONENT Development
DESTINATION ${CMAKE_INSTALL_LIBDIR}
EXPORT PTHREADS4W
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pthread
)
endif()
if (PTHREADS4W_BUILD_CE)
add_library (pthread${COMPILER_INDICATOR}CE SHARED
${PTHREAD_SOURCES}
)
add_library (Threads::CEShared ALIAS pthread${COMPILER_INDICATOR}CE)
target_include_directories (pthread${COMPILER_INDICATOR}CE
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/pthread>
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
set_target_properties (pthread${COMPILER_INDICATOR}CE PROPERTIES
OUTPUT_NAME pthread${COMPILER_INDICATOR}CE${PTHREADS4W_VERSION_MAJOR}
EXPORT_NAME Threads::CEShared
VERSION ${PTHREADS4W_VERSION}
SOVERSION ${PTHREADS4W_VERSION_MAJOR}
PUBLIC_HEADER "${PTHREAD_HEADERS}"
)
target_compile_definitions (pthread${COMPILER_INDICATOR}CE
PUBLIC CLEANUP=__PTW32_CLEANUP_CXX
PRIVATE __PTW32_BUILD_INLINED
PRIVATE HAVE_CONFIG_H
)
target_compile_options (pthread${COMPILER_INDICATOR}CE
PRIVATE "/EHs"
PRIVATE "/TP"
)
install (TARGETS pthread${COMPILER_INDICATOR}CE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT Runtime
EXPORT PTHREADS4W
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER
COMPONENT Development
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pthread
)
add_library (pthread${COMPILER_INDICATOR}CE-static STATIC
${PTHREAD_SOURCES}
)
add_library (Threads::CEStatic ALIAS pthread${COMPILER_INDICATOR}CE-static)
target_include_directories (pthread${COMPILER_INDICATOR}CE-static
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/pthread>
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
set_target_properties (pthread${COMPILER_INDICATOR}CE-static PROPERTIES
OUTPUT_NAME libpthreadVCE${PTHREADS4W_VERSION_MAJOR}
EXPORT_NAME Threads::CEStatic
VERSION ${PTHREADS4W_VERSION}
SOVERSION ${PTHREADS4W_VERSION_MAJOR}
PUBLIC_HEADER "${PTHREAD_HEADERS}"
)
target_compile_definitions (pthread${COMPILER_INDICATOR}CE-static
PUBLIC CLEANUP=__PTW32_CLEANUP_CXX
PRIVATE __PTW32_BUILD_INLINED
PRIVATE __PTW32_STATIC_LIB
PRIVATE HAVE_CONFIG_H
)
target_compile_options (pthread${COMPILER_INDICATOR}CE-static
PRIVATE "/EHs"
PRIVATE "/TP"
)
install (TARGETS pthread${COMPILER_INDICATOR}CE-static
COMPONENT Development
DESTINATION ${CMAKE_INSTALL_LIBDIR}
EXPORT PTHREADS4W
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pthread
)
endif()
if (PTHREADS4W_BUILD_SE)
add_library (pthread${COMPILER_INDICATOR}SE SHARED
${PTHREAD_SOURCES}
)
add_library (Threads::SEShared ALIAS pthread${COMPILER_INDICATOR}SE)
target_include_directories (pthreadVSE
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/pthread>
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
set_target_properties (pthread${COMPILER_INDICATOR}SE PROPERTIES
OUTPUT_NAME pthreadVSE${PTHREADS4W_VERSION_MAJOR}
EXPORT_NAME Threads::SEShared
VERSION ${PTHREADS4W_VERSION}
SOVERSION ${PTHREADS4W_VERSION_MAJOR}
PUBLIC_HEADER "${PTHREAD_HEADERS}"
)
target_compile_definitions (pthread${COMPILER_INDICATOR}SE
PUBLIC CLEANUP=__PTW32_CLEANUP_SEH
PRIVATE __PTW32_BUILD_INLINED
PRIVATE HAVE_CONFIG_H
)
install (TARGETS pthread${COMPILER_INDICATOR}SE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT Runtime
EXPORT PTHREADS4W
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER
COMPONENT Development
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pthread
)
add_library (pthread${COMPILER_INDICATOR}SE-static STATIC
${PTHREAD_SOURCES}
)
add_library (Threads::SEStatic ALIAS pthread${COMPILER_INDICATOR}SE-static)
target_include_directories (pthread${COMPILER_INDICATOR}SE-static
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/pthread>
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
set_target_properties (pthread${COMPILER_INDICATOR}SE-static PROPERTIES
OUTPUT_NAME libpthreadVSE${PTHREADS4W_VERSION_MAJOR}
EXPORT_NAME Threads::SEStatic
VERSION ${PTHREADS4W_VERSION}
SOVERSION ${PTHREADS4W_VERSION_MAJOR}
PUBLIC_HEADER "${PTHREAD_HEADERS}"
)
target_compile_definitions (pthread${COMPILER_INDICATOR}SE-static
PUBLIC CLEANUP=__PTW32_CLEANUP_SEH
PRIVATE __PTW32_BUILD_INLINED
PRIVATE __PTW32_STATIC_LIB
PRIVATE HAVE_CONFIG_H
)
install (TARGETS pthread${COMPILER_INDICATOR}SE-static
COMPONENT Development
DESTINATION ${CMAKE_INSTALL_LIBDIR}
EXPORT PTHREADS4W
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pthread
)
endif()
include (CMakePackageConfigHelpers)
configure_package_config_file (
PTHREADS.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/PTHREADS4WConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/
)
WRITE_BASIC_PACKAGE_VERSION_FILE (PTHREADS4WConfigVersion.cmake
VERSION ${PTHREADS4W_VERSION}
COMPATIBILITY SameMajorVersion
)
install (EXPORT PTHREADS4W
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake
)
install (FILES
${CMAKE_CURRENT_BINARY_DIR}/PTHREADS4WConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/PTHREADS4WConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/
)
if (BUILD_TESTING)
enable_testing()
add_subdirectory (tests)
endif()
set (CPACK_RESOURCE_FILE_LICENSE ${PROJECT_SOURCE_DIR}/LICENSE)
include (CPack)