@@ -50,9 +50,9 @@ OPTION(XEUS_CPP_BUILD_EXECUTABLE "Build the xcpp executable" ON)
50
50
OPTION (XEUS_CPP_USE_SHARED_XEUS "Link xcpp with the xeus shared library (instead of the static library)" ON )
51
51
OPTION (XEUS_CPP_USE_SHARED_XEUS_CPP "Link xcpp with the xeus shared library (instead of the static library)" ON )
52
52
53
- OPTION (XEUS_CPP_EMSCRIPTEN_WASM_BUILD "Build for wasm with emscripten" OFF )
54
53
55
- if (XEUS_CPP_EMSCRIPTEN_WASM_BUILD )
54
+
55
+ if (EMSCRIPTEN )
56
56
add_compile_definitions (XEUS_CPP_EMSCRIPTEN_WASM_BUILD )
57
57
message ("Build with emscripten" )
58
58
SET (XEUS_CPP_BUILD_STATIC ON )
90
90
endif ()
91
91
92
92
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel" )
93
- if (NOT XEUS_CPP_EMSCRIPTEN_WASM_BUILD )
93
+ if (NOT EMSCRIPTEN )
94
94
add_compile_options (-Wunused-parameter -Wextra -Wreorder )
95
95
endif ()
96
96
@@ -103,7 +103,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"
103
103
endif ()
104
104
endif ()
105
105
106
- if (XEUS_CPP_EMSCRIPTEN_WASM_BUILD )
106
+ if (EMSCRIPTEN )
107
107
# ENV (https://github.com/emscripten-core/emscripten/commit/6d9681ad04f60b41ef6345ab06c29bbc9eeb84e0)
108
108
set (EMSCRIPTEN_FEATURES "${EMSCRIPTEN_FEATURES} -s \" EXTRA_EXPORTED_RUNTIME_METHODS=[ENV']\" " )
109
109
endif ()
@@ -131,6 +131,10 @@ set(XEUS_CPP_SRC
131
131
src/xparser.cpp
132
132
)
133
133
134
+ if (EMSCRIPTEN )
135
+ list (APPEND XEUS_CPP_SRC src/xinterpreter_wasm.cpp )
136
+ endif ()
137
+
134
138
set (XEUS_CPP_MAIN_SRC
135
139
src/main.cpp
136
140
)
@@ -192,7 +196,7 @@ macro(xeus_cpp_set_kernel_options target_name)
192
196
target_link_libraries (${target_name} PRIVATE xeus-cpp-static )
193
197
endif ()
194
198
195
- if (NOT XEUS_CPP_EMSCRIPTEN_WASM_BUILD )
199
+ if (NOT EMSCRIPTEN )
196
200
find_package (Threads )
197
201
target_link_libraries (${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT} )
198
202
endif ()
@@ -238,7 +242,7 @@ macro(xeus_cpp_create_target target_name linkage output_name)
238
242
elseif (APPLE )
239
243
target_link_libraries (${target_name} PRIVATE "-undefined dynamic_lookup" )
240
244
endif ()
241
- if (NOT XEUS_CPP_EMSCRIPTEN_WASM_BUILD )
245
+ if (NOT EMSCRIPTEN )
242
246
find_package (Threads ) # TODO: add Threads as a dependence of xeus-static?
243
247
target_link_libraries (${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT} )
244
248
endif ()
@@ -291,14 +295,14 @@ if (XEUS_CPP_BUILD_EXECUTABLE)
291
295
target_link_libraries (xcpp PRIVATE xeus-zmq )
292
296
endif ()
293
297
294
- if (XEUS_CPP_EMSCRIPTEN_WASM_BUILD )
298
+ if (EMSCRIPTEN )
295
299
include (WasmBuildOptions )
296
300
find_package (xeus-lite REQUIRED )
297
- add_executable (xcpp_wasm src/main_emscripten_kernel.cpp )
298
- target_link_libraries (xcpp_wasm PRIVATE xeus-lite )
299
- xeus_cpp_set_kernel_options (xcpp_wasm )
300
- xeus_wasm_compile_options (xcpp_wasm )
301
- xeus_wasm_link_options (xcpp_wasm "web,worker" )
301
+ add_executable (xcpp src/main_emscripten_kernel.cpp )
302
+ target_link_libraries (xcpp PRIVATE xeus-lite )
303
+ xeus_cpp_set_kernel_options (xcpp )
304
+ xeus_wasm_compile_options (xcpp )
305
+ xeus_wasm_link_options (xcpp "web,worker" )
302
306
endif ()
303
307
304
308
# Installation
@@ -325,7 +329,9 @@ endif ()
325
329
if (XEUS_CPP_BUILD_EXECUTABLE )
326
330
install (TARGETS xcpp
327
331
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
332
+ endif ()
328
333
334
+ if (XEUS_CPP_BUILD_EXECUTABLE OR EMSCRIPTEN )
329
335
# Configuration and data directories for jupyter and xeus-cpp
330
336
set (XJUPYTER_DATA_DIR "share/jupyter" CACHE STRING "Jupyter data directory" )
331
337
@@ -391,13 +397,13 @@ if (XEUS_CPP_BUILD_SHARED)
391
397
DESTINATION ${XEUS_CPP_CMAKECONFIG_INSTALL_DIR} )
392
398
endif ()
393
399
394
- if (XEUS_CPP_EMSCRIPTEN_WASM_BUILD )
395
- install (TARGETS xcpp_wasm
400
+ if (EMSCRIPTEN )
401
+ install (TARGETS xcpp
396
402
ARCHIVE DESTINATION ${XEUS_CPP_CMAKECONFIG_INSTALL_DIR} )
397
403
398
404
install (FILES
399
- "$<TARGET_FILE_DIR:xcpp_wasm>/xcpp_wasm .js"
400
- "$<TARGET_FILE_DIR:xcpp_wasm>/xcpp_wasm .wasm"
405
+ "$<TARGET_FILE_DIR:xcpp>/xcpp .js"
406
+ "$<TARGET_FILE_DIR:xcpp>/xcpp .wasm"
401
407
DESTINATION ${CMAKE_INSTALL_BINDIR} )
402
408
endif ()
403
409
0 commit comments