CMakeLists.txt 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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(wasm_modules)
  5. if(NOT SOCKET_WASI_CMAKE)
  6. message(FATAL_ERROR "Require SOCKET_WASI_CMAKE")
  7. endif()
  8. option(WASM_TO_AOT "transfer wasm to aot" OFF)
  9. if(WASM_TO_AOT AND NOT WAMRC_PATH)
  10. message(FATAL_ERROR "Require WAMRC_PATH when WASM_TO_AOT is ON")
  11. endif()
  12. #
  13. # c -> wasm
  14. include(${SOCKET_WASI_CMAKE})
  15. add_executable(send_recv ${CMAKE_CURRENT_LIST_DIR}/send_recv.c)
  16. set_target_properties(send_recv PROPERTIES SUFFIX .wasm)
  17. target_include_directories(send_recv PUBLIC ${CMAKE_CURRENT_LIST_DIR}/inc)
  18. target_link_libraries(send_recv socket_wasi_ext)
  19. target_link_options(send_recv PRIVATE
  20. LINKER:--export=__heap_base
  21. LINKER:--export=__data_end
  22. LINKER:--shared-memory,--max-memory=196608
  23. LINKER:--no-check-features
  24. LINKER:--allow-undefined
  25. )
  26. if(WASM_TO_AOT)
  27. # wasm -> aot
  28. add_custom_target(send_recv_aot ALL
  29. COMMAND pwd && ${WAMRC_PATH} --invoke-c-api-import --enable-multi-thread -o ./send_recv.aot ./send_recv.wasm
  30. DEPENDS send_recv
  31. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  32. )
  33. endif()
  34. #
  35. # install
  36. if(WASM_TO_AOT)
  37. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/send_recv.aot DESTINATION . )
  38. else()
  39. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/send_recv.wasm DESTINATION . )
  40. endif()