CMakeLists.txt 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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(unit-test)
  5. # Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update
  6. # our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt
  7. # from 3rd parties that we should not alter. Therefore, in addition to
  8. # changing the `cmake_minimum_required()`, we should also add a configuration
  9. # here that is compatible with earlier versions.
  10. set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
  11. SET(CMAKE_BUILD_TYPE Debug)
  12. # add_definitions (-m32)
  13. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
  14. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
  15. if(WAMR_BUILD_TARGET STREQUAL "X86_32")
  16. # 1) Force -m32
  17. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "" FORCE)
  18. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "" FORCE)
  19. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32" CACHE STRING "" FORCE)
  20. set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32" CACHE STRING "" FORCE)
  21. # 2) Make CMake prefer i386 libraries
  22. set(CMAKE_SYSTEM_PROCESSOR i386 CACHE STRING "" FORCE)
  23. set(CMAKE_LIBRARY_ARCHITECTURE "i386-linux-gnu" CACHE STRING "" FORCE)
  24. endif()
  25. # Prevent overriding the parent project's compiler/linker
  26. # settings on Windows
  27. set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
  28. # Fetch Google test
  29. include (FetchContent)
  30. if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
  31. FetchContent_Declare (
  32. googletest
  33. URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
  34. DOWNLOAD_EXTRACT_TIMESTAMP ON
  35. )
  36. else()
  37. FetchContent_Declare (
  38. googletest
  39. URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
  40. )
  41. endif()
  42. FetchContent_MakeAvailable(googletest)
  43. SET(GOOGLETEST_INCLUDED 1)
  44. include(GoogleTest)
  45. enable_testing()
  46. add_subdirectory(wasm-vm)
  47. add_subdirectory(interpreter)
  48. add_subdirectory(wasm-c-api)
  49. add_subdirectory(libc-builtin)
  50. add_subdirectory(shared-utils)
  51. add_subdirectory(linear-memory-wasm)
  52. add_subdirectory(linear-memory-aot)
  53. add_subdirectory(aot-stack-frame)
  54. add_subdirectory(linux-perf)
  55. add_subdirectory(gc)
  56. add_subdirectory(tid-allocator)
  57. if (NOT WAMR_BUILD_TARGET STREQUAL "X86_32")
  58. # should enable 32-bit llvm when X86_32
  59. add_subdirectory (aot)
  60. add_subdirectory (custom-section)
  61. add_subdirectory (compilation)
  62. # Fast-JIT or mem64 is not supported on X86_32
  63. add_subdirectory (running-modes)
  64. add_subdirectory (memory64)
  65. add_subdirectory (shared-heap)
  66. # HW_BOUND_CHECK is not supported on X86_32
  67. add_subdirectory (runtime-common)
  68. endif ()