Skip to content

Commit 7474c47

Browse files
committed
build: try to enable io_uring if it is not specified
* configure.py: do not specify an option if "value_when_none" is None * configure.py: make IO_URING an nullable option, so we don't specify this option in the cmake command line option if user does not explicity specify it in the configure.py command line. * cmake: add a function `set_option_if_package_is_found()` to set an option if its value is not explicitly specified, while the package required for building it is found. this function can be reused to set other nullable option which requires a corresponding package for enabling it. * cmake: add the `Seastar_IO_URING` option only if it is specified, and try to enable it if it is not specified. * cmake: mark "LibUring" REQUIRED only when "Seastar_IO_URING" is specified and is ON or yes or TRUE, etc. Signed-off-by: Kefu Chai <[email protected]>
1 parent 32bf061 commit 7474c47

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

CMakeLists.txt

+17-7
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,17 @@ set (Seastar_ALLOC_PAGE_SIZE
188188
STRING
189189
"Override the Seastar allocator page size, in bytes.")
190190

191+
function (set_option_if_package_is_found option_name package_name)
192+
# if the package is found, set the option on behalf of user unless it is
193+
# explicitly specified,
194+
if (DEFINED ${option_name})
195+
return ()
196+
endif ()
197+
if (${package_name}_FOUND)
198+
set (${option_name} ON CACHE BOOL "")
199+
endif ()
200+
endfunction ()
201+
191202
option (Seastar_APPS
192203
"Enable application targets."
193204
ON)
@@ -230,9 +241,11 @@ option (Seastar_HWLOC
230241
"Enable hwloc support."
231242
ON)
232243

233-
option (Seastar_IO_URING
234-
"Enable io_uring support."
235-
ON)
244+
if (DEFINED Seastar_IO_URING)
245+
option (Seastar_IO_URING
246+
"Enable io_uring support."
247+
ON)
248+
endif ()
236249

237250
set (Seastar_JENKINS
238251
""
@@ -925,11 +938,8 @@ if (Seastar_HWLOC)
925938
PRIVATE hwloc::hwloc)
926939
endif ()
927940

941+
set_option_if_package_is_found(Seastar_IO_URING LibUring)
928942
if (Seastar_IO_URING)
929-
if (NOT LibUring_FOUND)
930-
message (FATAL_ERROR "`io_uring` supported is enabled but liburing is not available!")
931-
endif ()
932-
933943
list (APPEND Seastar_PRIVATE_COMPILE_DEFINITIONS SEASTAR_HAVE_URING)
934944
target_link_libraries (seastar
935945
PRIVATE URING::uring)

cmake/SeastarDependencies.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ macro (seastar_find_dependencies)
9797
set (_seastar_dep_args_lz4 1.7.3 REQUIRED)
9898
set (_seastar_dep_args_GnuTLS 3.3.26 REQUIRED)
9999
set (_seastar_dep_args_LibUring 2.0)
100+
if (Seastar_IO_URING)
101+
list (APPEND _seastar_dep_args_LibUring REQUIRED)
102+
endif ()
100103
set (_seastar_dep_args_StdAtomic REQUIRED)
101104
set (_seastar_dep_args_hwloc 1.11.2)
102105
set (_seastar_dep_args_lksctp-tools REQUIRED)

configure.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def configure_mode(mode):
201201
tr(args.dpdk, 'DPDK'),
202202
tr(infer_dpdk_machine(args.user_cflags), 'DPDK_MACHINE'),
203203
tr(args.hwloc, 'HWLOC', value_when_none='yes'),
204-
tr(args.io_uring, 'IO_URING', value_when_none='yes'),
204+
tr(args.io_uring, 'IO_URING', value_when_none=None),
205205
tr(args.alloc_failure_injection, 'ALLOC_FAILURE_INJECTION', value_when_none='DEFAULT'),
206206
tr(args.task_backtrace, 'TASK_BACKTRACE'),
207207
tr(args.alloc_page_size, 'ALLOC_PAGE_SIZE'),
@@ -233,7 +233,9 @@ def configure_mode(mode):
233233
# everything.
234234
ARGS = ['cmake', '-G', 'Ninja', '../..']
235235
dir = BUILD_PATH
236-
ARGS += TRANSLATED_ARGS
236+
# filter out empty args, their values are actually "guess",
237+
# CMake should be able to figure it out.
238+
ARGS += filter(lambda arg: arg, TRANSLATED_ARGS)
237239
if args.verbose:
238240
print("Running CMake in '{}' ...".format(dir))
239241
print(" \\\n ".join(ARGS))

seastar_cmake.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ def translate_arg(arg, new_name, value_when_none='no'):
4646
else:
4747
value = arg
4848

49-
return '-DSeastar_{}={}'.format(new_name, value)
49+
if value is None:
50+
return ''
51+
else:
52+
return '-DSeastar_{}={}'.format(new_name, value)

0 commit comments

Comments
 (0)