forked from StirlingLabs/jthread
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
162 lines (137 loc) · 5.68 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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
cmake_minimum_required(VERSION 3.13)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(jthread VERSION 24.00.0
HOMEPAGE_URL https://github.com/StirlingLabs/jthread
LANGUAGES CXX)
option(ENABLE_JTHREAD_TESTS "Enable jthread tests" OFF)
add_library(jthread INTERFACE)
add_library(nonstd::jthread ALIAS jthread)
target_sources(jthread INTERFACE include/nonstd/jthread.hpp include/nonstd/stop_token.hpp)
target_include_directories(jthread
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_features(jthread INTERFACE cxx_std_17)
include_directories(include)
include(GNUInstallDirs)
install(TARGETS jthread
EXPORT jthread_Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if (ENABLE_JTHREAD_TESTS)
enable_testing()
add_executable(test_stoken
include/nonstd/stop_token.hpp
source/condition_variable_any2.hpp
source/test_stoken.cpp
source/test.hpp)
add_test(NAME test_stoken COMMAND test_stoken)
set_tests_properties(test_stoken PROPERTIES TIMEOUT 30)
add_executable(test_stokencb
include/nonstd/stop_token.hpp
source/condition_variable_any2.hpp
source/test_stokencb.cpp
source/test.hpp)
add_test(NAME test_stokencb COMMAND test_stokencb)
set_tests_properties(test_stokencb PROPERTIES TIMEOUT 30)
add_executable(test_stokenrace
include/nonstd/stop_token.hpp
source/condition_variable_any2.hpp
source/test_stokenrace.cpp
source/test.hpp)
add_test(NAME test_stokenrace COMMAND test_stokenrace)
set_tests_properties(test_stokenrace PROPERTIES TIMEOUT 30)
add_executable(test_stopcb
include/nonstd/stop_token.hpp
source/test_stopcb.cpp
source/test.hpp)
add_test(NAME test_stopcb COMMAND test_stopcb)
set_tests_properties(test_stopcb PROPERTIES TIMEOUT 30)
add_executable(test_jthread1
include/nonstd/stop_token.hpp
source/condition_variable_any2.hpp
include/nonstd/jthread.hpp
source/test_jthread1.cpp
source/test.hpp)
add_test(NAME test_jthread1 COMMAND test_jthread1)
set_tests_properties(test_jthread1 PROPERTIES TIMEOUT 30)
add_executable(test_jthread2
include/nonstd/stop_token.hpp
source/condition_variable_any2.hpp
include/nonstd/jthread.hpp
source/test_jthread2.cpp
source/test.hpp)
add_test(NAME test_jthread2 COMMAND test_jthread2)
set_tests_properties(test_jthread2 PROPERTIES TIMEOUT 30)
# CV is just not ready for "prime time" (noop sched 1-core)
if (NOT DEFINED ENV{CI})
add_executable(test_cv
include/nonstd/stop_token.hpp
include/nonstd/jthread.hpp
source/condition_variable_any2.hpp
source/test_cv.cpp
source/test.hpp)
add_test(NAME test_cv COMMAND test_cv)
set_tests_properties(test_cv PROPERTIES TIMEOUT 30)
add_executable(test_cvcb
include/nonstd/stop_token.hpp
include/nonstd/jthread.hpp
source/condition_variable_any2.hpp
source/test_cvcb.cpp
source/test.hpp)
add_test(NAME test_cvcb COMMAND test_cvcb)
set_tests_properties(test_cvcb PROPERTIES TIMEOUT 30)
add_executable(test_cvrace
include/nonstd/stop_token.hpp
include/nonstd/jthread.hpp
source/condition_variable_any2.hpp
source/test_cvrace.cpp
source/test.hpp)
add_test(NAME test_cvrace COMMAND test_cvrace)
set_tests_properties(test_cvrace PROPERTIES TIMEOUT 30)
add_executable(test_cvrace_hh
include/nonstd/stop_token.hpp
include/nonstd/jthread.hpp
source/condition_variable_any2.hpp
source/test_cvrace_hh.cpp
source/test.hpp)
add_test(NAME test_cvrace_hh COMMAND test_cvrace_hh)
set_tests_properties(test_cvrace_hh PROPERTIES TIMEOUT 30)
add_executable(test_cvrace_stop
include/nonstd/stop_token.hpp
include/nonstd/jthread.hpp
source/condition_variable_any2.hpp
source/test_cvrace_stop.cpp
source/test.hpp)
add_test(NAME test_cvrace_stop COMMAND test_cvrace_stop)
set_tests_properties(test_cvrace_stop PROPERTIES TIMEOUT 30)
add_executable(test_cvprodcons
include/nonstd/stop_token.hpp
include/nonstd/jthread.hpp
source/condition_variable_any2.hpp
source/test_cvprodcons.cpp
source/test.hpp)
add_test(NAME test_cvprodcons COMMAND test_cvprodcons)
set_tests_properties(test_cvprodcons PROPERTIES TIMEOUT 30)
endif ()
# CV is just not ready for "prime time" (noop sched 1-core)
if (NOT DEFINED ENV{CI})
add_custom_target(build_tests)
add_dependencies(build_tests
test_stoken
test_stokencb
test_stokenrace
test_stopcb
test_jthread1
test_jthread2
test_cv
test_cvcb
test_cvrace
test_cvrace_hh
test_cvrace_stop
test_cvprodcons)
endif ()
endif ()