libc_uvwasi.cmake 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Copyright (C) 2019 Intel Corporation. All rights reserved.
  2. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  3. # Yes. To solve the compatibility issue with CMAKE (>= 4.0), we need to update
  4. # our `cmake_minimum_required()` to 3.5. However, there are CMakeLists.txt
  5. # from 3rd parties that we should not alter. Therefore, in addition to
  6. # changing the `cmake_minimum_required()`, we should also add a configuration
  7. # here that is compatible with earlier versions.
  8. set(CMAKE_POLICY_VERSION_MINIMUM 3.5 FORCE)
  9. set (LIBC_WASI_DIR ${CMAKE_CURRENT_LIST_DIR})
  10. set (LIBUV_VERSION v1.51.0)
  11. add_definitions (-DWASM_ENABLE_LIBC_WASI=1 -DWASM_ENABLE_UVWASI=1)
  12. include(FetchContent)
  13. # Point CMake at the custom modules to find libuv and uvwasi
  14. list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
  15. ## libuv
  16. find_package(LIBUV QUIET)
  17. if (LIBUV_FOUND)
  18. include_directories(${LIBUV_INCLUDE_DIR})
  19. else()
  20. FetchContent_Declare(
  21. libuv
  22. GIT_REPOSITORY https://github.com/libuv/libuv.git
  23. GIT_TAG ${LIBUV_VERSION}
  24. )
  25. FetchContent_MakeAvailable(libuv)
  26. include_directories("${libuv_SOURCE_DIR}/include")
  27. set (LIBUV_LIBRARIES uv_a)
  28. set_target_properties(uv_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
  29. endif()
  30. ## uvwasi
  31. find_package(UVWASI QUIET)
  32. if (UVWASI_FOUND)
  33. include_directories(${UVWASI_INCLUDE_DIR})
  34. else()
  35. FetchContent_Declare(
  36. uvwasi
  37. GIT_REPOSITORY https://github.com/nodejs/uvwasi.git
  38. GIT_TAG 392e1f1c1c8a2d2102c9f2e0b9f35959a149d133
  39. )
  40. FetchContent_MakeAvailable(uvwasi)
  41. include_directories("${uvwasi_SOURCE_DIR}/include")
  42. set (UVWASI_LIBRARIES uvwasi_a)
  43. set_target_properties(uvwasi_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
  44. endif()
  45. set (UV_A_LIBS ${LIBUV_LIBRARIES} ${UVWASI_LIBRARIES})
  46. file (GLOB_RECURSE source_all ${LIBC_WASI_DIR}/*.c)
  47. set (LIBC_WASI_SOURCE ${source_all})