Skip to content

Commit

Permalink
Merge pull request #372 from DerThorsten/unify_wasm_kernels
Browse files Browse the repository at this point in the history
unify wasm options
  • Loading branch information
JohanMabille authored Nov 28, 2023
2 parents 30e0a7b + e687711 commit 3fc567a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
9 changes: 4 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,14 @@ message(STATUS "xeus binary version: v${XEUS_BINARY_VERSION}")
option(XEUS_BUILD_SHARED_LIBS "Build xeus shared library." ON)
option(XEUS_BUILD_STATIC_LIBS "Build xeus static library (default if BUILD_SHARED_LIBS is OFF)." ON)
option(XEUS_STATIC_DEPENDENCIES "link statically with xeus dependencies" OFF)
option(XEUS_EMSCRIPTEN_WASM_BUILD "build for wasm via emscripten" OFF)

# Test options
option(XEUS_BUILD_TESTS "xeus test suite" OFF)

# Emscripten wasm build configuration
# ===================================

if(XEUS_EMSCRIPTEN_WASM_BUILD)
if(EMSCRIPTEN)
SET(XEUS_BUILD_SHARED_LIBS OFF)
SET(XEUS_BUILD_STATIC_LIBS ON)
endif()
Expand All @@ -70,7 +69,7 @@ endif()
message(STATUS "XEUS_BUILD_SHARED_LIBS: ${XEUS_BUILD_SHARED_LIBS}")
message(STATUS "XEUS_BUILD_STATIC_LIBS: ${XEUS_BUILD_STATIC_LIBS}")
message(STATUS "XEUS_STATIC_DEPENDENCIES: ${XEUS_STATIC_DEPENDENCIES}")
message(STATUS "XEUS_EMSCRIPTEN_WASM_BUILD: ${XEUS_EMSCRIPTEN_WASM_BUILD}")
message(STATUS "XEUS_EMSCRIPTEN_WASM_BUILD: ${EMSCRIPTEN}")
message(STATUS "XEUS_BUILD_TESTS: ${XEUS_BUILD_TESTS}")

# Dependencies
Expand Down Expand Up @@ -169,7 +168,7 @@ macro(xeus_create_target target_name linkage output_name)
PUBLIC xtl
)

if (NOT MSVC AND NOT XEUS_EMSCRIPTEN_WASM_BUILD)
if (NOT MSVC AND NOT EMSCRIPTEN)
if (APPLE)
target_link_libraries(${target_name} PUBLIC "-framework CoreFoundation")
else ()
Expand Down Expand Up @@ -251,7 +250,7 @@ macro(xeus_create_target target_name linkage output_name)
endif ()
endif ()

if (XEUS_EMSCRIPTEN_WASM_BUILD)
if (EMSCRIPTEN)
target_compile_definitions(${target_name} PRIVATE XEUS_EMSCRIPTEN_WASM_BUILD)
xeus_wasm_compile_options(${target_name})
endif()
Expand Down
17 changes: 3 additions & 14 deletions cmake/WasmBuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function(xeus_wasm_compile_options target)
PUBLIC "SHELL: -s USE_PTHREADS=0"
PUBLIC "SHELL: -fexceptions"
)
set_property(TARGET ${target} PROPERTY POSITION_INDEPENDENT_CODE ON)
endfunction()

function(xeus_wasm_link_options target environment)
Expand All @@ -37,19 +38,7 @@ function(xeus_wasm_link_options target environment)
PUBLIC "SHELL: -s TOTAL_STACK=32mb"
PUBLIC "SHELL: -s INITIAL_MEMORY=128mb"
PUBLIC "SHELL: -s WASM_BIGINT"
)
endfunction()

function(xeus_wasm_fs_options target)
target_link_options("${target}"
PUBLIC "SHELL: -s FORCE_FILESYSTEM"
PUBLIC "SHELL: -s MAIN_MODULE=1"
)
endfunction()

function(xeus_wasm_async_options target)
target_link_options("${target}"
INTERFACE "SHELL: -s ASYNCIFY=1"
INTERFACE "SHELL: -s 'ASYNCIFY_IMPORTS=[\"get_stdin\"]'"
INTERFACE "SHELL: -s 'ASYNCIFY_STACK_SIZE=100000'"
)
endfunction()
endfunction()

0 comments on commit 3fc567a

Please sign in to comment.