CMakeLists.txt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. cmake_minimum_required(VERSION 2.9)
  4. project (test-compilation)
  5. add_definitions (-DRUN_ON_LINUX)
  6. add_definitions (-Dattr_container_malloc=malloc)
  7. add_definitions (-Dattr_container_free=free)
  8. add_definitions (-DWASM_ENABLE_WAMR_COMPILER=1)
  9. add_definitions (-DWASM_ENABLE_DUMP_CALL_STACK=1)
  10. add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
  11. set (WAMR_BUILD_LIBC_WASI 0)
  12. set (WAMR_BUILD_APP_FRAMEWORK 0)
  13. set (WAMR_BUILD_THREAD_MGR 1)
  14. set (WAMR_BUILD_AOT 1)
  15. include (../unit_common.cmake)
  16. set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
  17. if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
  18. message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
  19. endif ()
  20. set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
  21. find_package(LLVM REQUIRED CONFIG)
  22. include_directories(${LLVM_INCLUDE_DIRS})
  23. add_definitions(${LLVM_DEFINITIONS})
  24. message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
  25. message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
  26. include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
  27. include_directories (${CMAKE_CURRENT_SOURCE_DIR})
  28. file (GLOB_RECURSE source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
  29. set (UNIT_SOURCE ${source_all})
  30. set (unit_test_sources
  31. ${UNIT_SOURCE}
  32. ${WAMR_RUNTIME_LIB_SOURCE}
  33. ${UNCOMMON_SHARED_SOURCE}
  34. ${SRC_LIST}
  35. ${PLATFORM_SHARED_SOURCE}
  36. ${UTILS_SHARED_SOURCE}
  37. ${MEM_ALLOC_SHARED_SOURCE}
  38. ${LIB_HOST_AGENT_SOURCE}
  39. ${NATIVE_INTERFACE_SOURCE}
  40. ${LIBC_BUILTIN_SOURCE}
  41. ${IWASM_COMMON_SOURCE}
  42. ${IWASM_INTERP_SOURCE}
  43. ${IWASM_AOT_SOURCE}
  44. ${IWASM_COMPL_SOURCE}
  45. ${WASM_APP_LIB_SOURCE_ALL}
  46. )
  47. # Now simply link against gtest or gtest_main as needed. Eg
  48. add_executable (compilation_test ${unit_test_sources})
  49. target_link_libraries (compilation_test ${LLVM_AVAILABLE_LIBS} gtest_main )
  50. add_custom_command(TARGET compilation_test POST_BUILD
  51. COMMAND ${CMAKE_COMMAND} -E copy
  52. ${CMAKE_CURRENT_LIST_DIR}/wasm-apps/main.wasm
  53. ${CMAKE_CURRENT_BINARY_DIR}
  54. COMMENT "Copy main.wasm to the directory: build/compilation."
  55. )
  56. gtest_discover_tests(compilation_test)