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)