-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
31 lines (23 loc) · 1.12 KB
/
CMakeLists.txt
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
project(threadpool)
cmake_minimum_required(VERSION 3.1)
include(CTest)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
add_definitions(-Wall -Wextra)
add_library(threadpool STATIC ${CMAKE_CURRENT_SOURCE_DIR}/threadpool.cpp)
set_target_properties(threadpool PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(threadpool Threads::Threads)
if (BUILD_TESTING)
set(CMAKE_CXX_FLAGS "-g -O0 -Wall -fprofile-arcs -ftest-coverage")
add_executable(check ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_pool.cpp)
target_link_libraries(check threadpool)
add_test(NAME threadpool_standalone_tests COMMAND check)
add_executable(check_latch ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_latch.cpp)
target_link_libraries(check_latch Threads::Threads)
add_test(NAME latch_standalone_tests COMMAND check_latch)
add_executable(example_latchpool ${CMAKE_CURRENT_SOURCE_DIR}/example.cpp)
target_link_libraries(example_latchpool threadpool Threads::Threads)
add_test(NAME latch_pool_example COMMAND example_latchpool)
endif (BUILD_TESTING)