-
Notifications
You must be signed in to change notification settings - Fork 128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HOLD MERGE PLEASE] ThreadPool compile time template parameter; CMake + CI cross platform work #9
Closed
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
bd7d94c
add cmake package config template
headupinclouds 57dbc3c
add cmake platform checks for: (1) true`thread_local` storage; (2) pl…
headupinclouds edcfe98
add thread_local attribute abstraction ATTRIBUTE_TLS for portability;…
headupinclouds d32d21d
remove TSettings template paramter; add TASK_SIZE template parameter
headupinclouds bc5aabd
package config install; thread_local cmake checks; add/increase VERSION
headupinclouds d28d5b6
remove std::move() for temporary object
headupinclouds e019fac
add macro for default unused error in Xcode/clang
headupinclouds 3262699
add template syntax for test
headupinclouds 00e7469
manage tests w/ CTest `if(THREAD_POOL_CPP_BUILD_TESTS)`
headupinclouds 379432f
use "quotes" for local include
headupinclouds 03d47a9
remove pthread, remove include_directories()
headupinclouds 1b969bc
bump cmake version to 3.3
headupinclouds 85d6312
remove boost and pthread dependencies in benchmark code
headupinclouds 838a5b7
Introduce TSettings template parameter wrapper for `task_size`
headupinclouds 1c65c52
remove manual Findthread-pool-cpp.cmake
headupinclouds 4058471
size_t -> std::size_t; auto return type; remove/expand ((void)(x)) macro
headupinclouds 3673c1d
cross platform updates
headupinclouds File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,124 @@ | ||
S# Lineage: ruslo/hunter test scripts | ||
# test | ||
|
||
# OSX/Linux (https://github.com/travis-ci-tester/toolchain-table) | ||
|
||
language: | ||
- cpp | ||
|
||
# Container-based infrastructure (Linux) | ||
# * https://docs.travis-ci.com/user/migrating-from-legacy/#How-can-I-use-container-based-infrastructure%3F | ||
sudo: | ||
- false | ||
|
||
# Install packages differs for container-based infrastructure | ||
# * https://docs.travis-ci.com/user/migrating-from-legacy/#How-do-I-install-APT-sources-and-packages%3F | ||
# * http://stackoverflow.com/a/30925448/2288008 | ||
addons: | ||
apt: | ||
sources: | ||
- ubuntu-toolchain-r-test | ||
packages: | ||
- python3 | ||
|
||
# python3-pip package is not available, use 'easy_install3': | ||
# * https://github.com/travis-ci/apt-package-whitelist/issues/768 | ||
- python3-setuptools # easy_install3 | ||
|
||
# https://github.com/travis-ci-tester/travis-test-clang-cxx-11 | ||
- libstdc++-4.8-dev | ||
|
||
# https://github.com/travis-ci-tester/travis-test-gcc-cxx-11 | ||
- g++-4.8 | ||
|
||
# For Qt | ||
- libegl1-mesa-dev | ||
|
||
# Packages for Android development: http://superuser.com/a/360398/252568 | ||
- libncurses5:i386 | ||
- libstdc++6:i386 | ||
- zlib1g:i386 | ||
|
||
matrix: | ||
include: | ||
# Linux { | ||
- os: linux | ||
env: CONFIG=Release TOOLCHAIN=gcc-4-8-pic-hid-sections HAS_CPP14=OFF | ||
- os: linux | ||
env: CONFIG=Debug TOOLCHAIN=gcc-4-8-pic-hid-sections HAS_CPP14=OFF | ||
- os: linux | ||
env: CONFIG=Release TOOLCHAIN=android-ndk-r10e-api-19-armeabi-v7a-neon-hid-sections HAS_CPP14=OFF | ||
- os: linux | ||
env: CONFIG=Debug TOOLCHAIN=android-ndk-r10e-api-19-armeabi-v7a-neon-hid-sections HAS_CPP14=OFF | ||
# } | ||
|
||
# OSX { | ||
- os: osx | ||
env: CONFIG=Release TOOLCHAIN=osx-10-11-hid-sections HAS_CPP14=OFF | ||
- os: osx | ||
env: CONFIG=Debug TOOLCHAIN=osx-10-11-hid-sections HAS_CPP14=OFF | ||
- os: osx | ||
env: CONFIG=Release TOOLCHAIN=ios-nocodesign-9-3-device-hid-sections HAS_CPP14=OFF | ||
- os: osx | ||
env: CONFIG=Debug TOOLCHAIN=ios-nocodesign-9-3-device-hid-sections HAS_CPP14=OFF | ||
- os: osx | ||
osx_image: xcode8.1 | ||
env: CONFIG=Release TOOLCHAIN=osx-10-12-sanitize-address-hid-sections HAS_CPP14=OFF | ||
- os: osx | ||
osx_image: xcode8.1 | ||
env: CONFIG=Debug TOOLCHAIN=osx-10-12-sanitize-address-hid-sections HAS_CPP14=OFF | ||
- os: osx | ||
env: CONFIG=Release TOOLCHAIN=android-ndk-r10e-api-19-armeabi-v7a-neon-hid-sections HAS_CPP14=OFF | ||
- os: osx | ||
env: CONFIG=Debug TOOLCHAIN=android-ndk-r10e-api-19-armeabi-v7a-neon-hid-sections HAS_CPP14=OFF | ||
# } | ||
|
||
# disable the default submodule logic to support local modification of .gitmodules paths | ||
git: | ||
submodules: false | ||
|
||
install: | ||
# Info about OS | ||
- uname -a | ||
|
||
# Install Python 3 | ||
- if [[ "`uname`" == "Darwin" ]]; then travis_retry brew install python3; fi | ||
|
||
# Install Python package 'requests' | ||
# 'easy_install3' is not installed by 'brew install python3' on OS X 10.9 Maverick | ||
- if [[ "`uname`" == "Darwin" ]]; then pip3 install requests; fi | ||
- if [[ "`uname`" == "Linux" ]]; then travis_retry easy_install3 --user requests==2.10.0; fi | ||
|
||
# Install latest Polly toolchains and scripts | ||
- wget https://github.com/ruslo/polly/archive/master.zip | ||
- unzip master.zip | ||
- POLLY_ROOT="`pwd`/polly-master" | ||
- export PATH="${POLLY_ROOT}/bin:${PATH}" | ||
|
||
# Install dependencies (CMake, Android NDK) | ||
- install-ci-dependencies.py | ||
|
||
# Tune locations | ||
- export PATH="`pwd`/_ci/cmake/bin:${PATH}" | ||
|
||
# Installed if toolchain is Android (otherwise directory doesn't exist) | ||
- export ANDROID_NDK_r10e="`pwd`/_ci/android-ndk-r10e" | ||
|
||
script: | ||
|
||
# '--ios-{multiarch,combined}' do nothing for non-iOS builds | ||
- > | ||
polly.py | ||
--toolchain ${TOOLCHAIN} | ||
--config ${CONFIG} | ||
--verbose | ||
--ios-multiarch --ios-combined | ||
--fwd | ||
THREAD_POOL_CPP_BUILD_TESTS=ON | ||
THREAD_POOL_CPP_HAS_CPP14=${HAS_CPP14} | ||
--test | ||
--jobs 2 | ||
|
||
branches: | ||
except: | ||
- /^pr\..*/ |
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,23 +1,111 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
cmake_minimum_required(VERSION 3.3) # support visibility settings | ||
|
||
list(APPEND CMAKE_MODULE_PATH | ||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") | ||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules") | ||
|
||
project(thread-pool-cpp) | ||
add_definitions(-std=c++14 -Wall -Werror -O3) | ||
project(thread-pool-cpp VERSION 1.1.0) | ||
|
||
option(THREAD_POOL_CPP_BUILD_TESTS "Build tests." OFF) | ||
option(THREAD_POOL_CPP_BUILD_BENCHMARKS "Build benchmarks." OFF) | ||
|
||
# Get all include files | ||
if(THREAD_POOL_CPP_BUILD_TESTS) | ||
include(CTest) | ||
endif() | ||
|
||
# Variable used in: benchmark, tests | ||
set(THREAD_POOL_CPP_INC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/") | ||
include_directories("${THREAD_POOL_CPP_INC_DIR}") | ||
file(GLOB_RECURSE INSTALL_FILES_LIST "${THREAD_POOL_CPP_INC_DIR}/*") | ||
|
||
add_subdirectory(tests) | ||
add_subdirectory(benchmark) | ||
# If true C++11 thread_local support exists, we will use it: | ||
include(thread_pool_has_thread_local_storage) | ||
thread_pool_has_thread_local_storage(THREAD_POOL_HAS_THREAD_LOCAL_STORAGE) | ||
message("THREAD_POOL_HAS_THREAD_LOCAL_STORAGE: ${THREAD_POOL_HAS_THREAD_LOCAL_STORAGE}") | ||
|
||
if(NOT THREAD_POOL_HAS_THREAD_LOCAL_STORAGE) | ||
# Else, we will check for backups | ||
include(thread_pool_has_thread_storage) | ||
thread_pool_has_thread_storage(THREAD_POOL_HAS_THREAD_STORAGE) | ||
message("THREAD_POOL_HAS_THREAD_STORAGE: ${THREAD_POOL_HAS_THREAD_STORAGE}") | ||
if(NOT THREAD_POOL_HAS_THREAD_STORAGE) | ||
message(FATAL_ERROR "Compiler does not support: thread_local, __thread, or declspec(thread)") | ||
endif() | ||
endif() | ||
|
||
# http://stackoverflow.com/a/11583676 | ||
add_library(thread-pool-cpp INTERFACE) | ||
|
||
option(THREAD_POOL_CPP_HAS_CPP14 "Has true C++14 support." ON) | ||
|
||
if(NOT MSVC) | ||
if(THREAD_POOL_CPP_HAS_CPP14) | ||
target_compile_definitions(thread-pool-cpp INTERFACE -std=c++14 -Wall -Werror -O3) | ||
else() | ||
target_compile_definitions(thread-pool-cpp INTERFACE -std=c++1y -Wall -Werror -O3) | ||
endif() | ||
else() | ||
if(THREAD_POOL_CPP_HAS_CPP14) | ||
target_compile_definitions(thread-pool-cpp INTERFACE /std:c++14) | ||
else() | ||
target_compile_definitions(thread-pool-cpp INTERFACE /std:c++1y) | ||
endif() | ||
endif() | ||
|
||
if(THREAD_POOL_CPP_BUILD_TESTS) | ||
add_subdirectory(tests) | ||
endif() | ||
|
||
if(THREAD_POOL_CPP_BUILD_BENCHMARKS) | ||
add_subdirectory(benchmark) | ||
endif() | ||
|
||
#### install | ||
|
||
set(TARGET_NAME thread-pool-cpp) | ||
|
||
set(config_install_dir "lib/cmake/${TARGET_NAME}") | ||
set(include_install_dir "include") | ||
|
||
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") | ||
|
||
# Configuration | ||
set(version_config "${generated_dir}/${TARGET_NAME}ConfigVersion.cmake") | ||
set(project_config "${generated_dir}/${TARGET_NAME}Config.cmake") | ||
set(targets_export_name "${TARGET_NAME}Targets") | ||
set(namespace "${TARGET_NAME}::") | ||
|
||
include(CMakePackageConfigHelpers) | ||
|
||
write_basic_package_version_file( | ||
"${version_config}" COMPATIBILITY SameMajorVersion | ||
) | ||
|
||
configure_package_config_file( | ||
"cmake/Config.cmake.in" | ||
"${project_config}" | ||
INSTALL_DESTINATION "${config_install_dir}" | ||
) | ||
|
||
install( | ||
TARGETS thread-pool-cpp | ||
EXPORT "${targets_export_name}" | ||
LIBRARY DESTINATION "lib" | ||
ARCHIVE DESTINATION "lib" | ||
RUNTIME DESTINATION "bin" | ||
INCLUDES DESTINATION "${include_install_dir}" | ||
) | ||
|
||
install( | ||
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/thread_pool | ||
DESTINATION "${include_install_dir}" | ||
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" | ||
) | ||
|
||
install( | ||
FILES "${project_config}" "${version_config}" | ||
DESTINATION "${config_install_dir}" | ||
) | ||
|
||
# Install as header-only library | ||
set_source_files_properties(${INSTALL_FILES_LIST} PROPERTIES HEADER_FILE_ONLY 1) | ||
add_library(HEADER_ONLY_TARGET STATIC ${INSTALL_FILES_LIST}) | ||
set_target_properties(HEADER_ONLY_TARGET PROPERTIES LINKER_LANGUAGE CXX) | ||
install(DIRECTORY ${THREAD_POOL_CPP_INC_DIR} DESTINATION "include") | ||
install( | ||
EXPORT "${targets_export_name}" | ||
NAMESPACE "${namespace}" | ||
DESTINATION "${config_install_dir}" | ||
) |
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,63 @@ | ||
# Lineage: ruslo/hunter tests scripts | ||
# test | ||
|
||
os: Visual Studio 2015 | ||
|
||
environment: | ||
|
||
matrix: | ||
|
||
- TOOLCHAIN: "vs-14-2015-sdk-8-1" | ||
CONFIG: Release | ||
HAS_CPP14: OFF | ||
|
||
- TOOLCHAIN: "vs-14-2015-sdk-8-1" | ||
CONFIG: Debug | ||
HAS_CPP14: OFF | ||
|
||
- TOOLCHAIN: "vs-14-2015-win64-sdk-8-1" | ||
CONFIG: Release | ||
HAS_CPP14: OFF | ||
|
||
- TOOLCHAIN: "vs-14-2015-win64-sdk-8-1" | ||
CONFIG: Debug | ||
HAS_CPP14: OFF | ||
|
||
install: | ||
# Python 3 | ||
- cmd: set PATH=C:\Python34-x64;C:\Python34-x64\Scripts;%PATH% | ||
|
||
# Install Python package 'requests' | ||
- cmd: pip install requests | ||
|
||
# Install latest Polly toolchains and scripts | ||
- cmd: appveyor DownloadFile https://github.com/ruslo/polly/archive/master.zip | ||
- cmd: 7z x master.zip | ||
- cmd: set POLLY_ROOT=%cd%\polly-master | ||
|
||
# Install dependencies (CMake, Ninja) | ||
- cmd: python %POLLY_ROOT%\bin\install-ci-dependencies.py | ||
|
||
# Tune locations | ||
- cmd: set PATH=%cd%\_ci\cmake\bin;%PATH% | ||
- cmd: set PATH=%cd%\_ci\ninja;%PATH% | ||
|
||
# Remove entry with sh.exe from PATH to fix error with MinGW toolchain | ||
# (For MinGW make to work correctly sh.exe must NOT be in your path) | ||
# * http://stackoverflow.com/a/3870338/2288008 | ||
- cmd: set PATH=%PATH:C:\Program Files\Git\usr\bin;=% | ||
|
||
# Use MinGW from Qt tools because version is higher | ||
# * http://www.appveyor.com/docs/installed-software#qt | ||
- cmd: set MINGW_PATH=C:\Qt\Tools\mingw492_32\bin | ||
|
||
# MSYS2 location | ||
- cmd: set MSYS_PATH=C:\msys64\usr\bin | ||
|
||
build_script: | ||
|
||
- cmd: bin\build-appveyor.cmd "%CONFIG%" "%TOOLCHAIN%" "%HAS_CPP14%" | ||
|
||
branches: | ||
except: | ||
- /^pr\..*/ |
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,11 +1,4 @@ | ||
#benchmark | ||
|
||
include_directories("${THREAD_POOL_CPP_INC_DIR}") | ||
|
||
find_package(Boost REQUIRED COMPONENTS system) | ||
|
||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
include_directories(${Boost_INCLUDE_DIR}) | ||
add_executable(benchmark benchmark.cpp) | ||
target_link_libraries(benchmark ${Boost_LIBRARIES} pthread) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this work to avoid the explicit branching? https://cmake.org/cmake/help/v3.1/prop_tgt/CXX_STANDARD.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure. I will take a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this isn't supported for interface libraries: http://stackoverflow.com/q/29687331
"Indeed, it is a deliberate design choice not to support a INTERFACE_CXX_STANDARD target property. See also the CMAKE_CXX_STANDARD variable. "
But the target_compile_features() are.... That may not necessarily help too much.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think something like this might work (and is a little cleaner):