Skip to content

Commit e3a09fa

Browse files
committed
Fix Emscripten CMake configuration due to --preload-file
Specify `--preload-file data` linker flag to preload data directory into the filesystem in the `CMakeLists.txt` file as an additional target link option instead of specifying it in the `Emscripten.toolchain` file, as the latter caused the CMake configuration steps to fail due to the `data` folder being missing during this phase: ``` error: data does not exist em++: error: '/emsdk/upstream/emscripten/tools/file_packager cmTC_83f35.data --from-emcc --preload data' failed (returned 1) ``` This was causing the CMake configuration phase to take longer, but building seemed to work anyway because it eventually falls back to some working defaults.
1 parent e23c815 commit e3a09fa

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,6 +3529,10 @@ foreach(target ${TARGETS})
35293529
if(ENABLE_IPO)
35303530
set_property(TARGET ${target} PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
35313531
endif()
3532+
if(TARGET_OS STREQUAL "emscripten")
3533+
# Preload data directory into the filesystem
3534+
target_link_options(${target} PRIVATE --preload-file data)
3535+
endif()
35323536
endforeach()
35333537

35343538
foreach(target ${TARGETS_LINK})

cmake/toolchains/Emscripten.toolchain

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ set(WASM_ENGINE_FLAGS "")
33
set(WASM_ENGINE_FLAGS "-s LLD_REPORT_UNDEFINED -s USE_PTHREADS=1")
44
# needed for loading files in a c-like style
55
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} -s FILESYSTEM=1 -s FORCE_FILESYSTEM=1")
6-
# load data directory to the filesystem
7-
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} --preload-file data")
86
# remove some annoyance for now, TODO
97
set(WASM_ENGINE_FLAGS "${WASM_ENGINE_FLAGS} --allow-multiple-definition -Wl,--shared-memory,--no-check-features")
108
# TODO

0 commit comments

Comments
 (0)