CMakeLists.txt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 (wasm_c_api_test)
  5. ################ runtime settings ################
  6. set(CMAKE_BUILD_TYPE Debug)
  7. set(WAMR_BUILD_PLATFORM "linux")
  8. # Resetdefault linker flags
  9. set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
  10. set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
  11. # WAMR features switch
  12. set(WAMR_BUILD_TARGET "X86_64")
  13. set(WAMR_BUILD_INTERP 1)
  14. set(WAMR_BUILD_AOT 0)
  15. set(WAMR_BUILD_JIT 0)
  16. set(WAMR_BUILD_LIBC_BUILTIN 1)
  17. set(WAMR_BUILD_LIBC_WASI 0)
  18. set(WAMR_BUILD_FAST_INTERP 0)
  19. # compiling and linking flags
  20. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections -pie -fPIE")
  21. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -mindirect-branch-register")
  22. # build out vmlib
  23. # hard code path here
  24. set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../..)
  25. include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
  26. add_library(vmlib STATIC ${WAMR_RUNTIME_LIB_SOURCE})
  27. ################################################
  28. ################ unit test related ################
  29. # Add googletest directly to our build. This defines
  30. # the gtest and gtest_main targets.
  31. if (NOT (GOOGLETEST_INCLUDED EQUAL 1))
  32. # Prevent overriding the parent project's compiler/linker
  33. # settings on Windows
  34. set (gtest_force_shared_crt ON CACHE BOOL "" FORCE)
  35. # Fetch Google test
  36. include (FetchContent)
  37. FetchContent_Declare (
  38. googletest
  39. URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
  40. )
  41. FetchContent_MakeAvailable (googletest)
  42. endif()
  43. enable_testing()
  44. add_executable(wasm_c_api_test
  45. basic.cc
  46. )
  47. target_link_libraries(wasm_c_api_test vmlib gtest_main)
  48. gtest_discover_tests(wasm_c_api_test)