-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
27 lines (24 loc) · 1.16 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
cmake_minimum_required(VERSION 3.10)
project(www)
add_custom_target(libwww ALL
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR}/www cargo build
COMMAND ${CMAKE_COMMAND} -E echo "Building WebAssembly module..."
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_SOURCE_DIR}/www wasm-pack build --dev --target web
COMMAND ${CMAKE_COMMAND} -E echo "Copying wasm module to static directory..."
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/www/pkg/www.js ${CMAKE_SOURCE_DIR}/src/worker/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/www/pkg/www.d.ts ${CMAKE_SOURCE_DIR}/src/worker/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/www/pkg/www_bg.wasm ${CMAKE_SOURCE_DIR}/src/worker/
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/www/pkg/www_bg.wasm.d.ts ${CMAKE_SOURCE_DIR}/src/worker/
)
add_custom_command(OUTPUT cargo_build
COMMAND ${CMAKE_COMMAND} -E echo "Installing Cargo dependencies..."
COMMAND cargo build
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/www
COMMENT "Cargo build"
)
add_custom_target(www ALL
COMMAND ${CMAKE_COMMAND} -E echo "Running pnpm build..."
COMMAND pnpm build
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS libwww
)