-
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 15 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 |
---|---|---|
@@ -1,23 +1,97 @@ | ||
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 VERSION 1.1.0) | ||
|
||
project(thread-pool-cpp) | ||
add_definitions(-std=c++14 -Wall -Werror -O3) | ||
|
||
option(THREAD_POOL_CPP_BUILD_TESTS "Build tests." OFF) | ||
option(THREAD_POOL_CPP_BUILD_BENCHMARKS "Build benchmarks." OFF) | ||
|
||
if(THREAD_POOL_CPP_BUILD_TESTS) | ||
include(CTest) | ||
endif() | ||
|
||
# Get all include files | ||
# 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) | ||
|
||
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 |
---|---|---|
@@ -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) | ||
|
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@PACKAGE_INIT@ | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") | ||
check_required_components("@PROJECT_NAME@") |
This file was deleted.
Oops, something went wrong.
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.
All occurrences of
size_t
should be properly qualified asstd::size_t
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.
Agreed. I can replace size_t -> std::size_t in this PR.