|
4 | 4 | cmake_minimum_required(VERSION 3.14) |
5 | 5 | project(wasm-apps) |
6 | 6 |
|
7 | | -# set(CMAKE_C_FLAGS "-nostdlib -pthread -Qunused-arguments") |
8 | | -# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -z stack-size=8192 -nostdlib") |
9 | | - |
10 | 7 | add_executable(mytest.wasm mytest.c) |
11 | | -target_link_libraries(mytest.wasm) |
12 | | -target_compile_options(mytest.wasm PRIVATE |
13 | | - -pthread |
14 | | -) |
| 8 | +target_compile_options(mytest.wasm PUBLIC -nostdlib) |
15 | 9 | target_link_options(mytest.wasm PRIVATE |
| 10 | + -nostdlib |
16 | 11 | LINKER:--allow-undefined |
17 | 12 | LINKER:--export-all |
| 13 | + LINKER:--initial-memory=131072 |
18 | 14 | LINKER:--no-entry |
19 | 15 | ) |
20 | 16 |
|
21 | 17 | add_executable(hello.wasm hello.c) |
22 | | -target_link_libraries(hello.wasm) |
23 | | - |
24 | | -add_custom_command(TARGET hello.wasm POST_BUILD |
25 | | - COMMAND ${CMAKE_COMMAND} -E copy |
26 | | - ${CMAKE_CURRENT_BINARY_DIR}/hello.wasm |
27 | | - ${CMAKE_CURRENT_BINARY_DIR}/../ |
28 | | - COMMENT "Copy hello.wasm to the same directory of google test" |
29 | | - ) |
| 18 | +target_compile_options(hello.wasm PUBLIC -nostdlib) |
| 19 | +target_link_options(hello.wasm PRIVATE |
| 20 | + -nostdlib |
| 21 | + LINKER:--allow-undefined |
| 22 | + LINKER:--export-all |
| 23 | + LINKER:--initial-memory=131072 |
| 24 | + LINKER:--no-entry |
| 25 | +) |
30 | 26 |
|
31 | | -add_custom_command(TARGET mytest.wasm POST_BUILD |
32 | | - COMMAND ${CMAKE_COMMAND} -E copy |
33 | | - ${CMAKE_CURRENT_BINARY_DIR}/mytest.wasm |
34 | | - ${CMAKE_CURRENT_BINARY_DIR}/../ |
35 | | - COMMENT "Copy mytest.wasm to the same directory of google test" |
36 | | - ) |
| 27 | +# install .wasm |
| 28 | +set( |
| 29 | + WASM_FILES |
| 30 | + ${CMAKE_CURRENT_BINARY_DIR}/hello.wasm |
| 31 | + ${CMAKE_CURRENT_BINARY_DIR}/mytest.wasm |
| 32 | +) |
| 33 | +install(FILES ${WASM_FILES} DESTINATION .) |
0 commit comments