Skip to content

Commit ded980f

Browse files
committed
CMake support and Travis CI job
1 parent 44daa24 commit ded980f

22 files changed

+970
-1476
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ tests/benchlib.o
1717
tests/SIZES.*
1818
tests/*.log
1919
/.project
20+
build
21+
PTHREADS-BUILT
22+
.vscode

.travis.yml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
language: shell
2+
3+
os: windows
4+
5+
env:
6+
- BUILD_TYPE=Debug VS2017=amd64 TESTING=OFF
7+
- BUILD_TYPE=Release VS2017=amd64 TESTING=OFF
8+
- BUILD_TYPE=MinSizeRel VS2017=amd64 TESTING=OFF
9+
- BUILD_TYPE=MinSizeRel VS2017=amd64 TESTING=OFF
10+
11+
- BUILD_TYPE=Debug VS2017=amd64_x86 TESTING=OFF
12+
- BUILD_TYPE=Release VS2017=amd64_x86 TESTING=OFF
13+
- BUILD_TYPE=MinSizeRel VS2017=amd64_x86 TESTING=OFF
14+
- BUILD_TYPE=MinSizeRel VS2017=amd64_x86 TESTING=OFF
15+
16+
#- BUILD_TYPE=Debug VS2017=amd64_arm TESTING=OFF
17+
#- BUILD_TYPE=Release VS2017=amd64_arm TESTING=OFF
18+
#- BUILD_TYPE=MinSizeRel VS2017=amd64_arm TESTING=OFF
19+
#- BUILD_TYPE=MinSizeRel VS2017=amd64_arm TESTING=OFF
20+
21+
#- BUILD_TYPE=Debug VS2017=amd64_arm64 TESTING=OFF
22+
#- BUILD_TYPE=Release VS2017=amd64_arm64 TESTING=OFF
23+
#- BUILD_TYPE=MinSizeRel VS2017=amd64_arm64 TESTING=OFF
24+
#- BUILD_TYPE=MinSizeRel VS2017=amd64_arm64 TESTING=OFF
25+
26+
#install:
27+
#- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
28+
#- mkdir ${DEPS_DIR} && cd ${DEPS_DIR} && pwd
29+
#- travis_retry wget --no-check-certificate https://cmake.org/files/v3.11/cmake-3.11.0-win64-x64.zip
30+
#- echo "615dfb0813443c1ff56ae0e9d6dbfc61 *cmake-3.11.0-win64-x64.zip" > cmake_md5.txt
31+
#- md5sum -c cmake_md5.txt
32+
#- 7z x -y cmake-3.11.0-win64-x64.zip
33+
#- PATH=${DEPS_DIR}/cmake-3.11.0-win64-x64:${DEPS_DIR}/cmake-3.11.0-win64-x64/bin:$PATH
34+
35+
before_script:
36+
37+
# document the version
38+
#- cmake --version
39+
#- cmake --help
40+
41+
# set enviromental variables
42+
- ls "/c/Progra~2/Microsoft Visual Studio/2017/BuildTools/VC/Auxiliary/Build/"
43+
#vcvars32.bat
44+
#vcvars64.bat
45+
#vcvarsall.bat
46+
#vcvarsamd64_arm.bat
47+
#vcvarsamd64_arm64.bat
48+
#vcvarsamd64_x86.bat
49+
#vcvarsx86_amd64.bat
50+
#vcvarsx86_arm.bat
51+
#vcvarsx86_arm64.bat
52+
#- printenv
53+
54+
#- msvcenv="__msvc.bat"
55+
#- echo "@echo off" > "$msvcenv"
56+
#- echo "call /c/Progra~2/Microsoft\ Visual\ Studio/2017/BuildTools/VC/Auxiliary/Build/vcvarsall.bat ${VS2017}" >> "$msvcenv"
57+
#- echo "set" >> "$msvcenv"
58+
#- cmd "/K $msvcenv"
59+
# > "$msenv.tmp"
60+
61+
#- cat "$msvcenv"
62+
#- rm -f "$msvcenv"
63+
64+
- printenv
65+
66+
#- cat "$msenv.tmp"
67+
68+
#- grep -e '^PATH=' "$msenv.tmp" | \
69+
#sed \
70+
#-e 's/\(.*\)=\(.*\)/export \1="\2:$PATH"/g' \
71+
#-e 's/\([a-zA-Z]\):[\\\/]/\/\1\//g' \
72+
#-e 's/\\/\//g' -e 's/;\//:\//g'
73+
# > "$msenv"
74+
#- grep -e '^(INCLUDE|LIB|LIBPATH)=' "$msenv.tmp" | sed -e 's/\(.*\)=\(.*\)/export \1="\2"/g' >> "$msenv"
75+
#- rm "$msenv.tmp"
76+
#- cat "$msenv"
77+
#- source "$msenv"
78+
79+
#- printenv
80+
81+
- call "c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars32.bat" ${VS2017}
82+
#- cmd "/K C:\\Progra~2\\Microsoft\ Visual\ Studio\\2017\\BuildTools\\VC\\Auxiliary\\Build\\vcvarsall.bat ${VS2017}"
83+
#- /c/Progra~2/Microsoft\ Visual\ Studio/2017/BuildTools/VC/Auxiliary/Build/vcvarsall.bat ${VS2017} > "$msenv.tmp"
84+
#- cat "$msenv.tmp"
85+
#- printenv
86+
87+
# Visual Studio 2015
88+
#- ls "/c/Progra~2/Microsoft Visual Studio 14.0/VC/"
89+
#- /c/Progra~2/Microsoft\ Visual\ Studio\ 14.0/VC/vcvarsall.bat amd64
90+
91+
# generate the build files
92+
- cd ${TRAVIS_BUILD_DIR} && mkdir build && cd build
93+
- cmake -G"NMake Makefiles" -DCMAKE_VERBOSE_MAKEFILE=FALSE -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
94+
#-DBUILD_NUMBER=${TRAVIS_BUILD_NUMBER}
95+
#-DDIST_ROOT="${TRAVIS_BUILD_DIR}/build/dist"
96+
#-DENABLE_TESTS=${TESTING}
97+
#..
98+
script:
99+
- cmake --build . --config ${BUILD_TYPE} --target install
100+
101+
addons:
102+
coverity_scan:
103+
project:
104+
name: “jwinarske/pthreads4w"
105+
notification_email: [email protected]
106+
build_command_prepend: "mkdir build && cd build && cmake -DCMAKE_VERBOSE_MAKEFILE=TRUE -DDCMAKE_INSTALL_PREFIX=`pwd`/dist .."
107+
build_command: "cmake --build . --target install"
108+
branch_pattern: coverity_scan

CMakeLists.txt

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
cmake_minimum_required(VERSION 3.11)
2+
3+
if(NOT CMAKE_BUILD_TYPE)
4+
set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING "Choose the type of build, options are: Debug, Release, or MinSizeRel." FORCE)
5+
message(STATUS "No build type specified, defaulting to MinSizeRel.")
6+
endif()
7+
8+
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake")
9+
10+
include (get_version)
11+
12+
message(STATUS "Generator ......... ${CMAKE_GENERATOR}")
13+
message(STATUS "Build Type ........ ${CMAKE_BUILD_TYPE}")
14+
message(STATUS "Version ........... ${PTHREADS4W_VERSION}")
15+
16+
project(pthreads4w VERSION ${PTHREADS4W_VERSION} LANGUAGES C)
17+
18+
set(PTW32_VER ${PROJECT_VERSION_MAJOR}${EXTRAVERSION})
19+
set(CMAKE_DEBUG_POSTFIX d)
20+
21+
# Uncomment this if config.h defines RETAIN_WSALASTERROR
22+
#set(XLIBS wsock32.lib)
23+
24+
25+
include_directories(.)
26+
27+
#################################
28+
# Target Arch #
29+
#################################
30+
include (target_arch)
31+
32+
get_target_arch(TARGET_ARCH)
33+
34+
if(${TARGET_ARCH} STREQUAL "ARM")
35+
add_definitions(-D__PTW32_ARCHARM -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1)
36+
elseif(${TARGET_ARCH} STREQUAL "ARM64")
37+
add_definitions(-D__PTW32_ARCHARM64 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE=1)
38+
elseif(${TARGET_ARCH} STREQUAL "x86_64")
39+
add_definitions(-D__PTW32_ARCHAMD64)
40+
elseif(${TARGET_ARCH} STREQUAL "x86")
41+
add_definitions(-D__PTW32_ARCHX86)
42+
elseif(${TARGET_ARCH} STREQUAL "x64")
43+
add_definitions(-D__PTW32_ARCHX64)
44+
else()
45+
MESSAGE(ERROR "\"${TARGET_ARCH}\" not supported in version.rc")
46+
endif()
47+
message(STATUS "Target ............ ${TARGET_ARCH}")
48+
49+
if(MSVC)
50+
message(STATUS "MSVC Version ...... ${MSVC_VERSION}")
51+
endif()
52+
53+
#################################
54+
# Install Path #
55+
#################################
56+
if(DIST_ROOT)
57+
set(CMAKE_INSTALL_PREFIX "${DIST_ROOT}")
58+
else()
59+
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/PTHREADS-BUILT")
60+
endif()
61+
message(STATUS "Install Path ${CMAKE_INSTALL_PREFIX}")
62+
63+
64+
set(DLLDEST ${CMAKE_INSTALL_PREFIX}/${TARGET_ARCH}/${CMAKE_BUILD_TYPE}/bin)
65+
set(LIBDEST ${CMAKE_INSTALL_PREFIX}/${TARGET_ARCH}/${CMAKE_BUILD_TYPE}/lib)
66+
set(HDRDEST ${CMAKE_INSTALL_PREFIX}/${TARGET_ARCH}/${CMAKE_BUILD_TYPE}/include)
67+
set(TESTDEST ${CMAKE_INSTALL_PREFIX}/${TARGET_ARCH}/${CMAKE_BUILD_TYPE}/test)
68+
69+
#################################
70+
# Defs #
71+
#################################
72+
add_definitions(-D__PTW32_BUILD_INLINED)
73+
74+
if(MSVC)
75+
76+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /errorReport:none /nologo ")
77+
78+
# C++ Exceptions
79+
# (Note: If you are using Microsoft VC++6.0, the library needs to be built
80+
# with /EHa instead of /EHs or else cancellation won't work properly.)
81+
if(MSVC_VERSION EQUAL 1200)
82+
set(VCEFLAGS "/EHa /TP ")
83+
else()
84+
set(VCEFLAGS "/EHs /TP ")
85+
endif()
86+
87+
add_definitions(-DHAVE_CONFIG_H -D__PTW32_RC_MSC)
88+
89+
endif()
90+
91+
# Update filename with proper version info
92+
configure_file(${CMAKE_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_BINARY_DIR}/version.rc @ONLY)
93+
94+
#################################
95+
# Libraries #
96+
#################################
97+
set(targ_suffix "")
98+
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
99+
set(targ_suffix ${CMAKE_DEBUG_POSTFIX})
100+
endif()
101+
102+
macro(shared_lib type def)
103+
set(targ pthread${type}${PTW32_VER})
104+
add_library(${targ} SHARED pthread.c ${CMAKE_BINARY_DIR}/version.rc)
105+
message(STATUS ${targ})
106+
target_compile_definitions(${targ} PUBLIC "-D${def}")
107+
if(${type} STREQUAL "VCE")
108+
set_target_properties(${targ} PROPERTIES COMPILE_FLAGS ${VCEFLAGS})
109+
endif()
110+
if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
111+
install(FILES ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${targ}${targ_suffix}.dll DESTINATION ${DLLDEST})
112+
install(FILES ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${targ}${targ_suffix}.lib DESTINATION ${LIBDEST})
113+
else()
114+
install(FILES ${CMAKE_BINARY_DIR}/${targ}${targ_suffix}.dll DESTINATION ${DLLDEST})
115+
install(FILES ${CMAKE_BINARY_DIR}/${targ}${targ_suffix}.lib DESTINATION ${LIBDEST})
116+
endif()
117+
endmacro()
118+
119+
macro(static_lib type def)
120+
set(targ libpthread${type}${PTW32_VER})
121+
add_library(${targ} STATIC pthread.c)
122+
message(STATUS ${targ})
123+
target_compile_definitions(${targ} PUBLIC "-D${def}" -D__PTW32_STATIC_LIB)
124+
if(${type} STREQUAL "VCE")
125+
set_target_properties(${targ} PROPERTIES COMPILE_FLAGS ${VCEFLAGS})
126+
endif()
127+
if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
128+
install(FILES ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE}/${targ}${targ_suffix}.lib DESTINATION ${LIBDEST})
129+
else()
130+
install(FILES ${CMAKE_BINARY_DIR}/${targ}${targ_suffix}.lib DESTINATION ${LIBDEST})
131+
endif()
132+
endmacro()
133+
134+
shared_lib ( VCE __PTW32_CLEANUP_CXX )
135+
shared_lib ( VSE __PTW32_CLEANUP_SEH )
136+
shared_lib ( VC __PTW32_CLEANUP_C )
137+
138+
static_lib ( VCE __PTW32_CLEANUP_CXX )
139+
static_lib ( VSE __PTW32_CLEANUP_SEH )
140+
static_lib ( VC __PTW32_CLEANUP_C )
141+
142+
#################################
143+
# Install #
144+
#################################
145+
install(FILES _ptw32.h pthread.h sched.h semaphore.h DESTINATION ${HDRDEST})
146+
147+
#################################
148+
# Test #
149+
#################################
150+
option(ENABLE_TESTS "Enable Test code build" FALSE)
151+
152+
#TODO determine if cross compile...
153+
if(ENABLE_TESTS)
154+
add_subdirectory(tests)
155+
endif()

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2019-11-03 Ross Johnson <ross dot johnson at homemail dot com dot au>
2+
3+
* NOTICE: Remove third party code acknowledgments because files have been
4+
removed from distro.
5+
16
2018-08-19 Ross Johnson <ross dot johnson at homemail dot com dot au>
27

38
* context.h (__PTW32_PROCPTR): Added missing '__' prefix for v3.

NOTICE

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,4 @@ Copyright 1999-2018, Pthreads4w contributors
44

55
This product includes software developed through the colaborative
66
effort of several individuals, each of whom is listed in the file
7-
CONTRIBUTORS included with this software.
8-
9-
The following files are not covered under the Copyrights
10-
listed above:
11-
12-
[1] tests/rwlock7.c
13-
[1] tests/rwlock7_1.c
14-
[1] tests/rwlock8.c
15-
[1] tests/rwlock8_1.c
16-
[2] tests/threestage.c
17-
18-
[1] The file tests/rwlock7.c and those similarly named are derived from
19-
code written by Dave Butenhof for his book 'Programming With POSIX(R)
20-
Threads'. The original code was obtained by free download from his
21-
website http://home.earthlink.net/~anneart/family/Threads/source.html
22-
23-
[2] The file tests/threestage.c is taken directly from examples in the
24-
book "Windows System Programming, Edition 4" by Johnson (John) Hart
25-
Session 6, Chapter 10. ThreeStage.c
26-
Several required additional header and source files from the
27-
book examples have been included inline to simplify compilation.
28-
The only modification to the code has been to provide default
29-
values when run without arguments.
7+
CONTRIBUTORS included with this software.

_ptw32.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@
4343
*/
4444
#define __PTW32_VERSION_MAJOR 3
4545
#define __PTW32_VERSION_MINOR 0
46-
#define __PTW32_VERSION_MICRO 1
46+
#define __PTW32_VERSION_MICRO 2
4747
#define __PTW32_VERION_BUILD 0
48-
#define __PTW32_VERSION 3,0,0,1
49-
#define __PTW32_VERSION_STRING "3, 0, 1, 0\0"
48+
#define __PTW32_VERSION 3,0,2,0
49+
#define __PTW32_VERSION_STRING "3, 0, 2, 0\0"
5050

5151
#if defined(__GNUC__)
5252
# pragma GCC system_header

0 commit comments

Comments
 (0)