Skip to content
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

updates #13

Merged
merged 7 commits into from
Jan 19, 2024
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
5 changes: 2 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ jobs:
strategy:
fail-fast: false
matrix:
emsdk_ver: ["3.1.45", "latest"]

emsdk_ver: ["3.1.45"]
steps:
- uses: actions/checkout@v4

Expand All @@ -126,7 +125,7 @@ jobs:
source $CONDA_EMSDK_DIR/emsdk_env.sh

micromamba create -f environment-wasm-host.yml --platform=emscripten-wasm32

mkdir build
pushd build

Expand Down
36 changes: 19 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ option(XEUS_NELSON_BUILD_EXECUTABLE "Build the xnelson executable" ON)

option(XEUS_NELSON_USE_SHARED_XEUS "Link xnelson with the xeus shared library (instead of the static library)" ON)
option(XEUS_NELSON_USE_SHARED_XEUS_NELSON "Link xnelson with the xeus-nelson shared library (instead of the static library)" ON)
option(XEUS_NELSON_EMSCRIPTEN_WASM_BUILD "Build for wasm with emscripten" OFF)

if (XEUS_NELSON_EMSCRIPTEN_WASM_BUILD)
if (EMSCRIPTEN)
message(STATUS "Building with emscripten")
set(XEUS_NELSON_BUILD_STATIC ON)
set(XEUS_NELSON_BUILD_SHARED OFF)
set(XEUS_NELSON_BUILD_EXECUTABLE OFF)
set(XEUS_NELSON_USE_SHARED_XEUS OFF)
set(XEUS_NELSON_USE_SHARED_XEUS_NELSON OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif ()

# Dependencies
Expand Down Expand Up @@ -84,7 +84,7 @@ if (MSVC)
endif ()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
if (NOT XEUS_NELSON_EMSCRIPTEN_WASM_BUILD)
if (NOT EMSCRIPTEN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-parameter -Wextra -Wreorder")
endif ()

Expand Down Expand Up @@ -171,7 +171,7 @@ macro(xnelson_set_kernel_options target_name)
target_link_libraries(${target_name} PRIVATE xeus-nelson-static)
endif()

if (NOT XEUS_NELSON_EMSCRIPTEN_WASM_BUILD)
if (NOT EMSCRIPTEN)
find_package(Threads)
target_link_libraries(${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT})
endif ()
Expand Down Expand Up @@ -226,7 +226,7 @@ macro(xnelson_create_target target_name linkage output_name)
target_link_libraries(${target_name} PRIVATE "-undefined dynamic_lookup")
endif ()

if (NOT XEUS_NELSON_EMSCRIPTEN_WASM_BUILD)
if (NOT EMSCRIPTEN)
find_package(Threads) # TODO: add Threads as a dependence of xeus-static?
target_link_libraries(${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT})
endif ()
Expand Down Expand Up @@ -270,16 +270,16 @@ if (XEUS_NELSON_BUILD_EXECUTABLE)
target_link_libraries(xnelson PRIVATE xeus-zmq)
endif()

if (XEUS_NELSON_EMSCRIPTEN_WASM_BUILD)
if (EMSCRIPTEN)
include(WasmBuildOptions)
find_package(xeus-lite REQUIRED)
add_executable(xnelson_wasm src/main_emscripten_kernel.cpp)
target_link_libraries(xnelson_wasm PRIVATE xeus-lite)
target_compile_features(xnelson_wasm PRIVATE cxx_std_17)
target_compile_options(xnelson_wasm PRIVATE -fPIC)
xnelson_set_kernel_options(xnelson_wasm)
xeus_wasm_compile_options(xnelson_wasm)
xeus_wasm_link_options(xnelson_wasm "web,worker")
add_executable(xnelson src/main_emscripten_kernel.cpp)
target_link_libraries(xnelson PRIVATE xeus-lite)
target_compile_features(xnelson PRIVATE cxx_std_17)
target_compile_options(xnelson PRIVATE -fPIC)
xnelson_set_kernel_options(xnelson)
xeus_wasm_compile_options(xnelson)
xeus_wasm_link_options(xnelson "web,worker")
endif ()

# Installation
Expand All @@ -306,7 +306,9 @@ endif ()
if (XEUS_NELSON_BUILD_EXECUTABLE)
install(TARGETS xnelson
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

if (XEUS_NELSON_BUILD_EXECUTABLE OR EMSCRIPTEN)
# Configuration and data directories for jupyter and xeus-nelson
set(XJUPYTER_DATA_DIR "share/jupyter" CACHE STRING "Jupyter data directory")

Expand Down Expand Up @@ -352,12 +354,12 @@ if (XEUS_NELSON_BUILD_SHARED)
DESTINATION ${XEUS_NELSON_CMAKECONFIG_INSTALL_DIR})
endif ()

if(XEUS_NELSON_EMSCRIPTEN_WASM_BUILD)
install(TARGETS xnelson_wasm
if(EMSCRIPTEN)
install(TARGETS xnelson
ARCHIVE DESTINATION ${CMAKE_INSTALL_BINDIR})

install(FILES
"$<TARGET_FILE_DIR:xnelson_wasm>/xnelson_wasm.js"
"$<TARGET_FILE_DIR:xnelson_wasm>/xnelson_wasm.wasm"
"$<TARGET_FILE_DIR:xnelson>/xnelson.js"
"$<TARGET_FILE_DIR:xnelson>/xnelson.wasm"
DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()