-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
47 lines (37 loc) · 1.3 KB
/
Copy pathCMakeLists.txt
File metadata and controls
47 lines (37 loc) · 1.3 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
cmake_minimum_required(VERSION 3.20)
project(ThreadPool)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "" FORCE)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(ENABLE_TSAN "Build with ThreadSanitizer" OFF)
if(ENABLE_TSAN)
add_compile_options(-Wall -Wextra -Wshadow -fsanitize=thread -g)
add_link_options(-fsanitize=thread)
else()
add_compile_options(-Wall -Wextra -Wshadow -fsanitize=address,undefined -g)
add_link_options(-fsanitize=address,undefined)
endif()
find_package(Threads REQUIRED)
# --- library ---
add_library(threadpool src/ThreadPool.cpp src/Worker.cpp)
target_include_directories(threadpool PUBLIC include)
target_link_libraries(threadpool PUBLIC Threads::Threads)
# --- demo app ---
add_executable(threadpool_demo src/main.cpp)
target_link_libraries(threadpool_demo PRIVATE threadpool)
# --- tests ---
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.15.2.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
FetchContent_MakeAvailable(googletest)
enable_testing()
add_executable(unit_tests tests/threadpool_test.cpp)
target_link_libraries(unit_tests PRIVATE threadpool GTest::gtest_main)
include(GoogleTest)
gtest_discover_tests(unit_tests)