diff --git a/CMakeLists.txt b/CMakeLists.txt index 680f96f..9379a50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.16.3) -project(rang +project(rang VERSION 3.2.0 LANGUAGES CXX) diff --git a/include/rang.hpp b/include/rang.hpp index 831eda4..1387dd4 100644 --- a/include/rang.hpp +++ b/include/rang.hpp @@ -7,6 +7,8 @@ #define OS_WIN #elif defined(__APPLE__) || defined(__MACH__) #define OS_MAC +#elif defined(__wasi__) +#define OS_WASI #else #error Unknown Platform #endif @@ -37,7 +39,10 @@ #endif #include +// As of WASI-SDK 12, does not support atomic +#ifndef OS_WASI #include +#endif #include #include #include @@ -124,21 +129,33 @@ enum class winTerm { // Windows Terminal Mode namespace rang_implementation { +#ifndef OS_WASI inline std::atomic &controlMode() noexcept { static std::atomic value(control::Auto); +#else + inline control &controlMode() noexcept + { + static control value(control::Auto); +#endif return value; } +#ifndef OS_WASI inline std::atomic &winTermMode() noexcept { static std::atomic termMode(winTerm::Auto); +#else + inline winTerm &winTermMode() noexcept + { + static winTerm termMode(winTerm::Auto); +#endif return termMode; } inline bool supportsColor() noexcept { -#if defined(OS_LINUX) || defined(OS_MAC) +#if defined(OS_LINUX) || defined(OS_MAC) || defined(OS_WASI) static const bool result = [] { const char *Terms[]