Skip to content

Commit

Permalink
EMSCRIPTEN support in cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
dancazarin committed Feb 13, 2024
1 parent 31166bd commit 1fda4f0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 29 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 ()
Expand Down
6 changes: 5 additions & 1 deletion cmake/target_set_arch.cmake
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
29 changes: 1 addition & 28 deletions include/kfr/runtime/cpuid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1fda4f0

Please sign in to comment.