@@ -60,9 +60,8 @@ OPTION(XSQL_USE_SHARED_XEUS_SQLITE "Link xsqlite with the xeus-sqlite shared lib
60
60
61
61
OPTION (XSQL_DOWNLOAD_GTEST "build gtest from downloaded sources" OFF )
62
62
OPTION (XSQL_BUILD_TESTS "xeus-sqlite test suite" OFF )
63
- OPTION (XSQL_EMSCRIPTEN_WASM_BUILD "Build for wasm with emscripten" OFF )
64
63
65
- if (XSQL_EMSCRIPTEN_WASM_BUILD )
64
+ if (EMSCRIPTEN )
66
65
# for the emscripten build we need a FindSQLite3.cmake since
67
66
# we install sqlite in a non-standart way
68
67
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /cmake_emscripten;${CMAKE_MODULE_PATH} " )
@@ -114,7 +113,7 @@ string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE)
114
113
115
114
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX} /lib; ${CMAKE_INSTALL_PREFIX} /${CMAKE_INSTALL_LIBDIR} " )
116
115
117
- if (XSQL_EMSCRIPTEN_WASM_BUILD )
116
+ if (EMSCRIPTEN )
118
117
add_compile_definitions (XSQL_EMSCRIPTEN_WASM_BUILD )
119
118
endif ()
120
119
@@ -218,10 +217,9 @@ macro(xsql_create_target target_name linkage output_name)
218
217
${XSQL_XEUS_TARGET}
219
218
xvega
220
219
SQLiteCpp
221
- SQLite::SQLite3
222
220
)
223
221
224
- if (NOT XSQL_EMSCRIPTEN_WASM_BUILD )
222
+ if (NOT EMSCRIPTEN )
225
223
# find_package(Threads) # TODO: add Threads as a dependence of xeus-static?
226
224
target_link_libraries (${target_name} PRIVATE ${CMAKE_THREAD_LIBS_INIT} )
227
225
endif ()
@@ -284,18 +282,23 @@ if(XSQL_BUILD_TESTS)
284
282
add_subdirectory (test )
285
283
endif ()
286
284
287
- if (XSQL_EMSCRIPTEN_WASM_BUILD )
285
+ if (EMSCRIPTEN )
288
286
find_package (xeus-lite REQUIRED )
289
- add_executable (xeus_kernel src/main_emscripten_kernel.cpp )
290
- target_link_libraries (xeus_kernel PRIVATE xeus-sqlite-static xeus-lite )
291
- target_compile_features (xeus_kernel PRIVATE cxx_std_17 )
292
- target_link_options (xeus_kernel
287
+ include (WasmBuildOptions )
288
+ add_executable (xsqlite src/main_emscripten_kernel.cpp )
289
+ target_link_libraries (xsqlite PRIVATE xeus-sqlite-static xeus-lite )
290
+ target_compile_features (xsqlite PRIVATE cxx_std_17 )
291
+
292
+ xeus_wasm_compile_options (xsqlite )
293
+ xeus_wasm_link_options (xsqlite "web,worker" )
294
+
295
+ target_link_options (xsqlite
293
296
PUBLIC "SHELL: -s FETCH=1"
294
297
PUBLIC "SHELL: -s NO_EXIT_RUNTIME=1"
295
298
PUBLIC "SHELL: -s 'ASYNCIFY_IMPORTS=[\" async_ems_init_idbfs\" , \" async_ems_sync_db\" ]'"
296
299
PUBLIC "SHELL: -s FORCE_FILESYSTEM=1"
297
300
)
298
- target_link_libraries (xeus_kernel idbfs.js )
301
+ # target_link_libraries(xsqlite idbfs.js)
299
302
endif ()
300
303
301
304
# Installation
@@ -323,7 +326,9 @@ endif ()
323
326
if (XSQL_BUILD_XSQLITE_EXECUTABLE )
324
327
install (TARGETS xsqlite
325
328
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
329
+ endif ()
326
330
331
+ if (XSQL_BUILD_XSQLITE_EXECUTABLE OR EMSCRIPTEN )
327
332
# Configuration and data directories for jupyter and xeus_sqlite
328
333
set (XJUPYTER_DATA_DIR "share/jupyter" CACHE STRING "Jupyter data directory" )
329
334
@@ -368,3 +373,11 @@ if (XSQL_BUILD_SHARED)
368
373
FILE ${PROJECT_NAME} Targets.cmake
369
374
DESTINATION ${XEUS_SQLITE_CMAKECONFIG_INSTALL_DIR} )
370
375
endif ()
376
+
377
+ if (EMSCRIPTEN )
378
+ install (FILES
379
+ "$<TARGET_FILE_DIR:xsqlite>/xsqlite.js"
380
+ "$<TARGET_FILE_DIR:xsqlite>/xsqlite.wasm"
381
+ DESTINATION ${XJUPYTER_DATA_DIR} /kernels/xsqlite )
382
+
383
+ endif ()
0 commit comments