-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ceph#34535 from changchengx/refine_build_liburing
cmake: refactor liburing support Reviewed-by: Kefu Chai <[email protected]>
- Loading branch information
Showing
4 changed files
with
59 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
function(build_uring) | ||
include(FindMake) | ||
find_make("MAKE_EXECUTABLE" "make_cmd") | ||
|
||
include(ExternalProject) | ||
ExternalProject_Add(liburing_ext | ||
GIT_REPOSITORY http://git.kernel.dk/liburing | ||
GIT_TAG "4e360f71131918c36774f51688e5c65dea8d43f2" | ||
SOURCE_DIR ${CMAKE_BINARY_DIR}/src/liburing | ||
CONFIGURE_COMMAND <SOURCE_DIR>/configure | ||
BUILD_COMMAND env CC=${CMAKE_C_COMPILER} ${make_cmd} -C src -s | ||
BUILD_IN_SOURCE 1 | ||
BUILD_BYPRODUCTS "<SOURCE_DIR>/src/liburing.a" | ||
INSTALL_COMMAND "") | ||
unset(make_cmd) | ||
|
||
ExternalProject_Get_Property(liburing_ext source_dir) | ||
set(URING_INCLUDE_DIR "${source_dir}/src/include") | ||
set(URING_LIBRARY_DIR "${source_dir}/src") | ||
|
||
add_library(uring::uring STATIC IMPORTED GLOBAL) | ||
add_dependencies(uring::uring liburing_ext) | ||
file(MAKE_DIRECTORY ${URING_INCLUDE_DIR}) | ||
set_target_properties(uring::uring PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES ${URING_INCLUDE_DIR} | ||
IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
IMPORTED_LOCATION "${URING_LIBRARY_DIR}/liburing.a") | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# - Find uring | ||
# | ||
# URING_INCLUDE_DIR - Where to find liburing.h | ||
# URING_LIBRARIES - List of libraries when using uring. | ||
# uring_FOUND - True if uring found. | ||
|
||
find_path(URING_INCLUDE_DIR liburing.h) | ||
find_library(URING_LIBRARIES liburing.a liburing) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(uring DEFAULT_MSG URING_LIBRARIES URING_INCLUDE_DIR) | ||
|
||
if(uring_FOUND AND NOT TARGET uring::uring) | ||
add_library(uring::uring UNKNOWN IMPORTED) | ||
set_target_properties(uring::uring PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES "${URING_INCLUDE_DIR}" | ||
IMPORTED_LINK_INTERFACE_LANGUAGES "C" | ||
IMPORTED_LOCATION "${URING_LIBRARIES}") | ||
endif() | ||
|
||
mark_as_advanced(URING_INCLUDE_DIR URING_LIBRARIES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters