-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joel Winarske
committed
Oct 8, 2018
1 parent
c53ac54
commit 113d329
Showing
8 changed files
with
947 additions
and
0 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 |
---|---|---|
|
@@ -17,3 +17,6 @@ tests/benchlib.o | |
tests/SIZES.* | ||
tests/*.log | ||
/.project | ||
build | ||
PTHREADS-BUILT | ||
.vscode |
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 |
---|---|---|
@@ -0,0 +1,149 @@ | ||
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 (common) | ||
|
||
include_directories(.) | ||
|
||
################################# | ||
# Target Arch # | ||
################################# | ||
include (target_arch) | ||
|
||
get_target_arch(TARGET_ARCH) | ||
|
||
if(${TARGET_ARCH} STREQUAL "ARM") | ||
add_definitions(-D__PTW32_ARCHARM) | ||
elseif(${TARGET_ARCH} STREQUAL "x86_64") | ||
add_definitions(-D__PTW32_ARCHAMD64) | ||
elseif(${TARGET_ARCH} STREQUAL "x86") | ||
add_definitions(-D__PTW32_ARCHX86) | ||
elseif(${TARGET_ARCH} STREQUAL "x64") | ||
add_definitions(-D__PTW32_ARCHX64) | ||
else() | ||
MESSAGE(ERROR "\"${TARGET_ARCH}\" not supported in version.rc") | ||
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(-D__PTW32_BUILD_INLINED) | ||
|
||
if(MSVC) | ||
|
||
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 -D__PTW32_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() | ||
|
||
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}" -D__PTW32_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() |
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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
version: 3.0.1.{build} | ||
|
||
cache: | ||
- C:\Tools\ninja\ninja.exe | ||
|
||
shallow_clone: true | ||
clone_depth: 1 | ||
|
||
branches: | ||
only: | ||
- cmake | ||
|
||
configuration: | ||
- MinSizeRel | ||
- Release | ||
- Debug | ||
|
||
environment: | ||
DIST_DIR: '%APPVEYOR_BUILD_FOLDER%\dist' | ||
CMAKE_DIST_DIR: C:/projects/pthreads4w/dist | ||
NINJA_DIR: C:\Tools\ninja | ||
matrix: | ||
- APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2015' | ||
PLATFORM: x64 | ||
VCVARSALL: '%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat' | ||
ARCHITECTURE: x86_amd64 | ||
ARCHIVE: VS2015_%CONFIGURATION%_%PLATFORM%_%APPVEYOR_BUILD_NUMBER% | ||
GENERATOR: Ninja | ||
- APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2015' | ||
PLATFORM: x86 | ||
VCVARSALL: '%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat' | ||
ARCHITECTURE: x86 | ||
ARCHIVE: VS2015_%CONFIGURATION%_%PLATFORM%_%APPVEYOR_BUILD_NUMBER% | ||
GENERATOR: Ninja | ||
- APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2017' | ||
PLATFORM: x64 | ||
VCVARSALL: '%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"' | ||
ARCHITECTURE: | ||
ARCHIVE: VS2017_%CONFIGURATION%_%PLATFORM%_%APPVEYOR_BUILD_NUMBER% | ||
GENERATOR: Ninja | ||
- APPVEYOR_BUILD_WORKER_IMAGE: 'Visual Studio 2017' | ||
PLATFORM: x86 | ||
VCVARSALL: '%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"' | ||
ARCHITECTURE: | ||
ARCHIVE: VS2017_%CONFIGURATION%_%PLATFORM%_%APPVEYOR_BUILD_NUMBER% | ||
GENERATOR: Ninja | ||
|
||
init: | ||
- echo BUILD_NUMBER=%APPVEYOR_BUILD_NUMBER% | ||
|
||
install: | ||
# Ninja | ||
- if not exist %NINJA_DIR%\ mkdir %NINJA_DIR% | ||
- cd %NINJA_DIR% | ||
- if not exist ninja.exe appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-win.zip | ||
- if not exist ninja.exe 7z x ninja-win.zip | ||
- set PATH=%NINJA_DIR%;%PATH% | ||
# CMake | ||
- cmake --version | ||
|
||
build: | ||
parallel: true | ||
|
||
build_script: | ||
- call "%VCVARSALL%" %ARCHITECTURE% | ||
- cd %APPVEYOR_BUILD_FOLDER% | ||
- mkdir build | ||
- cd build | ||
- cmake -G"%GENERATOR%" | ||
-DCMAKE_BUILD_TYPE=%CONFIGURATION% | ||
-DBUILD_NUMBER=%APPVEYOR_BUILD_NUMBER% | ||
-DDIST_ROOT="%CMAKE_DIST_DIR%/%APPVEYOR_BUILD_WORKER_IMAGE%" | ||
-DENABLE_TESTS=ON | ||
.. | ||
- cmake --build . --config %CONFIGURATION% --target install | ||
|
||
after_build: | ||
- cd %DIST_DIR% | ||
- 7z a -tzip %ARCHIVE%.zip "%APPVEYOR_BUILD_WORKER_IMAGE%" | ||
- certutil -hashfile %ARCHIVE%.zip MD5 > %ARCHIVE%.md5 | ||
|
||
artifacts: | ||
- path: dist\$(ARCHIVE).zip | ||
- path: dist\$(ARCHIVE).md5 | ||
|
||
test: | ||
before_test: | ||
- set PATH=%APPVEYOR_BUILD_FOLDER%\build;%PATH% | ||
test_script: | ||
- if exist %APPVEYOR_BUILD_FOLDER%\build\tests\ cd %APPVEYOR_BUILD_FOLDER%\build\tests | ||
- if exist %APPVEYOR_BUILD_FOLDER%\build\tests\ ctest -C %CONFIGURATION% | ||
after_test: | ||
# TODO process CTest output |
Oops, something went wrong.