From 117b3f73f44f81ead09320c4bd0aa7fce94a5e39 Mon Sep 17 00:00:00 2001 From: Isaac Torres Date: Tue, 9 Apr 2024 15:27:23 -0700 Subject: [PATCH] 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++. --- CheckExperimentalMemoryResource.cmake | 16 ++++++++++++++++ CheckLibcpp.cmake | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 CheckExperimentalMemoryResource.cmake create mode 100644 CheckLibcpp.cmake diff --git a/CheckExperimentalMemoryResource.cmake b/CheckExperimentalMemoryResource.cmake new file mode 100644 index 0000000..d006106 --- /dev/null +++ b/CheckExperimentalMemoryResource.cmake @@ -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 + int main() { + return 0; + } + " ${success}) +endfunction() diff --git a/CheckLibcpp.cmake b/CheckLibcpp.cmake new file mode 100644 index 0000000..f01c522 --- /dev/null +++ b/CheckLibcpp.cmake @@ -0,0 +1,18 @@ +include(CheckCXXSourceCompiles) + +# Checks if libc++ is being used +# +function(check_libcpp success) + check_cxx_source_compiles(" + #include + int a = + #ifdef _LIBCPP_VERSION + 1; + #else + kdfasfdl + #endif + int main() { + return 0; + } + " ${success}) +endfunction()