runtime_lib.cmake 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. if (NOT DEFINED WAMR_ROOT_DIR)
  4. set (WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../)
  5. endif ()
  6. if (NOT DEFINED SHARED_DIR)
  7. set (SHARED_DIR ${WAMR_ROOT_DIR}/core/shared)
  8. endif ()
  9. if (NOT DEFINED IWASM_DIR)
  10. set (IWASM_DIR ${WAMR_ROOT_DIR}/core/iwasm)
  11. endif ()
  12. if (NOT DEFINED APP_MGR_DIR)
  13. set (APP_MGR_DIR ${WAMR_ROOT_DIR}/core/app-mgr)
  14. endif ()
  15. if (NOT DEFINED APP_FRAMEWORK_DIR)
  16. set (APP_FRAMEWORK_DIR ${WAMR_ROOT_DIR}/core/app-framework)
  17. endif ()
  18. if (NOT DEFINED DEPS_DIR)
  19. set (DEPS_DIR ${WAMR_ROOT_DIR}/core/deps)
  20. endif ()
  21. if (DEFINED EXTRA_SDK_INCLUDE_PATH)
  22. message(STATUS, "EXTRA_SDK_INCLUDE_PATH = ${EXTRA_SDK_INCLUDE_PATH} ")
  23. include_directories (
  24. ${EXTRA_SDK_INCLUDE_PATH}
  25. )
  26. endif ()
  27. # Set default options
  28. # Set WAMR_BUILD_TARGET, currently values supported:
  29. # "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]",
  30. # "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]"
  31. if (NOT DEFINED WAMR_BUILD_TARGET)
  32. if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
  33. set (WAMR_BUILD_TARGET "AARCH64")
  34. elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
  35. set (WAMR_BUILD_TARGET "RISCV64")
  36. elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
  37. # Build as X86_64 by default in 64-bit platform
  38. set (WAMR_BUILD_TARGET "X86_64")
  39. else ()
  40. # Build as X86_32 by default in 32-bit platform
  41. set (WAMR_BUILD_TARGET "X86_32")
  42. endif ()
  43. endif ()
  44. ################ optional according to settings ################
  45. if (WAMR_BUILD_INTERP EQUAL 1 OR WAMR_BUILD_JIT EQUAL 1)
  46. include (${IWASM_DIR}/interpreter/iwasm_interp.cmake)
  47. endif ()
  48. if (WAMR_BUILD_AOT EQUAL 1)
  49. include (${IWASM_DIR}/aot/iwasm_aot.cmake)
  50. if (WAMR_BUILD_JIT EQUAL 1)
  51. include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
  52. endif ()
  53. endif ()
  54. if (WAMR_BUILD_APP_FRAMEWORK EQUAL 1)
  55. include (${APP_FRAMEWORK_DIR}/app_framework.cmake)
  56. include (${SHARED_DIR}/coap/lib_coap.cmake)
  57. include (${APP_MGR_DIR}/app-manager/app_mgr.cmake)
  58. include (${APP_MGR_DIR}/app-mgr-shared/app_mgr_shared.cmake)
  59. endif ()
  60. if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
  61. include (${IWASM_DIR}/libraries/libc-builtin/libc_builtin.cmake)
  62. endif ()
  63. if (WAMR_BUILD_LIBC_UVWASI EQUAL 1)
  64. include (${IWASM_DIR}/libraries/libc-uvwasi/libc_uvwasi.cmake)
  65. elseif (WAMR_BUILD_LIBC_WASI EQUAL 1)
  66. include (${IWASM_DIR}/libraries/libc-wasi/libc_wasi.cmake)
  67. endif ()
  68. if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)
  69. include (${IWASM_DIR}/libraries/lib-pthread/lib_pthread.cmake)
  70. # Enable the dependent feature if lib pthread is enabled
  71. set (WAMR_BUILD_THREAD_MGR 1)
  72. set (WAMR_BUILD_BULK_MEMORY 1)
  73. set (WAMR_BUILD_SHARED_MEMORY 1)
  74. endif ()
  75. if (WAMR_BUILD_DEBUG_INTERP EQUAL 1)
  76. set (WAMR_BUILD_THREAD_MGR 1)
  77. include (${IWASM_DIR}/libraries/debug-engine/debug_engine.cmake)
  78. if (WAMR_BUILD_FAST_INTERP EQUAL 1)
  79. set (WAMR_BUILD_FAST_INTERP 0)
  80. message(STATUS
  81. "Debugger doesn't work with fast interpreter, switch to classic interpreter")
  82. endif ()
  83. endif ()
  84. if (WAMR_BUILD_THREAD_MGR EQUAL 1)
  85. include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
  86. endif ()
  87. if (WAMR_BUILD_LIBC_EMCC EQUAL 1)
  88. include (${IWASM_DIR}/libraries/libc-emcc/libc_emcc.cmake)
  89. endif ()
  90. ####################### Common sources #######################
  91. if (NOT MSVC)
  92. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -ffunction-sections -fdata-sections \
  93. -Wall -Wno-unused-parameter -Wno-pedantic")
  94. endif ()
  95. # include the build config template file
  96. include (${CMAKE_CURRENT_LIST_DIR}/config_common.cmake)
  97. include_directories (${IWASM_DIR}/include)
  98. file (GLOB header
  99. ${IWASM_DIR}/include/*.h
  100. )
  101. LIST (APPEND RUNTIME_LIB_HEADER_LIST ${header})
  102. enable_language (ASM)
  103. include (${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake)
  104. include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
  105. include (${IWASM_DIR}/common/iwasm_common.cmake)
  106. include (${SHARED_DIR}/utils/shared_utils.cmake)
  107. set (source_all
  108. ${PLATFORM_SHARED_SOURCE}
  109. ${MEM_ALLOC_SHARED_SOURCE}
  110. ${UTILS_SHARED_SOURCE}
  111. ${LIBC_BUILTIN_SOURCE}
  112. ${LIBC_WASI_SOURCE}
  113. ${IWASM_COMMON_SOURCE}
  114. ${IWASM_INTERP_SOURCE}
  115. ${IWASM_AOT_SOURCE}
  116. ${IWASM_COMPL_SOURCE}
  117. ${WASM_APP_LIB_SOURCE_ALL}
  118. ${NATIVE_INTERFACE_SOURCE}
  119. ${APP_MGR_SOURCE}
  120. ${LIB_PTHREAD_SOURCE}
  121. ${THREAD_MGR_SOURCE}
  122. ${LIBC_EMCC_SOURCE}
  123. ${DEBUG_ENGINE_SOURCE}
  124. )
  125. set (WAMR_RUNTIME_LIB_SOURCE ${source_all})