CMakeLists.txt 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. cmake_minimum_required (VERSION 3.14)
  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. # Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update
  30. # our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt
  31. # from 3rd parties that we should not alter. Therefore, in addition to
  32. # changing the `cmake_minimum_required()`, we should also add a configuration
  33. # here that is compatible with earlier versions.
  34. set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE)
  35. # Add googletest directly to our build. This defines
  36. # the gtest and gtest_main targets.
  37. if (NOT (GOOGLETEST_INCLUDED EQUAL 1))
  38. # Prevent overriding the parent project's compiler/linker
  39. # settings on Windows
  40. set (gtest_force_shared_crt ON CACHE BOOL "" FORCE)
  41. # Fetch Google test
  42. include (FetchContent)
  43. FetchContent_Declare (
  44. googletest
  45. URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
  46. )
  47. FetchContent_MakeAvailable (googletest)
  48. endif()
  49. enable_testing()
  50. add_executable(wasm_c_api_test
  51. basic.cc
  52. )
  53. target_link_libraries(wasm_c_api_test vmlib gtest_main)
  54. gtest_discover_tests(wasm_c_api_test)