forked from gofractally/Eden
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
58 lines (49 loc) · 1.78 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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
cmake_minimum_required(VERSION 3.16.3)
project(eden)
include(ExternalProject)
if(CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
message(FATAL_ERROR "Building in-source is not supported; create a build dir and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt and ${CMAKE_SOURCE_DIR}/CMakeFiles")
endif()
if(NOT DEFINED WASI_SDK_PREFIX AND DEFINED ENV{WASI_SDK_PREFIX})
set(WASI_SDK_PREFIX $ENV{WASI_SDK_PREFIX})
endif()
file(WRITE ${CMAKE_BINARY_DIR}/CTestTestfile.cmake)
option(BUILD_NATIVE "Build native code" ON)
if(BUILD_NATIVE)
add_subdirectory(native)
endif()
if(DEFINED WASI_SDK_PREFIX)
ExternalProject_Add(wasm
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/wasm
BINARY_DIR wasm
INSTALL_COMMAND ""
BUILD_ALWAYS 1
TEST_EXCLUDE_FROM_MAIN 1
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_SOURCE_DIR}/wasm/toolchain.cmake
-DWASI_SDK_PREFIX=${WASI_SDK_PREFIX}
-DCMAKE_SYSROOT=${WASI_SDK_PREFIX}/share/wasi-sysroot
)
file(APPEND ${CMAKE_BINARY_DIR}/CTestTestfile.cmake "subdirs(\"wasm\")\n")
ExternalProject_Add_StepTargets(wasm test)
else()
message(WARNING "WASI_SDK_PREFIX isn't defined; skipping wasm")
endif()
########## TS PACKAGES ####################
if(NOT DEFINED SKIP_TS OR NOT SKIP_TS)
add_custom_target(yarn ALL
COMMAND yarn
COMMAND yarn build
)
add_custom_target(packages ALL
DEPENDS yarn
COMMAND rm -rf ${CMAKE_BINARY_DIR}/dist
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/dist/webapp
COMMAND cp -a ${CMAKE_CURRENT_SOURCE_DIR}/packages/webapp/dist/* ${CMAKE_BINARY_DIR}/dist/webapp
)
add_custom_target(dev
DEPENDS yarn
COMMAND yarn dev --stream
)
endif()