Skip to content

Commit

Permalink
Add CMake configuration for WAMR's runtime "iwasm VM core".
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottTodd committed Mar 9, 2021
1 parent 2b5c7b9 commit 2795092
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ add_subdirectory(build_tools/third_party/half EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/pffft EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/renderdoc_api EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/vulkan_memory_allocator EXCLUDE_FROM_ALL)
add_subdirectory(build_tools/third_party/wasm-micro-runtime EXCLUDE_FROM_ALL)

add_subdirectory(third_party/cpuinfo EXCLUDE_FROM_ALL)
add_subdirectory(third_party/googletest EXCLUDE_FROM_ALL)
Expand Down
59 changes: 59 additions & 0 deletions build_tools/third_party/wasm-micro-runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This file modeled after the instructions at
# https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/doc/build_wamr.md

set(WAMR_SOURCE_DIR "${IREE_SOURCE_DIR}/third_party/wasm-micro-runtime")

# Runtime build target -> platform in wasm-micro-runtime/core/shared/platform/
if(ANDROID)
set(WAMR_BUILD_PLATFORM "android")
elseif(APPLE)
set(WAMR_BUILD_PLATFORM "darwin")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(WAMR_BUILD_PLATFORM "linux")
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
set(WAMR_BUILD_PLATFORM "windows")
# Enable MASM (Microsoft Macro Assembler) for compiling .asm files.
enable_language(ASM_MASM)
endif()

# Pick the features we want. Most default to disabled.
set(WAMR_BUILD_INTERP 1)

include(${WAMR_SOURCE_DIR}/build-scripts/runtime_lib.cmake)

# WAMR unconditionally adds a global compiler flag for 64 bit targets, which
# is not handled or needed by MSVC.
# TODO(scotttodd): Omit the flag upstream rather than work around it here.
if(MSVC)
string(REGEX REPLACE " -fPIC" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
endif()

set(_WAMR_LIBRARY_NAME "wasm_micro_runtime_vmlib")
add_library(${_WAMR_LIBRARY_NAME} STATIC "")
target_sources(${_WAMR_LIBRARY_NAME}
PRIVATE
${WAMR_RUNTIME_LIB_SOURCE})
target_include_directories(${_WAMR_LIBRARY_NAME} SYSTEM
PUBLIC
"$<BUILD_INTERFACE:${WAMR_SOURCE_DIR}/core/iwasm/include/>")

# Suppress all warnings for this third party code.
if(MSVC)
target_compile_options(${_WAMR_LIBRARY_NAME} PRIVATE "/W0")
else()
target_compile_options(${_WAMR_LIBRARY_NAME} PRIVATE "-w")
endif()

0 comments on commit 2795092

Please sign in to comment.