runtime_lib.cmake 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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]", "MIPS", "XTENSA"
  30. if (NOT DEFINED WAMR_BUILD_TARGET)
  31. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  32. # Build as X86_64 by default in 64-bit platform
  33. set (WAMR_BUILD_TARGET "X86_64")
  34. else ()
  35. # Build as X86_32 by default in 32-bit platform
  36. set (WAMR_BUILD_TARGET "X86_32")
  37. endif ()
  38. endif ()
  39. ################ optional according to settings ################
  40. if (WAMR_BUILD_INTERP EQUAL 1 OR WAMR_BUILD_JIT EQUAL 1)
  41. include (${IWASM_DIR}/interpreter/iwasm_interp.cmake)
  42. endif ()
  43. if (WAMR_BUILD_AOT EQUAL 1)
  44. include (${IWASM_DIR}/aot/iwasm_aot.cmake)
  45. if (WAMR_BUILD_JIT EQUAL 1)
  46. include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
  47. endif ()
  48. endif ()
  49. if (WAMR_BUILD_APP_FRAMEWORK EQUAL 1)
  50. include (${APP_FRAMEWORK_DIR}/app_framework.cmake)
  51. include (${SHARED_DIR}/coap/lib_coap.cmake)
  52. include (${APP_MGR_DIR}/app-manager/app_mgr.cmake)
  53. include (${APP_MGR_DIR}/app-mgr-shared/app_mgr_shared.cmake)
  54. endif ()
  55. if (WAMR_BUILD_LIBC_BUILTIN EQUAL 1)
  56. include (${IWASM_DIR}/libraries/libc-builtin/libc_builtin.cmake)
  57. endif ()
  58. if (WAMR_BUILD_LIBC_WASI EQUAL 1)
  59. include (${IWASM_DIR}/libraries/libc-wasi/libc_wasi.cmake)
  60. endif ()
  61. if (WAMR_BUILD_LIB_PTHREAD EQUAL 1)
  62. include (${IWASM_DIR}/libraries/lib-pthread/lib_pthread.cmake)
  63. # Enable the dependent feature if lib pthread is enabled
  64. set (WAMR_BUILD_THREAD_MGR 1)
  65. set (WAMR_BUILD_BULK_MEMORY 1)
  66. set (WAMR_BUILD_SHARED_MEMORY 1)
  67. endif ()
  68. if (WAMR_BUILD_THREAD_MGR EQUAL 1)
  69. include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
  70. endif ()
  71. ####################### Common sources #######################
  72. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -ffunction-sections -fdata-sections \
  73. -Wall -Wno-unused-parameter -Wno-pedantic")
  74. # include the build config template file
  75. include (${CMAKE_CURRENT_LIST_DIR}/config_common.cmake)
  76. include_directories (${SHARED_DIR}/include
  77. ${IWASM_DIR}/include)
  78. file (GLOB header
  79. ${SHARED_DIR}/include/*.h
  80. ${IWASM_DIR}/include/*.h
  81. )
  82. LIST (APPEND RUNTIME_LIB_HEADER_LIST ${header})
  83. enable_language (ASM)
  84. include (${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake)
  85. include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
  86. include (${IWASM_DIR}/common/iwasm_common.cmake)
  87. include (${SHARED_DIR}/utils/shared_utils.cmake)
  88. set (source_all
  89. ${PLATFORM_SHARED_SOURCE}
  90. ${MEM_ALLOC_SHARED_SOURCE}
  91. ${UTILS_SHARED_SOURCE}
  92. ${LIBC_BUILTIN_SOURCE}
  93. ${LIBC_WASI_SOURCE}
  94. ${IWASM_COMMON_SOURCE}
  95. ${IWASM_INTERP_SOURCE}
  96. ${IWASM_AOT_SOURCE}
  97. ${IWASM_COMPL_SOURCE}
  98. ${WASM_APP_LIB_SOURCE_ALL}
  99. ${NATIVE_INTERFACE_SOURCE}
  100. ${APP_MGR_SOURCE}
  101. ${LIB_PTHREAD_SOURCE}
  102. ${THREAD_MGR_SOURCE}
  103. )
  104. set (WAMR_RUNTIME_LIB_SOURCE ${source_all})