-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathpolyfill.cmake
53 lines (42 loc) · 1.03 KB
/
polyfill.cmake
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
cmake_policy(SET CMP0067 NEW)
include(CheckCXXSourceCompiles)
function(check_features)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
check_cxx_source_compiles(
"#include <thread>
int main()
{
std::jthread t{[]{}};
return 0;
}"
has_jthread
)
check_cxx_source_compiles(
"#include <functional>
int main()
{
std::move_only_function<void()> f{[]{}};
return 0;
}"
has_move_only_function
)
check_cxx_source_compiles(
"#include <expected>
int main()
{
std::expected<int, int> e{};
return 0;
}"
has_expected
)
if (NOT has_jthread)
set(saucer_polyfill_thread ON PARENT_SCOPE)
endif()
if (NOT has_move_only_function)
set(saucer_polyfill_functional ON PARENT_SCOPE)
endif()
if (NOT has_expected)
set(saucer_polyfill_expected ON PARENT_SCOPE)
endif()
endfunction()