|
| 1 | +# Copyright (C) 2019 Intel Corporation. All rights reserved. |
| 2 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 3 | + |
| 4 | +cmake_minimum_required (VERSION 2.9) |
| 5 | + |
| 6 | +project (iwasm) |
| 7 | + |
| 8 | +set (WAMR_BUILD_PLATFORM "freebsd") |
| 9 | + |
| 10 | +# Reset default linker flags |
| 11 | +set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") |
| 12 | +set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "") |
| 13 | + |
| 14 | +# Set WAMR_BUILD_TARGET, currently values supported: |
| 15 | +# "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]", |
| 16 | +# "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]" |
| 17 | +if (NOT DEFINED WAMR_BUILD_TARGET) |
| 18 | + if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)") |
| 19 | + set (WAMR_BUILD_TARGET "AARCH64") |
| 20 | + elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64") |
| 21 | + set (WAMR_BUILD_TARGET "RISCV64") |
| 22 | + elseif (CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 23 | + # Build as X86_64 by default in 64-bit platform |
| 24 | + set (WAMR_BUILD_TARGET "X86_64") |
| 25 | + elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) |
| 26 | + # Build as X86_32 by default in 32-bit platform |
| 27 | + set (WAMR_BUILD_TARGET "X86_32") |
| 28 | + else () |
| 29 | + message(SEND_ERROR "Unsupported build target platform!") |
| 30 | + endif () |
| 31 | +endif () |
| 32 | + |
| 33 | +if (NOT CMAKE_BUILD_TYPE) |
| 34 | + set(CMAKE_BUILD_TYPE Release) |
| 35 | +endif () |
| 36 | + |
| 37 | +set(CMAKE_CXX_STANDARD 14) |
| 38 | + |
| 39 | +if (NOT DEFINED WAMR_BUILD_INTERP) |
| 40 | + # Enable Interpreter by default |
| 41 | + set (WAMR_BUILD_INTERP 1) |
| 42 | +endif () |
| 43 | + |
| 44 | +if (NOT DEFINED WAMR_BUILD_AOT) |
| 45 | + # Enable AOT by default. |
| 46 | + set (WAMR_BUILD_AOT 1) |
| 47 | +endif () |
| 48 | + |
| 49 | +if (NOT DEFINED WAMR_BUILD_JIT) |
| 50 | + # Disable JIT by default. |
| 51 | + set (WAMR_BUILD_JIT 0) |
| 52 | +endif () |
| 53 | + |
| 54 | +if (NOT DEFINED WAMR_BUILD_FAST_JIT) |
| 55 | + # Disable Fast JIT by default |
| 56 | + set (WAMR_BUILD_FAST_JIT 0) |
| 57 | +endif () |
| 58 | + |
| 59 | +if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN) |
| 60 | + # Enable libc builtin support by default |
| 61 | + set (WAMR_BUILD_LIBC_BUILTIN 1) |
| 62 | +endif () |
| 63 | + |
| 64 | +if (NOT DEFINED WAMR_BUILD_LIBC_WASI) |
| 65 | + # Enable libc wasi support by default |
| 66 | + set (WAMR_BUILD_LIBC_WASI 1) |
| 67 | +endif () |
| 68 | + |
| 69 | +if (NOT DEFINED WAMR_BUILD_FAST_INTERP) |
| 70 | + # Enable fast interpreter |
| 71 | + set (WAMR_BUILD_FAST_INTERP 1) |
| 72 | +endif () |
| 73 | + |
| 74 | +if (NOT DEFINED WAMR_BUILD_MULTI_MODULE) |
| 75 | + # Disable multiple module by default |
| 76 | + set (WAMR_BUILD_MULTI_MODULE 0) |
| 77 | +endif () |
| 78 | + |
| 79 | +if (NOT DEFINED WAMR_BUILD_LIB_PTHREAD) |
| 80 | + # Disable pthread library by default |
| 81 | + set (WAMR_BUILD_LIB_PTHREAD 0) |
| 82 | +endif () |
| 83 | + |
| 84 | +if (NOT DEFINED WAMR_BUILD_MINI_LOADER) |
| 85 | + # Disable wasm mini loader by default |
| 86 | + set (WAMR_BUILD_MINI_LOADER 0) |
| 87 | +endif () |
| 88 | + |
| 89 | +if (NOT DEFINED WAMR_BUILD_SIMD) |
| 90 | + # Enable SIMD by default |
| 91 | + set (WAMR_BUILD_SIMD 1) |
| 92 | +endif () |
| 93 | + |
| 94 | +if (NOT DEFINED WAMR_BUILD_DEBUG_INTERP) |
| 95 | + # Disable Debug feature by default |
| 96 | + set (WAMR_BUILD_DEBUG_INTERP 0) |
| 97 | +endif () |
| 98 | + |
| 99 | +if (WAMR_BUILD_DEBUG_INTERP EQUAL 1) |
| 100 | + set (WAMR_BUILD_FAST_INTERP 0) |
| 101 | + set (WAMR_BUILD_MINI_LOADER 0) |
| 102 | + set (WAMR_BUILD_SIMD 0) |
| 103 | +endif () |
| 104 | + |
| 105 | +set (WAMR_DISABLE_HW_BOUND_CHECK 1) |
| 106 | + |
| 107 | +set (CMAKE_SHARED_LINKER_FLAGS "-Wl") |
| 108 | +set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") |
| 109 | + |
| 110 | +set (CMAKE_MACOSX_RPATH True) |
| 111 | + |
| 112 | +set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) |
| 113 | + |
| 114 | +include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) |
| 115 | +add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE}) |
| 116 | + |
| 117 | +include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) |
| 118 | + |
| 119 | +add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE}) |
| 120 | + |
| 121 | +install (TARGETS iwasm DESTINATION bin) |
| 122 | + |
| 123 | +target_link_libraries (iwasm vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread) |
| 124 | + |
| 125 | +add_library (libiwasm SHARED ${WAMR_RUNTIME_LIB_SOURCE}) |
| 126 | + |
| 127 | +install (TARGETS libiwasm DESTINATION lib) |
| 128 | + |
| 129 | +set_target_properties (libiwasm PROPERTIES OUTPUT_NAME iwasm) |
| 130 | + |
| 131 | +target_link_libraries (libiwasm ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread) |
| 132 | + |
0 commit comments