Skip to content

Commit

Permalink
enable c++20 (#173)
Browse files Browse the repository at this point in the history
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++.
  • Loading branch information
jungleraptor committed Apr 9, 2024
1 parent 436d339 commit 117b3f7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions CheckExperimentalMemoryResource.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include(CheckCXXSourceCompiles)

# The libc++ implementation that ships with clang < v16 still
# has the memory_resource header under experimental.
#
# This functions checks if we are using such a standard library
# implementation.
#
function(check_experimental_memory_resource success)
check_cxx_source_compiles("
#include <experimental/memory_resource>
int main() {
return 0;
}
" ${success})
endfunction()
18 changes: 18 additions & 0 deletions CheckLibcpp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
include(CheckCXXSourceCompiles)

# Checks if libc++ is being used
#
function(check_libcpp success)
check_cxx_source_compiles("
#include <iostream>
int a =
#ifdef _LIBCPP_VERSION
1;
#else
kdfasfdl
#endif
int main() {
return 0;
}
" ${success})
endfunction()

0 comments on commit 117b3f7

Please sign in to comment.