Skip to content

Commit f580853

Browse files
authored
Emscripten4x (#436)
1 parent 39effb7 commit f580853

File tree

1 file changed

+63
-30
lines changed

1 file changed

+63
-30
lines changed

cmake/WasmBuildOptions.cmake

Lines changed: 63 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,68 @@
77
# The full license is in the file LICENSE, distributed with this software. #
88
############################################################################
99

10-
# Module to set compiler and linker options for WASM builds
10+
if (EMSCRIPTEN_VERSION VERSION_LESS "4.0.0")
11+
message(STATUS "Emscripten version < 4.0.0")
12+
function(xeus_wasm_compile_options target)
13+
target_compile_options("${target}"
14+
PUBLIC --std=c++17
15+
PUBLIC -Wno-deprecated
16+
PUBLIC "SHELL: -fexceptions"
17+
)
18+
set_property(TARGET ${target} PROPERTY POSITION_INDEPENDENT_CODE ON)
19+
endfunction()
1120

12-
function(xeus_wasm_compile_options target)
13-
target_compile_options("${target}"
14-
PUBLIC --std=c++17
15-
PUBLIC -Wno-deprecated
16-
PUBLIC "SHELL: -fexceptions"
17-
)
18-
set_property(TARGET ${target} PROPERTY POSITION_INDEPENDENT_CODE ON)
19-
endfunction()
21+
function(xeus_wasm_link_options target environment)
22+
target_link_options("${target}"
23+
PUBLIC --bind
24+
PUBLIC -Wno-unused-command-line-argument
25+
PUBLIC "SHELL: -fexceptions"
26+
PUBLIC "SHELL: -s MODULARIZE=1"
27+
PUBLIC "SHELL: -s EXPORT_NAME=\"createXeusModule\""
28+
PUBLIC "SHELL: -s EXPORT_ES6=0"
29+
PUBLIC "SHELL: -s ASSERTIONS=0"
30+
PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
31+
PUBLIC "SHELL: -s EXIT_RUNTIME=1"
32+
PUBLIC "SHELL: -s WASM=1"
33+
PUBLIC "SHELL: -s ENVIRONMENT=${environment}"
34+
PUBLIC "SHELL: -s STACK_SIZE=32mb"
35+
PUBLIC "SHELL: -s INITIAL_MEMORY=128mb"
36+
PUBLIC "SHELL: -s WASM_BIGINT"
37+
PUBLIC "SHELL: -s EXPORTED_RUNTIME_METHODS='[\"FS\",\"ENV\",\"PATH\",\"LDSO\",\"loadDynamicLibrary\",\"ERRNO_CODES\"]'"
38+
PUBLIC "SHELL: -s FORCE_FILESYSTEM"
39+
PUBLIC "SHELL: -s MAIN_MODULE=1"
40+
)
41+
endfunction()
42+
else()
43+
message(STATUS "Emscripten version >= 4.0.0")
44+
function(xeus_wasm_compile_options target)
45+
target_compile_options("${target}"
46+
PUBLIC --std=c++17
47+
PUBLIC -Wno-deprecated
48+
PUBLIC "SHELL: -fwasm-exceptions"
49+
)
50+
set_property(TARGET ${target} PROPERTY POSITION_INDEPENDENT_CODE ON)
51+
endfunction()
2052

21-
function(xeus_wasm_link_options target environment)
22-
target_link_options("${target}"
23-
PUBLIC --bind
24-
PUBLIC -Wno-unused-command-line-argument
25-
PUBLIC "SHELL: -fexceptions"
26-
PUBLIC "SHELL: -s MODULARIZE=1"
27-
PUBLIC "SHELL: -s EXPORT_NAME=\"createXeusModule\""
28-
PUBLIC "SHELL: -s EXPORT_ES6=0"
29-
PUBLIC "SHELL: -s ASSERTIONS=0"
30-
PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
31-
PUBLIC "SHELL: -s EXIT_RUNTIME=1"
32-
PUBLIC "SHELL: -s WASM=1"
33-
PUBLIC "SHELL: -s ENVIRONMENT=${environment}"
34-
PUBLIC "SHELL: -s STACK_SIZE=32mb"
35-
PUBLIC "SHELL: -s INITIAL_MEMORY=128mb"
36-
PUBLIC "SHELL: -s WASM_BIGINT"
37-
PUBLIC "SHELL: -s EXPORTED_RUNTIME_METHODS='[\"FS\",\"ENV\",\"PATH\",\"LDSO\",\"loadDynamicLibrary\",\"ERRNO_CODES\"]'"
38-
PUBLIC "SHELL: -s FORCE_FILESYSTEM"
39-
PUBLIC "SHELL: -s MAIN_MODULE=1"
40-
)
41-
endfunction()
53+
function(xeus_wasm_link_options target environment)
54+
target_link_options("${target}"
55+
PUBLIC -Wno-unused-command-line-argument
56+
PUBLIC "SHELL: -lembind"
57+
PUBLIC "SHELL: -fwasm-exceptions"
58+
PUBLIC "SHELL: -s MODULARIZE=1"
59+
PUBLIC "SHELL: -s EXPORT_NAME=\"createXeusModule\""
60+
PUBLIC "SHELL: -s EXPORT_ES6=0"
61+
PUBLIC "SHELL: -s ASSERTIONS=0"
62+
PUBLIC "SHELL: -s ALLOW_MEMORY_GROWTH=1"
63+
PUBLIC "SHELL: -s EXIT_RUNTIME=1"
64+
PUBLIC "SHELL: -s WASM=1"
65+
PUBLIC "SHELL: -s ENVIRONMENT=${environment}"
66+
PUBLIC "SHELL: -s STACK_SIZE=32mb"
67+
PUBLIC "SHELL: -s INITIAL_MEMORY=128mb"
68+
PUBLIC "SHELL: -s WASM_BIGINT"
69+
PUBLIC "SHELL: -s EXPORTED_RUNTIME_METHODS='[\"FS\",\"ENV\",\"PATH\",\"LDSO\",\"ERRNO_CODES\"]'"
70+
PUBLIC "SHELL: -s FORCE_FILESYSTEM"
71+
PUBLIC "SHELL: -s MAIN_MODULE=1"
72+
)
73+
endfunction()
74+
endif()

0 commit comments

Comments
 (0)