forked from GerHobbelt/pthread-win32
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # .gitignore # CMakeLists.txt # GNUmakefile.in # Makefile # README.md # appveyor.yml # config.h # create.c # dll.c # docs/ANNOUNCE.md # docs/COPYING.FSF.md # docs/COPYING.md # docs/ChangeLog.md # docs/NEWS.md # docs/README.NONPORTABLE.md # docs/README.md # docs/TODO.md # implement.h # manual/PortabilityIssues.html # manual/pthreadCancelableWait.html # manual/pthread_attr_init.html # manual/pthread_attr_setstackaddr.html # manual/pthread_create.html # manual/pthread_win32_getabstime_np.html # need_errno.h # pthread.h # pthread_attr_getname_np.c # pthread_attr_setname_np.c # pthread_getname_np.c # pthread_mutex_init.c # pthread_setaffinity.c # pthread_setname_np.c # pthread_timedjoin_np.c # pthread_tryjoin_np.c # pthread_win32_attach_detach_np.c # ptw32_MCS_lock.c # ptw32_processInitialize.c # ptw32_threadStart.c # ptw32_throw.c # sched.h # sched_getscheduler.c # sched_setaffinity.c # sched_setscheduler.c # semaphore.h # tests/GNUmakefile.in # tests/Makefile # tests/affinity1.c # tests/affinity2.c # tests/affinity3.c # tests/affinity4.c # tests/affinity5.c # tests/affinity6.c # tests/benchtest4.c # tests/cancel6a.c # tests/cancel6d.c # tests/cleanup1.c # tests/common.mk # tests/condvar2_1.c # tests/condvar3_1.c # tests/condvar3_2.c # tests/condvar3_3.c # tests/context2.c # tests/exception2.c # tests/exception3.c # tests/exception3_0.c # tests/exit6.c # tests/join4.c # tests/mutex6n.c # tests/mutex7n.c # tests/mutex8.c # tests/mutex8e.c # tests/mutex8n.c # tests/mutex8r.c # tests/name_np2.c # tests/openmp1.c # tests/reinit1.c # tests/runorder.mk # tests/rwlock7.c # tests/rwlock8.c # tests/semaphore4t.c # tests/stress1.c # tests/test.h # tests/threestage.c # tests/timeouts.c # tests/tryentercs.c # tests/tryentercs2.c # version.rc # windows/VC6/pthread.dsp # windows/VC6/pthread.dsw
- Loading branch information
Showing
187 changed files
with
7,105 additions
and
3,192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,7 @@ Release-64/ | |
*.scc | ||
*.exe | ||
*.a | ||
*.manifest | ||
|
||
# Visual C++ cache files | ||
ipch/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,155 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
project(pthread) | ||
|
||
# STATIC library pthread | ||
set(PUBLIC_INTERFACE pthread.h sched.h semaphore.h) | ||
set(PRIVATE_SOURCES pthread.c) # everything is in pthread.c | ||
file(GLOB PRIVATE_HEADERS *.h) | ||
source_group(include FILES ${PRIVATE_HEADERS}) | ||
source_group(src FILES ${PRIVATE_SOURCES}) | ||
|
||
include_directories(".") | ||
add_library(pthread STATIC ${PRIVATE_HEADERS} ${PRIVATE_SOURCES}) | ||
target_compile_definitions(pthread PRIVATE | ||
-DPTW32_STATIC_LIB=1 | ||
-DHAVE_CONFIG_H=1 | ||
) | ||
cmake_minimum_required(VERSION 3.11) | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING "Choose the type of build, options are: Debug, Release, or MinSizeRel." FORCE) | ||
message(STATUS "No build type specified, defaulting to MinSizeRel.") | ||
endif() | ||
|
||
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake") | ||
|
||
include (get_version) | ||
|
||
message(STATUS "Generator ......... ${CMAKE_GENERATOR}") | ||
message(STATUS "Build Type ........ ${CMAKE_BUILD_TYPE}") | ||
message(STATUS "Version ........... ${PTHREADS4W_VERSION}") | ||
|
||
project(pthreads4w VERSION ${PTHREADS4W_VERSION} LANGUAGES C) | ||
|
||
set(PTW32_VER ${PROJECT_VERSION_MAJOR}${EXTRAVERSION}) | ||
set(CMAKE_DEBUG_POSTFIX d) | ||
|
||
# Uncomment this if config.h defines RETAIN_WSALASTERROR | ||
#set(XLIBS wsock32.lib) | ||
|
||
|
||
include_directories(.) | ||
|
||
################################# | ||
# Target Arch # | ||
################################# | ||
include (target_arch) | ||
|
||
get_target_arch(TARGET_ARCH) | ||
|
||
if(${TARGET_ARCH} STREQUAL "ARM") | ||
add_definitions(-DPTW32_ARCHARM -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1) | ||
elseif(${TARGET_ARCH} STREQUAL "ARM64") | ||
add_definitions(-DPTW32_ARCHARM64 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1) | ||
elseif(${TARGET_ARCH} STREQUAL "x86_64") | ||
add_definitions(-DPTW32_ARCHAMD64) | ||
elseif(${TARGET_ARCH} STREQUAL "x86") | ||
add_definitions(-DPTW32_ARCHX86) | ||
elseif(${TARGET_ARCH} STREQUAL "x64") | ||
add_definitions(-DPTW32_ARCHX64) | ||
else() | ||
MESSAGE(ERROR "\"${TARGET_ARCH}\" not supported in version.rc") | ||
endif() | ||
message(STATUS "Target ............ ${TARGET_ARCH}") | ||
|
||
if(MSVC) | ||
message(STATUS "MSVC Version ...... ${MSVC_VERSION}") | ||
endif() | ||
|
||
################################# | ||
# Install Path # | ||
################################# | ||
if(DIST_ROOT) | ||
set(CMAKE_INSTALL_PREFIX "${DIST_ROOT}") | ||
else() | ||
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/PTHREADS-BUILT") | ||
endif() | ||
message(STATUS "Install Path ${CMAKE_INSTALL_PREFIX}") | ||
|
||
|
||
set(DLLDEST ${CMAKE_INSTALL_PREFIX}/${TARGET_ARCH}/${CMAKE_BUILD_TYPE}/bin) | ||
set(LIBDEST ${CMAKE_INSTALL_PREFIX}/${TARGET_ARCH}/${CMAKE_BUILD_TYPE}/lib) | ||
set(HDRDEST ${CMAKE_INSTALL_PREFIX}/${TARGET_ARCH}/${CMAKE_BUILD_TYPE}/include) | ||
set(TESTDEST ${CMAKE_INSTALL_PREFIX}/${TARGET_ARCH}/${CMAKE_BUILD_TYPE}/test) | ||
|
||
################################# | ||
# Defs # | ||
################################# | ||
add_definitions(-DPTW32_BUILD_INLINED) | ||
|
||
if(MSVC) | ||
add_compile_options(/Gm-) | ||
add_link_options(/ignore:4006) | ||
|
||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /errorReport:none /nologo ") | ||
|
||
# C++ Exceptions | ||
# (Note: If you are using Microsoft VC++6.0, the library needs to be built | ||
# with /EHa instead of /EHs or else cancellation won't work properly.) | ||
if(MSVC_VERSION EQUAL 1200) | ||
set(VCEFLAGS "/EHa /TP ") | ||
else() | ||
set(VCEFLAGS "/EHs /TP ") | ||
endif() | ||
|
||
add_definitions(-DHAVE_CONFIG_H -DPTW32_RC_MSC) | ||
|
||
endif() | ||
|
||
# Update filename with proper version info | ||
configure_file(${CMAKE_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_BINARY_DIR}/version.rc @ONLY) | ||
|
||
################################# | ||
# Libraries # | ||
################################# | ||
set(targ_suffix "") | ||
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") | ||
set(targ_suffix ${CMAKE_DEBUG_POSTFIX}) | ||
endif() | ||
|
||
install(FILES ${PUBLIC_INTERFACE} DESTINATION include) | ||
install(TARGETS pthread | ||
RUNTIME DESTINATION bin | ||
LIBRARY DESTINATION lib) | ||
macro(shared_lib type def) | ||
set(targ pthread${type}${PTW32_VER}) | ||
add_library(${targ} SHARED pthread.c ${CMAKE_BINARY_DIR}/version.rc) | ||
message(STATUS ${targ}) | ||
target_compile_definitions(${targ} PUBLIC "-D${def}") | ||
if(${type} STREQUAL "VCE") | ||
set_target_properties(${targ} PROPERTIES COMPILE_FLAGS ${VCEFLAGS}) | ||
endif() | ||
if(${CMAKE_GENERATOR} MATCHES "Visual Studio") | ||
install(FILES ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${targ}${targ_suffix}.dll DESTINATION ${DLLDEST}) | ||
install(FILES ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${targ}${targ_suffix}.lib DESTINATION ${LIBDEST}) | ||
else() | ||
install(FILES ${CMAKE_BINARY_DIR}/${targ}${targ_suffix}.dll DESTINATION ${DLLDEST}) | ||
install(FILES ${CMAKE_BINARY_DIR}/${targ}${targ_suffix}.lib DESTINATION ${LIBDEST}) | ||
endif() | ||
endmacro() | ||
|
||
macro(static_lib type def) | ||
set(targ libpthread${type}${PTW32_VER}) | ||
add_library(${targ} STATIC pthread.c) | ||
message(STATUS ${targ}) | ||
target_compile_definitions(${targ} PUBLIC "-D${def}" -DPTW32_STATIC_LIB) | ||
if(${type} STREQUAL "VCE") | ||
set_target_properties(${targ} PROPERTIES COMPILE_FLAGS ${VCEFLAGS}) | ||
endif() | ||
if(${CMAKE_GENERATOR} MATCHES "Visual Studio") | ||
install(FILES ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${targ}${targ_suffix}.lib DESTINATION ${LIBDEST}) | ||
else() | ||
install(FILES ${CMAKE_BINARY_DIR}/${targ}${targ_suffix}.lib DESTINATION ${LIBDEST}) | ||
endif() | ||
endmacro() | ||
|
||
shared_lib ( VCE PTW32_CLEANUP_CXX ) | ||
shared_lib ( VSE PTW32_CLEANUP_SEH ) | ||
shared_lib ( VC PTW32_CLEANUP_C ) | ||
|
||
static_lib ( VCE PTW32_CLEANUP_CXX ) | ||
static_lib ( VSE PTW32_CLEANUP_SEH ) | ||
static_lib ( VC PTW32_CLEANUP_C ) | ||
|
||
################################# | ||
# Install # | ||
################################# | ||
install(FILES _ptw32.h pthread.h sched.h semaphore.h DESTINATION ${HDRDEST}) | ||
|
||
################################# | ||
# Test # | ||
################################# | ||
option(ENABLE_TESTS "Enable Test code build" FALSE) | ||
|
||
#TODO determine if cross compile... | ||
if(ENABLE_TESTS) | ||
add_subdirectory(tests) | ||
endif() |
Oops, something went wrong.