unit_common.cmake 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. if (NOT DEFINED WAMR_BUILD_PLATFORM)
  4. set (WAMR_BUILD_PLATFORM "linux")
  5. endif ()
  6. set (UNIT_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
  7. include_directories(${UNIT_ROOT_DIR})
  8. enable_language (ASM)
  9. # Reset default linker flags
  10. set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
  11. set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
  12. # Set WAMR_BUILD_TARGET, currently values supported:
  13. # "X86_64", "AMD_64", "X86_32", "ARM_32", "MIPS_32", "XTENSA_32"
  14. if (NOT DEFINED WAMR_BUILD_TARGET)
  15. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  16. # Build as X86_64 by default in 64-bit platform
  17. set (WAMR_BUILD_TARGET "X86_64")
  18. else ()
  19. # Build as X86_32 by default in 32-bit platform
  20. set (WAMR_BUILD_TARGET "X86_32")
  21. endif ()
  22. endif ()
  23. if (NOT CMAKE_BUILD_TYPE)
  24. set (CMAKE_BUILD_TYPE Debug)
  25. endif ()
  26. if (NOT DEFINED WAMR_BUILD_INTERP)
  27. # Enable Interpreter by default
  28. set (WAMR_BUILD_INTERP 1)
  29. endif ()
  30. if (NOT DEFINED WAMR_BUILD_AOT)
  31. # Enable AOT by default.
  32. set (WAMR_BUILD_AOT 1)
  33. endif ()
  34. if (NOT DEFINED WAMR_BUILD_JIT)
  35. # Disable JIT by default.
  36. set (WAMR_BUILD_JIT 0)
  37. endif ()
  38. if (NOT DEFINED WAMR_BUILD_LIBC_BUILTIN)
  39. # Enable libc builtin support by default
  40. set (WAMR_BUILD_LIBC_BUILTIN 1)
  41. endif ()
  42. if (NOT DEFINED WAMR_BUILD_LIBC_WASI)
  43. # Enable libc wasi support by default
  44. set (WAMR_BUILD_LIBC_WASI 1)
  45. endif ()
  46. if (NOT DEFINED WAMR_BUILD_MULTI_MODULE)
  47. set (WAMR_BUILD_MULTI_MODULE 1)
  48. endif()
  49. if (NOT DEFINED WAMR_BUILD_APP_FRAMEWORK)
  50. set (WAMR_BUILD_APP_FRAMEWORK 1)
  51. endif ()
  52. if (COLLECT_CODE_COVERAGE EQUAL 1)
  53. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
  54. set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
  55. endif ()
  56. set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
  57. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -ffunction-sections -fdata-sections \
  58. -Wall -Wno-unused-parameter -Wno-pedantic")
  59. set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
  60. # include the build config template file
  61. include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
  62. include_directories (${SHARED_DIR}/include
  63. ${IWASM_DIR}/include)
  64. include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
  65. if (NOT (GOOGLETEST_INCLUDED EQUAL 1))
  66. # Prevent overriding the parent project's compiler/linker
  67. # settings on Windows
  68. set (gtest_force_shared_crt ON CACHE BOOL "" FORCE)
  69. # Fetch Google test
  70. include (FetchContent)
  71. FetchContent_Declare (
  72. googletest
  73. URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
  74. )
  75. FetchContent_MakeAvailable (googletest)
  76. endif()
  77. # Add helper classes
  78. include_directories(${CMAKE_CURRENT_LIST_DIR}/common)
  79. message ("unit_common.cmake included")