-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
executable file
·48 lines (36 loc) · 1.29 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
cmake_minimum_required(VERSION 3.11)
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source build is not allowed")
endif()
project(wasiapp)
set(OUT_FILE "app.out")
if(BUILD_DUMMY)
set(app_srcs src/dummy.c)
else()
#set(app_srcs src/wasi-app.c src/wasi-main.c src/wasm-rt-impl.c)
file(GLOB wasm_srcs "./src/wasm/*.c")
set(app_srcs ${wasm_srcs} src/wasi-main.c)
include_directories("${CMAKE_SOURCE_DIR}/deps/w2c2")
endif()
add_executable(${OUT_FILE} ${app_srcs})
# Set options
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "set build type to Release" FORCE)
endif()
include(FetchContent)
include(CheckIPOSupported)
FetchContent_Declare(libuv URL ${CMAKE_SOURCE_DIR}/deps/libuv.zip)
FetchContent_Declare(uvwasi URL ${CMAKE_SOURCE_DIR}/deps/uvwasi.zip)
FetchContent_GetProperties(uvwasi)
if(NOT uvwasi_POPULATED)
FetchContent_Populate(uvwasi)
include_directories("${uvwasi_SOURCE_DIR}/include")
add_subdirectory(${uvwasi_SOURCE_DIR} ${uvwasi_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-O0")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-O3")
target_link_libraries(${OUT_FILE} uvwasi_a uv_a m)
check_ipo_supported(RESULT result)
if(result)
set_property(TARGET ${OUT_FILE} PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
endif()