Skip to content

Switch to a shared xeus for the emscripten build #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ option(XEUS_CPP_BUILD_STATIC "Build xeus-cpp static library" ON)
option(XEUS_CPP_BUILD_SHARED "Split xcpp build into executable and library" ON)
option(XEUS_CPP_BUILD_EXECUTABLE "Build the xcpp executable" ON)

option(XEUS_CPP_USE_SHARED_XEUS "Link xcpp with the xeus shared library (instead of the static library)" ON)
option(XEUS_CPP_USE_SHARED_XEUS_CPP "Link xcpp with the xeus shared library (instead of the static library)" ON)
option(XEUS_CPP_USE_SHARED_XEUS "Link xcpp with the xeus shared library (instead of the static library)" ON)
option(XEUS_CPP_USE_SHARED_XEUS_CPP "Link xcpp with the xeus-cpp shared library (instead of the static library)" ON)
option(XEUS_CPP_EMSCRIPTEN_WASM_BUILD "Build for wasm with emscripten" OFF)

# Test options
Expand All @@ -77,10 +77,11 @@ endif()
if(EMSCRIPTEN)
add_compile_definitions(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
message("Build with emscripten")
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
set(XEUS_CPP_BUILD_STATIC ON)
set(XEUS_CPP_BUILD_SHARED OFF)
set(XEUS_CPP_BUILD_EXECUTABLE OFF)
set(XEUS_CPP_USE_SHARED_XEUS OFF)
set(XEUS_CPP_USE_SHARED_XEUS ON)
set(XEUS_CPP_USE_SHARED_XEUS_CPP OFF)
# ENV (https://github.com/emscripten-core/emscripten/commit/6d9681ad04f60b41ef6345ab06c29bbc9eeb84e0)
set(EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \"EXPORTED_RUNTIME_METHODS=[ENV']\"")
Expand Down Expand Up @@ -546,4 +547,4 @@ if(EMSCRIPTEN)
"$<TARGET_FILE_DIR:xcpp>/xcpp.wasm"
"$<TARGET_FILE_DIR:xcpp>/xcpp.data"
DESTINATION ${CMAKE_INSTALL_BINDIR})
endif ()
endif ()
1 change: 1 addition & 0 deletions share/jupyter/kernels/xcpp17/wasm_kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"metadata": {
"debugger": false,
"shared": {
"libxeus.so": "lib/libxeus.so",
"libclangCppInterOp.so": "lib/libclangCppInterOp.so"
}
}
Expand Down
1 change: 1 addition & 0 deletions share/jupyter/kernels/xcpp20/wasm_kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"metadata": {
"debugger": false,
"shared": {
"libxeus.so": "lib/libxeus.so",
"libclangCppInterOp.so": "lib/libclangCppInterOp.so"
}
}
Expand Down
1 change: 1 addition & 0 deletions share/jupyter/kernels/xcpp23/wasm_kernel.json.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"metadata": {
"debugger": false,
"shared": {
"libxeus.so": "lib/libxeus.so",
"libclangCppInterOp.so": "lib/libclangCppInterOp.so"
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ if(EMSCRIPTEN)
${CMAKE_CURRENT_BINARY_DIR}/libclangCppInterOp.so
COMMENT "Copying libclangCppInterOp.so to the test directory"
)

add_custom_command(TARGET test_xeus_cpp POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_INSTALL_PREFIX}/lib/libxeus.so
${CMAKE_CURRENT_BINARY_DIR}/libxeus.so
COMMENT "Copying libxeus.so to the test directory"
)
else()
find_package(Threads)

Expand Down