|
| 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 3.14) |
| 5 | + |
| 6 | +project (smart-tests-aot) |
| 7 | + |
| 8 | +add_definitions (-DRUN_ON_LINUX) |
| 9 | + |
| 10 | +add_definitions (-Dattr_container_malloc=malloc) |
| 11 | +add_definitions (-Dattr_container_free=free) |
| 12 | +add_definitions (-DWASM_ENABLE_WAMR_COMPILER=1) |
| 13 | +add_definitions (-DWASM_ENABLE_DUMP_CALL_STACK=1) |
| 14 | +add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1) |
| 15 | + |
| 16 | +set(WAMR_BUILD_AOT 1) |
| 17 | +set(WAMR_BUILD_INTERP 1) |
| 18 | +set(WAMR_BUILD_FAST_INTERP 0) |
| 19 | +set(WAMR_BUILD_JIT 0) |
| 20 | +set(WAMR_BUILD_LIBC_WASI 0) |
| 21 | +set(WAMR_BUILD_APP_FRAMEWORK 1) |
| 22 | +set(WAMR_BUILD_MULTI_MODULE 1) |
| 23 | + |
| 24 | +include (../../unit_common.cmake) |
| 25 | + |
| 26 | +set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm") |
| 27 | +if (NOT EXISTS "${LLVM_SRC_ROOT}/build") |
| 28 | + message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build") |
| 29 | +endif () |
| 30 | +set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}") |
| 31 | +find_package(LLVM REQUIRED CONFIG) |
| 32 | +include_directories(${LLVM_INCLUDE_DIRS}) |
| 33 | +add_definitions(${LLVM_DEFINITIONS}) |
| 34 | +message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") |
| 35 | +message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") |
| 36 | + |
| 37 | +include (${IWASM_DIR}/compilation/iwasm_compl.cmake) |
| 38 | + |
| 39 | +include_directories (${CMAKE_CURRENT_SOURCE_DIR}) |
| 40 | + |
| 41 | +file (GLOB source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc) |
| 42 | + |
| 43 | +foreach(source ${source_all}) |
| 44 | + string(FIND ${source} "/build/" build_pos) |
| 45 | + if(build_pos EQUAL -1) |
| 46 | + list(APPEND UNIT_SOURCE ${source}) |
| 47 | + endif() |
| 48 | +endforeach() |
| 49 | + |
| 50 | +set (unit_test_sources |
| 51 | + ${UNIT_SOURCE} |
| 52 | + ${PLATFORM_SHARED_SOURCE} |
| 53 | + ${UTILS_SHARED_SOURCE} |
| 54 | + ${MEM_ALLOC_SHARED_SOURCE} |
| 55 | + ${NATIVE_INTERFACE_SOURCE} |
| 56 | + ${LIBC_BUILTIN_SOURCE} |
| 57 | + ${IWASM_COMMON_SOURCE} |
| 58 | + ${IWASM_INTERP_SOURCE} |
| 59 | + ${IWASM_AOT_SOURCE} |
| 60 | + ${IWASM_COMPL_SOURCE} |
| 61 | + ) |
| 62 | + |
| 63 | +# Include GoogleTest module for gtest_discover_tests |
| 64 | +include(GoogleTest) |
| 65 | + |
| 66 | +add_executable (smart-tests-aot ${unit_test_sources}) |
| 67 | + |
| 68 | +target_link_libraries (smart-tests-aot ${LLVM_AVAILABLE_LIBS} gtest_main gmock) |
| 69 | + |
| 70 | +gtest_discover_tests(smart-tests-aot) |
| 71 | + |
0 commit comments