Skip to content

Commit 117b3f7

Browse files
authored
enable c++20 (#173)
Adds checks for whether the toolchain in use is using libc++ and if it only has an experimental version of memory_resource Essentially this is necessary to support building c++17/20 with older clangs using libc++.
1 parent 436d339 commit 117b3f7

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

CheckExperimentalMemoryResource.cmake

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
include(CheckCXXSourceCompiles)
2+
3+
# The libc++ implementation that ships with clang < v16 still
4+
# has the memory_resource header under experimental.
5+
#
6+
# This functions checks if we are using such a standard library
7+
# implementation.
8+
#
9+
function(check_experimental_memory_resource success)
10+
check_cxx_source_compiles("
11+
#include <experimental/memory_resource>
12+
int main() {
13+
return 0;
14+
}
15+
" ${success})
16+
endfunction()

CheckLibcpp.cmake

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
include(CheckCXXSourceCompiles)
2+
3+
# Checks if libc++ is being used
4+
#
5+
function(check_libcpp success)
6+
check_cxx_source_compiles("
7+
#include <iostream>
8+
int a =
9+
#ifdef _LIBCPP_VERSION
10+
1;
11+
#else
12+
kdfasfdl
13+
#endif
14+
int main() {
15+
return 0;
16+
}
17+
" ${success})
18+
endfunction()

0 commit comments

Comments
 (0)