CMakeLists.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. cmake_minimum_required(VERSION 2.8)
  4. project(pthread)
  5. ################ runtime settings ################
  6. string (TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
  7. if (APPLE)
  8. add_definitions(-DBH_PLATFORM_DARWIN)
  9. endif ()
  10. # Resetdefault linker flags
  11. set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
  12. set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
  13. # WAMR features switch
  14. # Set WAMR_BUILD_TARGET, currently values supported:
  15. # "X86_64", "AMD_64", "X86_32", "AARCH64[sub]", "ARM[sub]", "THUMB[sub]",
  16. # "MIPS", "XTENSA", "RISCV64[sub]", "RISCV32[sub]"
  17. if (NOT DEFINED WAMR_BUILD_TARGET)
  18. if (CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)")
  19. set (WAMR_BUILD_TARGET "AARCH64")
  20. elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
  21. set (WAMR_BUILD_TARGET "RISCV64")
  22. elseif (CMAKE_SIZEOF_VOID_P EQUAL 8)
  23. # Build as X86_64 by default in 64-bit platform
  24. set (WAMR_BUILD_TARGET "X86_64")
  25. elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
  26. # Build as X86_32 by default in 32-bit platform
  27. set (WAMR_BUILD_TARGET "X86_32")
  28. else ()
  29. message(SEND_ERROR "Unsupported build target platform!")
  30. endif ()
  31. endif ()
  32. if (NOT CMAKE_BUILD_TYPE)
  33. set (CMAKE_BUILD_TYPE Release)
  34. endif ()
  35. set(WAMR_BUILD_INTERP 1)
  36. set(WAMR_BUILD_AOT 1)
  37. set(WAMR_BUILD_JIT 0)
  38. set(WAMR_BUILD_LIBC_BUILTIN 1)
  39. set(WAMR_BUILD_FAST_INTERP 1)
  40. set(WAMR_BUILD_LIB_PTHREAD 1)
  41. # compiling and linking flags
  42. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie -fPIE")
  43. if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
  44. set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
  45. endif ()
  46. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security")
  47. # build out vmlib
  48. set(WAMR_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
  49. include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake)
  50. add_library(vmlib ${WAMR_RUNTIME_LIB_SOURCE})
  51. ################################################
  52. ################ wasm application ################
  53. add_subdirectory(wasm-apps)
  54. ################ wamr runtime ################
  55. include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
  56. set (RUNTIME_SOURCE_ALL
  57. ${CMAKE_CURRENT_LIST_DIR}/../../product-mini/platforms/linux/main.c
  58. ${UNCOMMON_SHARED_SOURCE}
  59. )
  60. add_executable (iwasm ${RUNTIME_SOURCE_ALL})
  61. target_link_libraries(iwasm vmlib -lpthread -lm -ldl)