commit 1fda4f030ebbd05f9dfc26a00b1c847b08f6c433
parent 31166bdb40db18bbda515c3c96bddd7b490dc80d
Author: [email protected] <[email protected]>
Date: Tue, 13 Feb 2024 18:55:48 +0000
EMSCRIPTEN support in cmake
Diffstat:
3 files changed, 15 insertions(+), 29 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -131,6 +131,11 @@ if (CPU_ARCH)
endif ()
endif ()
+if (EMSCRIPTEN)
+ set(KFR_ARCH "sse41" CACHE STRING "")
+ set(KFR_ENABLE_MULTIARCH OFF CACHE BOOL "")
+endif ()
+
set(X86 FALSE)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
set(X86 TRUE)
@@ -326,6 +331,10 @@ if (APPLE)
target_compile_options(kfr INTERFACE -faligned-allocation)
endif ()
+if (EMSCRIPTEN)
+ target_compile_options(kfr INTERFACE -msimd128)
+endif ()
+
if (MSVC)
target_compile_options(kfr INTERFACE -bigobj)
else ()
diff --git a/cmake/target_set_arch.cmake b/cmake/target_set_arch.cmake
@@ -1,4 +1,8 @@
-if (X86)
+if (EMSCRIPTEN)
+ function(target_set_arch TARGET MODE ARCH)
+ target_compile_options(${TARGET} ${MODE} -msse4.1)
+ endfunction()
+elseif (X86)
function(target_set_arch TARGET MODE ARCH)
diff --git a/include/kfr/runtime/cpuid.hpp b/include/kfr/runtime/cpuid.hpp
@@ -35,34 +35,7 @@
namespace kfr
{
-#if defined(__wasm)
-namespace internal_generic
-{
-template <size_t = 0>
-cpu_t detect_cpu()
-{
- #if defined(__AVX512F__)
- return cpu_t::avx512;
- #elif defined(__AVX2__)
- return cpu_t::avx2;
- #elif defined(__AVX__)
- return cpu_t::avx1;
- #elif defined(__SSE42__)
- return cpu_t::sse42;
- #elif defined(__SSE41__)
- return cpu_t::sse41;
- #elif defined(__SSSE3__)
- return cpu_t::ssse3;
- #elif defined(__SSE3__)
- return cpu_t::sse3;
- #elif defined(__SSE2__)
- return cpu_t::sse2;
- #else
- return cpu_t::lowest;
- #endif
-}
-}
-#elif defined(CMT_ARCH_X86)
+#if defined(CMT_ARCH_X86) && !defined(__wasm)
struct cpu_features
{
u32 max;