-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
63 lines (51 loc) · 1.41 KB
/
CMakeLists.txt
File metadata and controls
63 lines (51 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
cmake_minimum_required(VERSION 3.16)
project(cpp-threadpool
VERSION 1.0.0
DESCRIPTION "Modern C++17 thread pool library"
LANGUAGES CXX
)
# C++17 required
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Options
option(THREADPOOL_BUILD_TESTS "Build unit tests" ON)
option(THREADPOOL_BUILD_EXAMPLES "Build examples" ON)
option(THREADPOOL_BUILD_BENCHMARKS "Build benchmarks" ON)
# Header-only library target
add_library(threadpool INTERFACE)
add_library(tp::threadpool ALIAS threadpool)
target_include_directories(threadpool INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_features(threadpool INTERFACE cxx_std_17)
# Find threads
find_package(Threads REQUIRED)
target_link_libraries(threadpool INTERFACE Threads::Threads)
# Tests
if(THREADPOOL_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
# Examples
if(THREADPOOL_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
# Benchmarks
if(THREADPOOL_BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
# Installation
include(GNUInstallDirs)
install(TARGETS threadpool
EXPORT threadpool-targets
)
install(DIRECTORY include/threadpool
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(EXPORT threadpool-targets
FILE threadpool-config.cmake
NAMESPACE tp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/threadpool
)