-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
33 lines (25 loc) · 1.07 KB
/
Copy pathCMakeLists.txt
File metadata and controls
33 lines (25 loc) · 1.07 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
cmake_minimum_required(VERSION 3.16)
project(cpp_threadpool LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Header-only library target.
add_library(threadpool INTERFACE)
target_include_directories(threadpool INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)
find_package(Threads REQUIRED)
target_link_libraries(threadpool INTERFACE Threads::Threads)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
target_compile_options(threadpool INTERFACE -Wall -Wextra)
endif()
# Optional sanitizer: configure with -DTP_SANITIZE=thread (or address).
set(TP_SANITIZE "" CACHE STRING "Enable a sanitizer: thread, address, or empty")
if(TP_SANITIZE)
add_compile_options(-fsanitize=${TP_SANITIZE} -g -O1)
add_link_options(-fsanitize=${TP_SANITIZE})
endif()
enable_testing()
add_executable(threadpool_tests tests/thread_pool_test.cpp)
target_link_libraries(threadpool_tests PRIVATE threadpool)
add_test(NAME threadpool_tests COMMAND threadpool_tests)
add_executable(demo examples/main.cpp)
target_link_libraries(demo PRIVATE threadpool)