From 0f56e58742a64a993e4f2f7b34cbafccb613ebcd Mon Sep 17 00:00:00 2001 From: Jordan Woyak Date: Fri, 9 Oct 2026 14:51:43 -0500 Subject: [PATCH] CMakeLists: Add -fexperimental-library to allow use of std::jthread with libc++ 18. --- Source/CMakeLists.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 140abb02d7..cdfabd36c8 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -19,6 +19,19 @@ if (NOT MSVC) set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) + + # std::jthread is guarded behind -fexperimental-library prior to libc++ version 20 + check_cxx_source_compiles([[ + #include + #if defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 200000 + #error libc++ version < 20 + #endif + int main() {} + ]] IS_JTHREAD_STABLE) + + if(NOT IS_JTHREAD_STABLE) + add_compile_options(-fexperimental-library) + endif() endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON)