mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-02-11 09:25:20 +00:00
Use system libuv if available (#1861)
This PR attempts to search for the system libuv and use it if found instead of downloading it. As reported in #1831, this is needed because some tools build in a sandbox and clear the extra sources.
This commit is contained in:
parent
10c96b19d0
commit
f51d98f850
28
core/iwasm/libraries/libc-uvwasi/FindLIBUV.cmake
Normal file
28
core/iwasm/libraries/libc-uvwasi/FindLIBUV.cmake
Normal file
|
@ -0,0 +1,28 @@
|
|||
# Copyright (C) 2023 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# Find libuv library
|
||||
# This module defines
|
||||
# LIBUV_FOUND, if false, do not try to link to libuv
|
||||
# LIBUV_LIBRARIES
|
||||
# LIBUV_INCLUDE_DIR, where to find uv.h
|
||||
|
||||
find_path(LIBUV_INCLUDE_DIR NAMES uv.h)
|
||||
find_library(LIBUV_LIBRARIES NAMES uv libuv)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(
|
||||
LIBUV
|
||||
FOUND_VAR LIBUV_FOUND
|
||||
REQUIRED_VARS
|
||||
LIBUV_LIBRARIES
|
||||
LIBUV_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND LIBUV_LIBRARIES iphlpapi)
|
||||
list(APPEND LIBUV_LIBRARIES psapi)
|
||||
list(APPEND LIBUV_LIBRARIES userenv)
|
||||
list(APPEND LIBUV_LIBRARIES ws2_32)
|
||||
endif()
|
25
core/iwasm/libraries/libc-uvwasi/FindUVWASI.cmake
Normal file
25
core/iwasm/libraries/libc-uvwasi/FindUVWASI.cmake
Normal file
|
@ -0,0 +1,25 @@
|
|||
# Copyright (C) 2023 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
# Find libuvwasi library
|
||||
# This module defines
|
||||
# UVWASI_FOUND, if false, do not try to link to libuvwasi
|
||||
# UVWASI_LIBRARIES
|
||||
# UVWASI_INCLUDE_DIR, where to find headers
|
||||
|
||||
find_path(UVWASI_INCLUDE_DIR NAMES uvwasi.h wasi_serdes.h wasi_types.h PATH_SUFFIXES uvwasi)
|
||||
find_library(UVWASI_LIBRARIES NAMES uvwasi_a)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(
|
||||
UVWASI
|
||||
FOUND_VAR UVWASI_FOUND
|
||||
REQUIRED_VARS
|
||||
UVWASI_LIBRARIES
|
||||
UVWASI_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(UVWASI_FOUND)
|
||||
set(UVWASI_INCLUDE_DIR ${UVWASI_INCLUDE_DIR}/uvwasi)
|
||||
endif()
|
|
@ -9,36 +9,53 @@ add_definitions (-DWASM_ENABLE_LIBC_WASI=1 -DWASM_ENABLE_UVWASI=1)
|
|||
|
||||
include(FetchContent)
|
||||
|
||||
# Point CMake at the custom modules to find libuv and uvwasi
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
## libuv
|
||||
FetchContent_Declare(
|
||||
libuv
|
||||
GIT_REPOSITORY https://github.com/libuv/libuv.git
|
||||
GIT_TAG ${LIBUV_VERSION}
|
||||
)
|
||||
FetchContent_GetProperties(libuv)
|
||||
if (NOT libuv_POPULATED)
|
||||
message("-- Fetching libuv ..")
|
||||
FetchContent_Populate(libuv)
|
||||
include_directories("${libuv_SOURCE_DIR}/include")
|
||||
add_subdirectory(${libuv_SOURCE_DIR} ${libuv_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
set (UV_A_LIBS uv_a)
|
||||
set_target_properties(uv_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
||||
find_package(LIBUV QUIET)
|
||||
if (LIBUV_FOUND)
|
||||
include_directories(${LIBUV_INCLUDE_DIR})
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
libuv
|
||||
GIT_REPOSITORY https://github.com/libuv/libuv.git
|
||||
GIT_TAG ${LIBUV_VERSION}
|
||||
)
|
||||
FetchContent_GetProperties(libuv)
|
||||
if (NOT libuv_POPULATED)
|
||||
message("-- Fetching libuv ..")
|
||||
FetchContent_Populate(libuv)
|
||||
include_directories("${libuv_SOURCE_DIR}/include")
|
||||
add_subdirectory(${libuv_SOURCE_DIR} ${libuv_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
set (LIBUV_LIBRARIES uv_a)
|
||||
set_target_properties(uv_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
## uvwasi
|
||||
FetchContent_Declare(
|
||||
uvwasi
|
||||
GIT_REPOSITORY https://github.com/nodejs/uvwasi.git
|
||||
GIT_TAG main
|
||||
)
|
||||
FetchContent_GetProperties(uvwasi)
|
||||
if (NOT uvwasi_POPULATED)
|
||||
message("-- Fetching uvwasi ..")
|
||||
FetchContent_Populate(uvwasi)
|
||||
include_directories("${uvwasi_SOURCE_DIR}/include")
|
||||
add_subdirectory(${uvwasi_SOURCE_DIR} ${uvwasi_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
find_package(UVWASI QUIET)
|
||||
if (UVWASI_FOUND)
|
||||
include_directories(${UVWASI_INCLUDE_DIR})
|
||||
else()
|
||||
FetchContent_Declare(
|
||||
uvwasi
|
||||
GIT_REPOSITORY https://github.com/nodejs/uvwasi.git
|
||||
GIT_TAG main
|
||||
)
|
||||
FetchContent_GetProperties(uvwasi)
|
||||
if (NOT uvwasi_POPULATED)
|
||||
message("-- Fetching uvwasi ..")
|
||||
FetchContent_Populate(uvwasi)
|
||||
include_directories("${uvwasi_SOURCE_DIR}/include")
|
||||
add_subdirectory(${uvwasi_SOURCE_DIR} ${uvwasi_BINARY_DIR} EXCLUDE_FROM_ALL)
|
||||
set (UVWASI_LIBRARIES uvwasi_a)
|
||||
set_target_properties(uvwasi_a PROPERTIES POSITION_INDEPENDENT_CODE 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file (GLOB_RECURSE source_all ${LIBC_WASI_DIR}/*.c ${uvwasi_SOURCE_DIR}/src/*.c)
|
||||
set (UV_A_LIBS ${LIBUV_LIBRARIES} ${UVWASI_LIBRARIES})
|
||||
|
||||
file (GLOB_RECURSE source_all ${LIBC_WASI_DIR}/*.c)
|
||||
|
||||
set (LIBC_WASI_SOURCE ${source_all})
|
||||
|
|
Loading…
Reference in New Issue
Block a user