-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
149 lines (134 loc) · 5.45 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
cmake_minimum_required(VERSION 3.22)
project(MVVM LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 23)
find_package(fmt REQUIRED)
find_package(spdlog REQUIRED)
find_package(cxxopts REQUIRED)
include(CTest)
if (WIN32)
set(WASI_SDK_DIR D:/wasi-sdk/)
else ()
set(WASI_SDK_DIR /opt/wasi-sdk/)
endif ()
if (APPLE)
set(WAMR_BUILD_LIB_PTHREAD 1)
set(WAMR_BUILD_LIB_PTHREAD_SEMAPHORE 1)
set(WAMR_BUILD_LIB_WASI_THREADS 1)
set(WAMR_BUILD_THREAD_MGR 1)
set(WAMR_BUILD_PLATFORM "darwin")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
set(BLAS_LIBRARIES /opt/homebrew/opt/openblas/lib/libopenblas.0.dylib)
else ()
set(BLAS_LIBRARIES /usr/local/opt/openblas/lib/libopenblas.0.dylib)
endif ()
find_path(BLAS_INCLUDE_DIRS cblas.h
/opt/homebrew/opt/openblas/include
/usr/local/opt/openblas/include
$ENV{BLAS_HOME}/include)
message(${BLAS_INCLUDE_DIRS})
elseif (LINUX)
set(WAMR_BUILD_PLATFORM "linux")
set(WAMR_BUILD_LIB_PTHREAD 1)
set(WAMR_BUILD_LIB_PTHREAD_SEMAPHORE 1)
set(WAMR_BUILD_LIB_WASI_THREADS 1)
set(WAMR_BUILD_THREAD_MGR 1)
set(BLAS_LIBRARIES -lopenblas)
find_path(BLAS_INCLUDE_DIRS cblas.h
/usr/include
/usr/local/include
/opt/OpenBLAS/include/
$ENV{BLAS_HOME}/include)
message(${BLAS_INCLUDE_DIRS})
set(WIN_EXTRA_LIBS ibverbs rdmacm)
else ()
set(WAMR_BUILD_PLATFORM "windows")
set(WAMR_BUILD_LIB_PTHREAD 1)
set(WAMR_BUILD_LIB_WASI_THREADS 1)
set(WAMR_BUILD_THREAD_MGR 1)
set(WAMR_BUILD_LIBC_UVWASI 1)
set(CMAKE_MSVC_RUNTIME_LIBRARY "")
set(CMAKE_GENERATOR_PLATFORM "")
set(CMAKE_CXX_FLAGS "/MD")
find_library(DETOURS_LIBRARY detours REQUIRED)
find_path(DETOURS_INCLUDE_DIRS "detours/detours.h")
find_library(DETOURS_LIBRARY detours REQUIRED)
set(WIN_EXTRA_LIBS uvwasi_a msvcrt.lib libcmt.lib ${DETOURS_LIBRARY} uv_a ws2_32)
include_directories(${DETOURS_INCLUDE_DIRS})
if(MVVM_BUILD_TEST)
set(BLAS_LIBRARIES "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/lib/x64/cublas.lib" "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/lib/x64/cudart.lib")
set(BLAS_INCLUDE_DIRS "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/include/")
endif()
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options(-fdiagnostics-color=always)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-fcolor-diagnostics)
endif ()
# Set WAMR_BUILD_TARGET, currently values supported:
# "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]",
# "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]"
if (NOT DEFINED WAMR_BUILD_TARGET)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
set(WAMR_BUILD_TARGET "AARCH64")
elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
set(WAMR_BUILD_TARGET "RISCV64")
else ()
# Build as X86_64 by default in 64-bit platform
set(WAMR_BUILD_TARGET "X86_64")
endif ()
endif ()
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif ()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG)
else()
add_definitions(-DSPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO)
endif()
set(WAMR_BUILD_INTERP 1)
set(WAMR_BUILD_AOT 1)
set(WAMR_BUILD_JIT 0)
set(WAMR_BUILD_DEBUG_INTERP 0)
set(WAMR_BUILD_DEBUG_AOT 0)
set(WAMR_BUILD_FAST_JIT 0)
set(WAMR_BUILD_WASI_NN 0)
set(WAMR_BUILD_LIBC_BUILTIN 1)
set(WAMR_BUILD_LIBC_WASI 1)
set(WAMR_BUILD_DUMP_CALL_STACK 1)
set(WAMR_BUILD_FAST_INTERP 0)
set(WAMR_BUILD_SHARED_MEMORY 1)
set(WAMR_BUILD_BULK_MEMORY 1)
set(WAMR_BUILD_REF_TYPES 0)
set(WAMR_BUILD_SIMD 1)
set(WAMR_BUILD_CUSTOM_NAME_SECTION 1)
set(WAMR_BUILD_CHECKPOINT_RESTORE 1)
set(WAMR_DISABLE_HW_BOUND_CHECK 1)
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,-U,_get_ext_lib_export_apis")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
set(CMAKE_MACOSX_RPATH True)
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/wasm-micro-runtime)
include(${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
include(${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/lib/wasm-micro-runtime/core/iwasm/aot ${CMAKE_CURRENT_SOURCE_DIR}/lib/yalantinglibs/include ${BLAS_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/lib/libcrafter/libcrafter/)
if (MVVM_BUILD_BENCH)
add_subdirectory(bench)
endif()
if (MVVM_BUILD_TEST)
add_definitions(-DMVVM_BUILD_TEST=1)
add_subdirectory(test)
endif()
if (LINUX)
add_subdirectory(lib/libcrafter/libcrafter)
add_subdirectory(gateway)
add_executable(MVVM_profile src/profile.cpp ${UNCOMMON_SHARED_SOURCE})
target_link_libraries(MVVM_profile fmt::fmt spdlog::spdlog cxxopts::cxxopts ${BLAS_LIBRARIES} MVVM_export vmlib ${WIN_EXTRA_LIBS})
endif ()
file(GLOB_RECURSE SOURCE_FILES src/wamr*.cpp)
add_library(MVVM_export ${SOURCE_FILES} ${UNCOMMON_SHARED_SOURCE})
add_executable(MVVM_restore src/restore.cpp ${UNCOMMON_SHARED_SOURCE})
add_executable(MVVM_checkpoint src/checkpoint.cpp ${UNCOMMON_SHARED_SOURCE})
target_link_libraries(MVVM_export fmt::fmt spdlog::spdlog ${BLAS_LIBRARIES})
target_link_libraries(MVVM_restore fmt::fmt spdlog::spdlog cxxopts::cxxopts ${BLAS_LIBRARIES} MVVM_export vmlib ${WIN_EXTRA_LIBS})
target_link_libraries(MVVM_checkpoint fmt::fmt spdlog::spdlog cxxopts::cxxopts ${BLAS_LIBRARIES} MVVM_export vmlib ${WIN_EXTRA_LIBS})
add_definitions(-DCXXOPTS_NO_RTTI=1)