CMakeLists.txt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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-custom-section)
  5. add_definitions (-DRUN_ON_LINUX)
  6. set (WAMR_BUILD_LIBC_WASI 0)
  7. set (WAMR_BUILD_LIBC_BUILTIN 0)
  8. set (WAMR_BUILD_JIT 0)
  9. set (WAMR_BUILD_LAZY_JIT 0)
  10. set (WAMR_BUILD_AOT 1)
  11. add_definitions(-DWASM_ENABLE_WAMR_COMPILER=1)
  12. add_definitions (-DWASM_ENABLE_DUMP_CALL_STACK=1)
  13. add_definitions (-DWASM_ENABLE_AOT_STACK_FRAME=1)
  14. # Feature to test
  15. set (WAMR_BUILD_LOAD_CUSTOM_SECTION 1)
  16. include (../unit_common.cmake)
  17. set (LLVM_SRC_ROOT "${WAMR_ROOT_DIR}/core/deps/llvm")
  18. if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
  19. message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
  20. endif ()
  21. set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
  22. find_package(LLVM REQUIRED CONFIG)
  23. include_directories(${LLVM_INCLUDE_DIRS})
  24. add_definitions(${LLVM_DEFINITIONS})
  25. message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
  26. message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
  27. include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
  28. include_directories (${CMAKE_CURRENT_SOURCE_DIR})
  29. file (GLOB_RECURSE source_all ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
  30. set (UNIT_SOURCE ${source_all})
  31. set (unit_test_sources
  32. ${UNIT_SOURCE}
  33. ${PLATFORM_SHARED_SOURCE}
  34. ${UTILS_SHARED_SOURCE}
  35. ${MEM_ALLOC_SHARED_SOURCE}
  36. ${NATIVE_INTERFACE_SOURCE}
  37. ${IWASM_COMMON_SOURCE}
  38. ${IWASM_INTERP_SOURCE}
  39. ${IWASM_AOT_SOURCE}
  40. ${IWASM_COMPL_SOURCE}
  41. ${WASM_APP_LIB_SOURCE_ALL}
  42. )
  43. # Automatically build wasm-apps for this test
  44. add_subdirectory(wasm-apps)
  45. # Now simply link against gtest or gtest_main as needed. Eg
  46. add_executable (custom_section_test ${unit_test_sources})
  47. target_link_libraries (custom_section_test ${LLVM_AVAILABLE_LIBS} gtest_main )
  48. gtest_discover_tests(custom_section_test)